babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650
  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. private _tempMatrix2;
  7514. protected _isWorldMatrixFrozen: boolean;
  7515. /** @hidden */
  7516. _indexInSceneTransformNodesArray: number;
  7517. /**
  7518. * An event triggered after the world matrix is updated
  7519. */
  7520. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7521. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7522. /**
  7523. * Gets a string identifying the name of the class
  7524. * @returns "TransformNode" string
  7525. */
  7526. getClassName(): string;
  7527. /**
  7528. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7529. */
  7530. position: Vector3;
  7531. /**
  7532. * 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)).
  7533. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7534. */
  7535. rotation: Vector3;
  7536. /**
  7537. * 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)).
  7538. */
  7539. scaling: Vector3;
  7540. /**
  7541. * 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).
  7542. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7543. */
  7544. rotationQuaternion: Nullable<Quaternion>;
  7545. /**
  7546. * The forward direction of that transform in world space.
  7547. */
  7548. readonly forward: Vector3;
  7549. /**
  7550. * The up direction of that transform in world space.
  7551. */
  7552. readonly up: Vector3;
  7553. /**
  7554. * The right direction of that transform in world space.
  7555. */
  7556. readonly right: Vector3;
  7557. /**
  7558. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7559. * @param matrix the matrix to copy the pose from
  7560. * @returns this TransformNode.
  7561. */
  7562. updatePoseMatrix(matrix: Matrix): TransformNode;
  7563. /**
  7564. * Returns the mesh Pose matrix.
  7565. * @returns the pose matrix
  7566. */
  7567. getPoseMatrix(): Matrix;
  7568. /** @hidden */
  7569. _isSynchronized(): boolean;
  7570. /** @hidden */
  7571. _initCache(): void;
  7572. /**
  7573. * Flag the transform node as dirty (Forcing it to update everything)
  7574. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7575. * @returns this transform node
  7576. */
  7577. markAsDirty(property: string): TransformNode;
  7578. /**
  7579. * Returns the current mesh absolute position.
  7580. * Returns a Vector3.
  7581. */
  7582. readonly absolutePosition: Vector3;
  7583. /**
  7584. * Sets a new matrix to apply before all other transformation
  7585. * @param matrix defines the transform matrix
  7586. * @returns the current TransformNode
  7587. */
  7588. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7589. /**
  7590. * Sets a new pivot matrix to the current node
  7591. * @param matrix defines the new pivot matrix to use
  7592. * @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
  7593. * @returns the current TransformNode
  7594. */
  7595. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7596. /**
  7597. * Returns the mesh pivot matrix.
  7598. * Default : Identity.
  7599. * @returns the matrix
  7600. */
  7601. getPivotMatrix(): Matrix;
  7602. /**
  7603. * Prevents the World matrix to be computed any longer.
  7604. * @returns the TransformNode.
  7605. */
  7606. freezeWorldMatrix(): TransformNode;
  7607. /**
  7608. * Allows back the World matrix computation.
  7609. * @returns the TransformNode.
  7610. */
  7611. unfreezeWorldMatrix(): this;
  7612. /**
  7613. * True if the World matrix has been frozen.
  7614. */
  7615. readonly isWorldMatrixFrozen: boolean;
  7616. /**
  7617. * Retuns the mesh absolute position in the World.
  7618. * @returns a Vector3.
  7619. */
  7620. getAbsolutePosition(): Vector3;
  7621. /**
  7622. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7623. * @param absolutePosition the absolute position to set
  7624. * @returns the TransformNode.
  7625. */
  7626. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7627. /**
  7628. * Sets the mesh position in its local space.
  7629. * @param vector3 the position to set in localspace
  7630. * @returns the TransformNode.
  7631. */
  7632. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7633. /**
  7634. * Returns the mesh position in the local space from the current World matrix values.
  7635. * @returns a new Vector3.
  7636. */
  7637. getPositionExpressedInLocalSpace(): Vector3;
  7638. /**
  7639. * Translates the mesh along the passed Vector3 in its local space.
  7640. * @param vector3 the distance to translate in localspace
  7641. * @returns the TransformNode.
  7642. */
  7643. locallyTranslate(vector3: Vector3): TransformNode;
  7644. private static _lookAtVectorCache;
  7645. /**
  7646. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7647. * @param targetPoint the position (must be in same space as current mesh) to look at
  7648. * @param yawCor optional yaw (y-axis) correction in radians
  7649. * @param pitchCor optional pitch (x-axis) correction in radians
  7650. * @param rollCor optional roll (z-axis) correction in radians
  7651. * @param space the choosen space of the target
  7652. * @returns the TransformNode.
  7653. */
  7654. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7655. /**
  7656. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7657. * This Vector3 is expressed in the World space.
  7658. * @param localAxis axis to rotate
  7659. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7660. */
  7661. getDirection(localAxis: Vector3): Vector3;
  7662. /**
  7663. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7664. * localAxis is expressed in the mesh local space.
  7665. * result is computed in the Wordl space from the mesh World matrix.
  7666. * @param localAxis axis to rotate
  7667. * @param result the resulting transformnode
  7668. * @returns this TransformNode.
  7669. */
  7670. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7671. /**
  7672. * Sets this transform node rotation to the given local axis.
  7673. * @param localAxis the axis in local space
  7674. * @param yawCor optional yaw (y-axis) correction in radians
  7675. * @param pitchCor optional pitch (x-axis) correction in radians
  7676. * @param rollCor optional roll (z-axis) correction in radians
  7677. * @returns this TransformNode
  7678. */
  7679. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7680. /**
  7681. * Sets a new pivot point to the current node
  7682. * @param point defines the new pivot point to use
  7683. * @param space defines if the point is in world or local space (local by default)
  7684. * @returns the current TransformNode
  7685. */
  7686. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7687. /**
  7688. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7689. * @returns the pivot point
  7690. */
  7691. getPivotPoint(): Vector3;
  7692. /**
  7693. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7694. * @param result the vector3 to store the result
  7695. * @returns this TransformNode.
  7696. */
  7697. getPivotPointToRef(result: Vector3): TransformNode;
  7698. /**
  7699. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7700. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7701. */
  7702. getAbsolutePivotPoint(): Vector3;
  7703. /**
  7704. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7705. * @param result vector3 to store the result
  7706. * @returns this TransformNode.
  7707. */
  7708. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7709. /**
  7710. * Defines the passed node as the parent of the current node.
  7711. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7712. * @param node the node ot set as the parent
  7713. * @returns this TransformNode.
  7714. */
  7715. setParent(node: Nullable<Node>): TransformNode;
  7716. private _nonUniformScaling;
  7717. /**
  7718. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7719. */
  7720. readonly nonUniformScaling: boolean;
  7721. /** @hidden */
  7722. _updateNonUniformScalingState(value: boolean): boolean;
  7723. /**
  7724. * Attach the current TransformNode to another TransformNode associated with a bone
  7725. * @param bone Bone affecting the TransformNode
  7726. * @param affectedTransformNode TransformNode associated with the bone
  7727. * @returns this object
  7728. */
  7729. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7730. /**
  7731. * Detach the transform node if its associated with a bone
  7732. * @returns this object
  7733. */
  7734. detachFromBone(): TransformNode;
  7735. private static _rotationAxisCache;
  7736. /**
  7737. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7738. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7739. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7740. * The passed axis is also normalized.
  7741. * @param axis the axis to rotate around
  7742. * @param amount the amount to rotate in radians
  7743. * @param space Space to rotate in (Default: local)
  7744. * @returns the TransformNode.
  7745. */
  7746. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7747. /**
  7748. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7749. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7750. * The passed axis is also normalized. .
  7751. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7752. * @param point the point to rotate around
  7753. * @param axis the axis to rotate around
  7754. * @param amount the amount to rotate in radians
  7755. * @returns the TransformNode
  7756. */
  7757. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7758. /**
  7759. * Translates the mesh along the axis vector for the passed distance in the given space.
  7760. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7761. * @param axis the axis to translate in
  7762. * @param distance the distance to translate
  7763. * @param space Space to rotate in (Default: local)
  7764. * @returns the TransformNode.
  7765. */
  7766. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7767. /**
  7768. * Adds a rotation step to the mesh current rotation.
  7769. * x, y, z are Euler angles expressed in radians.
  7770. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7771. * This means this rotation is made in the mesh local space only.
  7772. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7773. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7774. * ```javascript
  7775. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7776. * ```
  7777. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7778. * 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.
  7779. * @param x Rotation to add
  7780. * @param y Rotation to add
  7781. * @param z Rotation to add
  7782. * @returns the TransformNode.
  7783. */
  7784. addRotation(x: number, y: number, z: number): TransformNode;
  7785. /**
  7786. * Computes the world matrix of the node
  7787. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7788. * @returns the world matrix
  7789. */
  7790. computeWorldMatrix(force?: boolean): Matrix;
  7791. protected _afterComputeWorldMatrix(): void;
  7792. /**
  7793. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7794. * @param func callback function to add
  7795. *
  7796. * @returns the TransformNode.
  7797. */
  7798. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7799. /**
  7800. * Removes a registered callback function.
  7801. * @param func callback function to remove
  7802. * @returns the TransformNode.
  7803. */
  7804. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7805. /**
  7806. * Gets the position of the current mesh in camera space
  7807. * @param camera defines the camera to use
  7808. * @returns a position
  7809. */
  7810. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7811. /**
  7812. * Returns the distance from the mesh to the active camera
  7813. * @param camera defines the camera to use
  7814. * @returns the distance
  7815. */
  7816. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7817. /**
  7818. * Clone the current transform node
  7819. * @param name Name of the new clone
  7820. * @param newParent New parent for the clone
  7821. * @param doNotCloneChildren Do not clone children hierarchy
  7822. * @returns the new transform node
  7823. */
  7824. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7825. /**
  7826. * Serializes the objects information.
  7827. * @param currentSerializationObject defines the object to serialize in
  7828. * @returns the serialized object
  7829. */
  7830. serialize(currentSerializationObject?: any): any;
  7831. /**
  7832. * Returns a new TransformNode object parsed from the source provided.
  7833. * @param parsedTransformNode is the source.
  7834. * @param scene the scne the object belongs to
  7835. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7836. * @returns a new TransformNode object parsed from the source provided.
  7837. */
  7838. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7839. /**
  7840. * Get all child-transformNodes of this node
  7841. * @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
  7842. * @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
  7843. * @returns an array of TransformNode
  7844. */
  7845. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7846. /**
  7847. * Releases resources associated with this transform node.
  7848. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7849. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7850. */
  7851. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7852. }
  7853. }
  7854. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7855. /**
  7856. * Class used to override all child animations of a given target
  7857. */
  7858. export class AnimationPropertiesOverride {
  7859. /**
  7860. * Gets or sets a value indicating if animation blending must be used
  7861. */
  7862. enableBlending: boolean;
  7863. /**
  7864. * Gets or sets the blending speed to use when enableBlending is true
  7865. */
  7866. blendingSpeed: number;
  7867. /**
  7868. * Gets or sets the default loop mode to use
  7869. */
  7870. loopMode: number;
  7871. }
  7872. }
  7873. declare module "babylonjs/Bones/bone" {
  7874. import { Skeleton } from "babylonjs/Bones/skeleton";
  7875. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7876. import { Nullable } from "babylonjs/types";
  7877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7878. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7879. import { Node } from "babylonjs/node";
  7880. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7881. /**
  7882. * Class used to store bone information
  7883. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7884. */
  7885. export class Bone extends Node {
  7886. /**
  7887. * defines the bone name
  7888. */
  7889. name: string;
  7890. private static _tmpVecs;
  7891. private static _tmpQuat;
  7892. private static _tmpMats;
  7893. /**
  7894. * Gets the list of child bones
  7895. */
  7896. children: Bone[];
  7897. /** Gets the animations associated with this bone */
  7898. animations: import("babylonjs/Animations/animation").Animation[];
  7899. /**
  7900. * Gets or sets bone length
  7901. */
  7902. length: number;
  7903. /**
  7904. * @hidden Internal only
  7905. * Set this value to map this bone to a different index in the transform matrices
  7906. * Set this value to -1 to exclude the bone from the transform matrices
  7907. */
  7908. _index: Nullable<number>;
  7909. private _skeleton;
  7910. private _localMatrix;
  7911. private _restPose;
  7912. private _baseMatrix;
  7913. private _absoluteTransform;
  7914. private _invertedAbsoluteTransform;
  7915. private _parent;
  7916. private _scalingDeterminant;
  7917. private _worldTransform;
  7918. private _localScaling;
  7919. private _localRotation;
  7920. private _localPosition;
  7921. private _needToDecompose;
  7922. private _needToCompose;
  7923. /** @hidden */
  7924. _linkedTransformNode: Nullable<TransformNode>;
  7925. /** @hidden */
  7926. /** @hidden */
  7927. _matrix: Matrix;
  7928. /**
  7929. * Create a new bone
  7930. * @param name defines the bone name
  7931. * @param skeleton defines the parent skeleton
  7932. * @param parentBone defines the parent (can be null if the bone is the root)
  7933. * @param localMatrix defines the local matrix
  7934. * @param restPose defines the rest pose matrix
  7935. * @param baseMatrix defines the base matrix
  7936. * @param index defines index of the bone in the hiearchy
  7937. */
  7938. constructor(
  7939. /**
  7940. * defines the bone name
  7941. */
  7942. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7943. /**
  7944. * Gets the current object class name.
  7945. * @return the class name
  7946. */
  7947. getClassName(): string;
  7948. /**
  7949. * Gets the parent skeleton
  7950. * @returns a skeleton
  7951. */
  7952. getSkeleton(): Skeleton;
  7953. /**
  7954. * Gets parent bone
  7955. * @returns a bone or null if the bone is the root of the bone hierarchy
  7956. */
  7957. getParent(): Nullable<Bone>;
  7958. /**
  7959. * Returns an array containing the root bones
  7960. * @returns an array containing the root bones
  7961. */
  7962. getChildren(): Array<Bone>;
  7963. /**
  7964. * Sets the parent bone
  7965. * @param parent defines the parent (can be null if the bone is the root)
  7966. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7967. */
  7968. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7969. /**
  7970. * Gets the local matrix
  7971. * @returns a matrix
  7972. */
  7973. getLocalMatrix(): Matrix;
  7974. /**
  7975. * Gets the base matrix (initial matrix which remains unchanged)
  7976. * @returns a matrix
  7977. */
  7978. getBaseMatrix(): Matrix;
  7979. /**
  7980. * Gets the rest pose matrix
  7981. * @returns a matrix
  7982. */
  7983. getRestPose(): Matrix;
  7984. /**
  7985. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7986. */
  7987. getWorldMatrix(): Matrix;
  7988. /**
  7989. * Sets the local matrix to rest pose matrix
  7990. */
  7991. returnToRest(): void;
  7992. /**
  7993. * Gets the inverse of the absolute transform matrix.
  7994. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7995. * @returns a matrix
  7996. */
  7997. getInvertedAbsoluteTransform(): Matrix;
  7998. /**
  7999. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8000. * @returns a matrix
  8001. */
  8002. getAbsoluteTransform(): Matrix;
  8003. /**
  8004. * Links with the given transform node.
  8005. * The local matrix of this bone is copied from the transform node every frame.
  8006. * @param transformNode defines the transform node to link to
  8007. */
  8008. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8009. /** Gets or sets current position (in local space) */
  8010. position: Vector3;
  8011. /** Gets or sets current rotation (in local space) */
  8012. rotation: Vector3;
  8013. /** Gets or sets current rotation quaternion (in local space) */
  8014. rotationQuaternion: Quaternion;
  8015. /** Gets or sets current scaling (in local space) */
  8016. scaling: Vector3;
  8017. /**
  8018. * Gets the animation properties override
  8019. */
  8020. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8021. private _decompose;
  8022. private _compose;
  8023. /**
  8024. * Update the base and local matrices
  8025. * @param matrix defines the new base or local matrix
  8026. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8027. * @param updateLocalMatrix defines if the local matrix should be updated
  8028. */
  8029. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8030. /** @hidden */
  8031. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8032. /**
  8033. * Flag the bone as dirty (Forcing it to update everything)
  8034. */
  8035. markAsDirty(): void;
  8036. private _markAsDirtyAndCompose;
  8037. private _markAsDirtyAndDecompose;
  8038. /**
  8039. * Translate the bone in local or world space
  8040. * @param vec The amount to translate the bone
  8041. * @param space The space that the translation is in
  8042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8043. */
  8044. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8045. /**
  8046. * Set the postion of the bone in local or world space
  8047. * @param position The position to set the bone
  8048. * @param space The space that the position is in
  8049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8050. */
  8051. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8052. /**
  8053. * Set the absolute position of the bone (world space)
  8054. * @param position The position to set the bone
  8055. * @param mesh The mesh that this bone is attached to
  8056. */
  8057. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8058. /**
  8059. * Scale the bone on the x, y and z axes (in local space)
  8060. * @param x The amount to scale the bone on the x axis
  8061. * @param y The amount to scale the bone on the y axis
  8062. * @param z The amount to scale the bone on the z axis
  8063. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8064. */
  8065. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8066. /**
  8067. * Set the bone scaling in local space
  8068. * @param scale defines the scaling vector
  8069. */
  8070. setScale(scale: Vector3): void;
  8071. /**
  8072. * Gets the current scaling in local space
  8073. * @returns the current scaling vector
  8074. */
  8075. getScale(): Vector3;
  8076. /**
  8077. * Gets the current scaling in local space and stores it in a target vector
  8078. * @param result defines the target vector
  8079. */
  8080. getScaleToRef(result: Vector3): void;
  8081. /**
  8082. * Set the yaw, pitch, and roll of the bone in local or world space
  8083. * @param yaw The rotation of the bone on the y axis
  8084. * @param pitch The rotation of the bone on the x axis
  8085. * @param roll The rotation of the bone on the z axis
  8086. * @param space The space that the axes of rotation are in
  8087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8088. */
  8089. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8090. /**
  8091. * Add a rotation to the bone on an axis in local or world space
  8092. * @param axis The axis to rotate the bone on
  8093. * @param amount The amount to rotate the bone
  8094. * @param space The space that the axis is in
  8095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8096. */
  8097. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8098. /**
  8099. * Set the rotation of the bone to a particular axis angle in local or world space
  8100. * @param axis The axis to rotate the bone on
  8101. * @param angle The angle that the bone should be rotated to
  8102. * @param space The space that the axis is in
  8103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8104. */
  8105. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8106. /**
  8107. * Set the euler rotation of the bone in local of world space
  8108. * @param rotation The euler rotation that the bone should be set to
  8109. * @param space The space that the rotation is in
  8110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8111. */
  8112. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8113. /**
  8114. * Set the quaternion rotation of the bone in local of world space
  8115. * @param quat The quaternion rotation that the bone should be set to
  8116. * @param space The space that the rotation is in
  8117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8118. */
  8119. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8120. /**
  8121. * Set the rotation matrix of the bone in local of world space
  8122. * @param rotMat The rotation matrix that the bone should be set to
  8123. * @param space The space that the rotation is in
  8124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8125. */
  8126. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8127. private _rotateWithMatrix;
  8128. private _getNegativeRotationToRef;
  8129. /**
  8130. * Get the position of the bone in local or world space
  8131. * @param space The space that the returned position is in
  8132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8133. * @returns The position of the bone
  8134. */
  8135. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8136. /**
  8137. * Copy the position of the bone to a vector3 in local or world space
  8138. * @param space The space that the returned position is in
  8139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8140. * @param result The vector3 to copy the position to
  8141. */
  8142. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8143. /**
  8144. * Get the absolute position of the bone (world space)
  8145. * @param mesh The mesh that this bone is attached to
  8146. * @returns The absolute position of the bone
  8147. */
  8148. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8149. /**
  8150. * Copy the absolute position of the bone (world space) to the result param
  8151. * @param mesh The mesh that this bone is attached to
  8152. * @param result The vector3 to copy the absolute position to
  8153. */
  8154. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8155. /**
  8156. * Compute the absolute transforms of this bone and its children
  8157. */
  8158. computeAbsoluteTransforms(): void;
  8159. /**
  8160. * Get the world direction from an axis that is in the local space of the bone
  8161. * @param localAxis The local direction that is used to compute the world direction
  8162. * @param mesh The mesh that this bone is attached to
  8163. * @returns The world direction
  8164. */
  8165. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8166. /**
  8167. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8168. * @param localAxis The local direction that is used to compute the world direction
  8169. * @param mesh The mesh that this bone is attached to
  8170. * @param result The vector3 that the world direction will be copied to
  8171. */
  8172. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8173. /**
  8174. * Get the euler rotation of the bone in local or world space
  8175. * @param space The space that the rotation should be in
  8176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8177. * @returns The euler rotation
  8178. */
  8179. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8180. /**
  8181. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8182. * @param space The space that the rotation should be in
  8183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8184. * @param result The vector3 that the rotation should be copied to
  8185. */
  8186. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8187. /**
  8188. * Get the quaternion rotation of the bone in either local or world space
  8189. * @param space The space that the rotation should be in
  8190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8191. * @returns The quaternion rotation
  8192. */
  8193. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8194. /**
  8195. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8196. * @param space The space that the rotation should be in
  8197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8198. * @param result The quaternion that the rotation should be copied to
  8199. */
  8200. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8201. /**
  8202. * Get the rotation matrix of the bone in local or world space
  8203. * @param space The space that the rotation should be in
  8204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8205. * @returns The rotation matrix
  8206. */
  8207. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8208. /**
  8209. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8210. * @param space The space that the rotation should be in
  8211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8212. * @param result The quaternion that the rotation should be copied to
  8213. */
  8214. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8215. /**
  8216. * Get the world position of a point that is in the local space of the bone
  8217. * @param position The local position
  8218. * @param mesh The mesh that this bone is attached to
  8219. * @returns The world position
  8220. */
  8221. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8222. /**
  8223. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8224. * @param position The local position
  8225. * @param mesh The mesh that this bone is attached to
  8226. * @param result The vector3 that the world position should be copied to
  8227. */
  8228. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8229. /**
  8230. * Get the local position of a point that is in world space
  8231. * @param position The world position
  8232. * @param mesh The mesh that this bone is attached to
  8233. * @returns The local position
  8234. */
  8235. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8236. /**
  8237. * Get the local position of a point that is in world space and copy it to the result param
  8238. * @param position The world position
  8239. * @param mesh The mesh that this bone is attached to
  8240. * @param result The vector3 that the local position should be copied to
  8241. */
  8242. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8243. }
  8244. }
  8245. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8246. import { Nullable } from "babylonjs/types";
  8247. import { Scene } from "babylonjs/scene";
  8248. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8249. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8250. /**
  8251. * Class for creating a cube texture
  8252. */
  8253. export class CubeTexture extends BaseTexture {
  8254. private _delayedOnLoad;
  8255. /**
  8256. * The url of the texture
  8257. */
  8258. url: string;
  8259. /**
  8260. * Gets or sets the center of the bounding box associated with the cube texture.
  8261. * It must define where the camera used to render the texture was set
  8262. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8263. */
  8264. boundingBoxPosition: Vector3;
  8265. private _boundingBoxSize;
  8266. /**
  8267. * Gets or sets the size of the bounding box associated with the cube texture
  8268. * When defined, the cubemap will switch to local mode
  8269. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8270. * @example https://www.babylonjs-playground.com/#RNASML
  8271. */
  8272. /**
  8273. * Returns the bounding box size
  8274. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8275. */
  8276. boundingBoxSize: Vector3;
  8277. protected _rotationY: number;
  8278. /**
  8279. * Sets texture matrix rotation angle around Y axis in radians.
  8280. */
  8281. /**
  8282. * Gets texture matrix rotation angle around Y axis radians.
  8283. */
  8284. rotationY: number;
  8285. /**
  8286. * Are mip maps generated for this texture or not.
  8287. */
  8288. readonly noMipmap: boolean;
  8289. private _noMipmap;
  8290. private _files;
  8291. private _extensions;
  8292. private _textureMatrix;
  8293. private _format;
  8294. private _createPolynomials;
  8295. /** @hidden */
  8296. _prefiltered: boolean;
  8297. /**
  8298. * Creates a cube texture from an array of image urls
  8299. * @param files defines an array of image urls
  8300. * @param scene defines the hosting scene
  8301. * @param noMipmap specifies if mip maps are not used
  8302. * @returns a cube texture
  8303. */
  8304. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8305. /**
  8306. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8307. * @param url defines the url of the prefiltered texture
  8308. * @param scene defines the scene the texture is attached to
  8309. * @param forcedExtension defines the extension of the file if different from the url
  8310. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8311. * @return the prefiltered texture
  8312. */
  8313. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8314. /**
  8315. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8316. * as prefiltered data.
  8317. * @param rootUrl defines the url of the texture or the root name of the six images
  8318. * @param scene defines the scene the texture is attached to
  8319. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8320. * @param noMipmap defines if mipmaps should be created or not
  8321. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8322. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8323. * @param onError defines a callback triggered in case of error during load
  8324. * @param format defines the internal format to use for the texture once loaded
  8325. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8326. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8327. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8328. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8329. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8330. * @return the cube texture
  8331. */
  8332. 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);
  8333. /**
  8334. * Get the current class name of the texture useful for serialization or dynamic coding.
  8335. * @returns "CubeTexture"
  8336. */
  8337. getClassName(): string;
  8338. /**
  8339. * Update the url (and optional buffer) of this texture if url was null during construction.
  8340. * @param url the url of the texture
  8341. * @param forcedExtension defines the extension to use
  8342. * @param onLoad callback called when the texture is loaded (defaults to null)
  8343. */
  8344. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8345. /**
  8346. * Delays loading of the cube texture
  8347. * @param forcedExtension defines the extension to use
  8348. */
  8349. delayLoad(forcedExtension?: string): void;
  8350. /**
  8351. * Returns the reflection texture matrix
  8352. * @returns the reflection texture matrix
  8353. */
  8354. getReflectionTextureMatrix(): Matrix;
  8355. /**
  8356. * Sets the reflection texture matrix
  8357. * @param value Reflection texture matrix
  8358. */
  8359. setReflectionTextureMatrix(value: Matrix): void;
  8360. /**
  8361. * Parses text to create a cube texture
  8362. * @param parsedTexture define the serialized text to read from
  8363. * @param scene defines the hosting scene
  8364. * @param rootUrl defines the root url of the cube texture
  8365. * @returns a cube texture
  8366. */
  8367. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8368. /**
  8369. * Makes a clone, or deep copy, of the cube texture
  8370. * @returns a new cube texture
  8371. */
  8372. clone(): CubeTexture;
  8373. }
  8374. }
  8375. declare module "babylonjs/Shaders/postprocess.vertex" {
  8376. /** @hidden */
  8377. export var postprocessVertexShader: {
  8378. name: string;
  8379. shader: string;
  8380. };
  8381. }
  8382. declare module "babylonjs/Cameras/targetCamera" {
  8383. import { Nullable } from "babylonjs/types";
  8384. import { Camera } from "babylonjs/Cameras/camera";
  8385. import { Scene } from "babylonjs/scene";
  8386. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8387. /**
  8388. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8389. * This is the base of the follow, arc rotate cameras and Free camera
  8390. * @see http://doc.babylonjs.com/features/cameras
  8391. */
  8392. export class TargetCamera extends Camera {
  8393. private static _RigCamTransformMatrix;
  8394. private static _TargetTransformMatrix;
  8395. private static _TargetFocalPoint;
  8396. /**
  8397. * Define the current direction the camera is moving to
  8398. */
  8399. cameraDirection: Vector3;
  8400. /**
  8401. * Define the current rotation the camera is rotating to
  8402. */
  8403. cameraRotation: Vector2;
  8404. /**
  8405. * When set, the up vector of the camera will be updated by the rotation of the camera
  8406. */
  8407. updateUpVectorFromRotation: boolean;
  8408. private _tmpQuaternion;
  8409. /**
  8410. * Define the current rotation of the camera
  8411. */
  8412. rotation: Vector3;
  8413. /**
  8414. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8415. */
  8416. rotationQuaternion: Quaternion;
  8417. /**
  8418. * Define the current speed of the camera
  8419. */
  8420. speed: number;
  8421. /**
  8422. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8423. * around all axis.
  8424. */
  8425. noRotationConstraint: boolean;
  8426. /**
  8427. * Define the current target of the camera as an object or a position.
  8428. */
  8429. lockedTarget: any;
  8430. /** @hidden */
  8431. _currentTarget: Vector3;
  8432. /** @hidden */
  8433. _initialFocalDistance: number;
  8434. /** @hidden */
  8435. _viewMatrix: Matrix;
  8436. /** @hidden */
  8437. _camMatrix: Matrix;
  8438. /** @hidden */
  8439. _cameraTransformMatrix: Matrix;
  8440. /** @hidden */
  8441. _cameraRotationMatrix: Matrix;
  8442. /** @hidden */
  8443. _referencePoint: Vector3;
  8444. /** @hidden */
  8445. _transformedReferencePoint: Vector3;
  8446. protected _globalCurrentTarget: Vector3;
  8447. protected _globalCurrentUpVector: Vector3;
  8448. /** @hidden */
  8449. _reset: () => void;
  8450. private _defaultUp;
  8451. /**
  8452. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8453. * This is the base of the follow, arc rotate cameras and Free camera
  8454. * @see http://doc.babylonjs.com/features/cameras
  8455. * @param name Defines the name of the camera in the scene
  8456. * @param position Defines the start position of the camera in the scene
  8457. * @param scene Defines the scene the camera belongs to
  8458. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8459. */
  8460. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8461. /**
  8462. * Gets the position in front of the camera at a given distance.
  8463. * @param distance The distance from the camera we want the position to be
  8464. * @returns the position
  8465. */
  8466. getFrontPosition(distance: number): Vector3;
  8467. /** @hidden */
  8468. _getLockedTargetPosition(): Nullable<Vector3>;
  8469. private _storedPosition;
  8470. private _storedRotation;
  8471. private _storedRotationQuaternion;
  8472. /**
  8473. * Store current camera state of the camera (fov, position, rotation, etc..)
  8474. * @returns the camera
  8475. */
  8476. storeState(): Camera;
  8477. /**
  8478. * Restored camera state. You must call storeState() first
  8479. * @returns whether it was successful or not
  8480. * @hidden
  8481. */
  8482. _restoreStateValues(): boolean;
  8483. /** @hidden */
  8484. _initCache(): void;
  8485. /** @hidden */
  8486. _updateCache(ignoreParentClass?: boolean): void;
  8487. /** @hidden */
  8488. _isSynchronizedViewMatrix(): boolean;
  8489. /** @hidden */
  8490. _computeLocalCameraSpeed(): number;
  8491. /**
  8492. * Defines the target the camera should look at.
  8493. * This will automatically adapt alpha beta and radius to fit within the new target.
  8494. * @param target Defines the new target as a Vector or a mesh
  8495. */
  8496. setTarget(target: Vector3): void;
  8497. /**
  8498. * Return the current target position of the camera. This value is expressed in local space.
  8499. * @returns the target position
  8500. */
  8501. getTarget(): Vector3;
  8502. /** @hidden */
  8503. _decideIfNeedsToMove(): boolean;
  8504. /** @hidden */
  8505. _updatePosition(): void;
  8506. /** @hidden */
  8507. _checkInputs(): void;
  8508. protected _updateCameraRotationMatrix(): void;
  8509. /**
  8510. * 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)
  8511. * @returns the current camera
  8512. */
  8513. private _rotateUpVectorWithCameraRotationMatrix;
  8514. private _cachedRotationZ;
  8515. private _cachedQuaternionRotationZ;
  8516. /** @hidden */
  8517. _getViewMatrix(): Matrix;
  8518. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8519. /**
  8520. * @hidden
  8521. */
  8522. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8523. /**
  8524. * @hidden
  8525. */
  8526. _updateRigCameras(): void;
  8527. private _getRigCamPositionAndTarget;
  8528. /**
  8529. * Gets the current object class name.
  8530. * @return the class name
  8531. */
  8532. getClassName(): string;
  8533. }
  8534. }
  8535. declare module "babylonjs/Cameras/cameraInputsManager" {
  8536. import { Nullable } from "babylonjs/types";
  8537. import { Camera } from "babylonjs/Cameras/camera";
  8538. /**
  8539. * @ignore
  8540. * This is a list of all the different input types that are available in the application.
  8541. * Fo instance: ArcRotateCameraGamepadInput...
  8542. */
  8543. export var CameraInputTypes: {};
  8544. /**
  8545. * This is the contract to implement in order to create a new input class.
  8546. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8547. */
  8548. export interface ICameraInput<TCamera extends Camera> {
  8549. /**
  8550. * Defines the camera the input is attached to.
  8551. */
  8552. camera: Nullable<TCamera>;
  8553. /**
  8554. * Gets the class name of the current intput.
  8555. * @returns the class name
  8556. */
  8557. getClassName(): string;
  8558. /**
  8559. * Get the friendly name associated with the input class.
  8560. * @returns the input friendly name
  8561. */
  8562. getSimpleName(): string;
  8563. /**
  8564. * Attach the input controls to a specific dom element to get the input from.
  8565. * @param element Defines the element the controls should be listened from
  8566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8567. */
  8568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8569. /**
  8570. * Detach the current controls from the specified dom element.
  8571. * @param element Defines the element to stop listening the inputs from
  8572. */
  8573. detachControl(element: Nullable<HTMLElement>): void;
  8574. /**
  8575. * Update the current camera state depending on the inputs that have been used this frame.
  8576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8577. */
  8578. checkInputs?: () => void;
  8579. }
  8580. /**
  8581. * Represents a map of input types to input instance or input index to input instance.
  8582. */
  8583. export interface CameraInputsMap<TCamera extends Camera> {
  8584. /**
  8585. * Accessor to the input by input type.
  8586. */
  8587. [name: string]: ICameraInput<TCamera>;
  8588. /**
  8589. * Accessor to the input by input index.
  8590. */
  8591. [idx: number]: ICameraInput<TCamera>;
  8592. }
  8593. /**
  8594. * This represents the input manager used within a camera.
  8595. * It helps dealing with all the different kind of input attached to a camera.
  8596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8597. */
  8598. export class CameraInputsManager<TCamera extends Camera> {
  8599. /**
  8600. * Defines the list of inputs attahed to the camera.
  8601. */
  8602. attached: CameraInputsMap<TCamera>;
  8603. /**
  8604. * Defines the dom element the camera is collecting inputs from.
  8605. * This is null if the controls have not been attached.
  8606. */
  8607. attachedElement: Nullable<HTMLElement>;
  8608. /**
  8609. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8610. */
  8611. noPreventDefault: boolean;
  8612. /**
  8613. * Defined the camera the input manager belongs to.
  8614. */
  8615. camera: TCamera;
  8616. /**
  8617. * Update the current camera state depending on the inputs that have been used this frame.
  8618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8619. */
  8620. checkInputs: () => void;
  8621. /**
  8622. * Instantiate a new Camera Input Manager.
  8623. * @param camera Defines the camera the input manager blongs to
  8624. */
  8625. constructor(camera: TCamera);
  8626. /**
  8627. * Add an input method to a camera
  8628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8629. * @param input camera input method
  8630. */
  8631. add(input: ICameraInput<TCamera>): void;
  8632. /**
  8633. * Remove a specific input method from a camera
  8634. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8635. * @param inputToRemove camera input method
  8636. */
  8637. remove(inputToRemove: ICameraInput<TCamera>): void;
  8638. /**
  8639. * Remove a specific input type from a camera
  8640. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8641. * @param inputType the type of the input to remove
  8642. */
  8643. removeByType(inputType: string): void;
  8644. private _addCheckInputs;
  8645. /**
  8646. * Attach the input controls to the currently attached dom element to listen the events from.
  8647. * @param input Defines the input to attach
  8648. */
  8649. attachInput(input: ICameraInput<TCamera>): void;
  8650. /**
  8651. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8652. * @param element Defines the dom element to collect the events from
  8653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8654. */
  8655. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8656. /**
  8657. * Detach the current manager inputs controls from a specific dom element.
  8658. * @param element Defines the dom element to collect the events from
  8659. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8660. */
  8661. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8662. /**
  8663. * Rebuild the dynamic inputCheck function from the current list of
  8664. * defined inputs in the manager.
  8665. */
  8666. rebuildInputCheck(): void;
  8667. /**
  8668. * Remove all attached input methods from a camera
  8669. */
  8670. clear(): void;
  8671. /**
  8672. * Serialize the current input manager attached to a camera.
  8673. * This ensures than once parsed,
  8674. * the input associated to the camera will be identical to the current ones
  8675. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8676. */
  8677. serialize(serializedCamera: any): void;
  8678. /**
  8679. * Parses an input manager serialized JSON to restore the previous list of inputs
  8680. * and states associated to a camera.
  8681. * @param parsedCamera Defines the JSON to parse
  8682. */
  8683. parse(parsedCamera: any): void;
  8684. }
  8685. }
  8686. declare module "babylonjs/Events/keyboardEvents" {
  8687. /**
  8688. * Gather the list of keyboard event types as constants.
  8689. */
  8690. export class KeyboardEventTypes {
  8691. /**
  8692. * The keydown event is fired when a key becomes active (pressed).
  8693. */
  8694. static readonly KEYDOWN: number;
  8695. /**
  8696. * The keyup event is fired when a key has been released.
  8697. */
  8698. static readonly KEYUP: number;
  8699. }
  8700. /**
  8701. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8702. */
  8703. export class KeyboardInfo {
  8704. /**
  8705. * Defines the type of event (KeyboardEventTypes)
  8706. */
  8707. type: number;
  8708. /**
  8709. * Defines the related dom event
  8710. */
  8711. event: KeyboardEvent;
  8712. /**
  8713. * Instantiates a new keyboard info.
  8714. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8715. * @param type Defines the type of event (KeyboardEventTypes)
  8716. * @param event Defines the related dom event
  8717. */
  8718. constructor(
  8719. /**
  8720. * Defines the type of event (KeyboardEventTypes)
  8721. */
  8722. type: number,
  8723. /**
  8724. * Defines the related dom event
  8725. */
  8726. event: KeyboardEvent);
  8727. }
  8728. /**
  8729. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8730. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8731. */
  8732. export class KeyboardInfoPre extends KeyboardInfo {
  8733. /**
  8734. * Defines the type of event (KeyboardEventTypes)
  8735. */
  8736. type: number;
  8737. /**
  8738. * Defines the related dom event
  8739. */
  8740. event: KeyboardEvent;
  8741. /**
  8742. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8743. */
  8744. skipOnPointerObservable: boolean;
  8745. /**
  8746. * Instantiates a new keyboard pre info.
  8747. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8748. * @param type Defines the type of event (KeyboardEventTypes)
  8749. * @param event Defines the related dom event
  8750. */
  8751. constructor(
  8752. /**
  8753. * Defines the type of event (KeyboardEventTypes)
  8754. */
  8755. type: number,
  8756. /**
  8757. * Defines the related dom event
  8758. */
  8759. event: KeyboardEvent);
  8760. }
  8761. }
  8762. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8763. import { Nullable } from "babylonjs/types";
  8764. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8765. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8766. /**
  8767. * Manage the keyboard inputs to control the movement of a free camera.
  8768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8769. */
  8770. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8771. /**
  8772. * Defines the camera the input is attached to.
  8773. */
  8774. camera: FreeCamera;
  8775. /**
  8776. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8777. */
  8778. keysUp: number[];
  8779. /**
  8780. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8781. */
  8782. keysDown: number[];
  8783. /**
  8784. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8785. */
  8786. keysLeft: number[];
  8787. /**
  8788. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8789. */
  8790. keysRight: number[];
  8791. private _keys;
  8792. private _onCanvasBlurObserver;
  8793. private _onKeyboardObserver;
  8794. private _engine;
  8795. private _scene;
  8796. /**
  8797. * Attach the input controls to a specific dom element to get the input from.
  8798. * @param element Defines the element the controls should be listened from
  8799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8800. */
  8801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8802. /**
  8803. * Detach the current controls from the specified dom element.
  8804. * @param element Defines the element to stop listening the inputs from
  8805. */
  8806. detachControl(element: Nullable<HTMLElement>): void;
  8807. /**
  8808. * Update the current camera state depending on the inputs that have been used this frame.
  8809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8810. */
  8811. checkInputs(): void;
  8812. /**
  8813. * Gets the class name of the current intput.
  8814. * @returns the class name
  8815. */
  8816. getClassName(): string;
  8817. /** @hidden */
  8818. _onLostFocus(): void;
  8819. /**
  8820. * Get the friendly name associated with the input class.
  8821. * @returns the input friendly name
  8822. */
  8823. getSimpleName(): string;
  8824. }
  8825. }
  8826. declare module "babylonjs/Lights/shadowLight" {
  8827. import { Camera } from "babylonjs/Cameras/camera";
  8828. import { Scene } from "babylonjs/scene";
  8829. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8831. import { Light } from "babylonjs/Lights/light";
  8832. /**
  8833. * Interface describing all the common properties and methods a shadow light needs to implement.
  8834. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8835. * as well as binding the different shadow properties to the effects.
  8836. */
  8837. export interface IShadowLight extends Light {
  8838. /**
  8839. * The light id in the scene (used in scene.findLighById for instance)
  8840. */
  8841. id: string;
  8842. /**
  8843. * The position the shdow will be casted from.
  8844. */
  8845. position: Vector3;
  8846. /**
  8847. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8848. */
  8849. direction: Vector3;
  8850. /**
  8851. * The transformed position. Position of the light in world space taking parenting in account.
  8852. */
  8853. transformedPosition: Vector3;
  8854. /**
  8855. * The transformed direction. Direction of the light in world space taking parenting in account.
  8856. */
  8857. transformedDirection: Vector3;
  8858. /**
  8859. * The friendly name of the light in the scene.
  8860. */
  8861. name: string;
  8862. /**
  8863. * Defines the shadow projection clipping minimum z value.
  8864. */
  8865. shadowMinZ: number;
  8866. /**
  8867. * Defines the shadow projection clipping maximum z value.
  8868. */
  8869. shadowMaxZ: number;
  8870. /**
  8871. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8872. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8873. */
  8874. computeTransformedInformation(): boolean;
  8875. /**
  8876. * Gets the scene the light belongs to.
  8877. * @returns The scene
  8878. */
  8879. getScene(): Scene;
  8880. /**
  8881. * Callback defining a custom Projection Matrix Builder.
  8882. * This can be used to override the default projection matrix computation.
  8883. */
  8884. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8885. /**
  8886. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8887. * @param matrix The materix to updated with the projection information
  8888. * @param viewMatrix The transform matrix of the light
  8889. * @param renderList The list of mesh to render in the map
  8890. * @returns The current light
  8891. */
  8892. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8893. /**
  8894. * Gets the current depth scale used in ESM.
  8895. * @returns The scale
  8896. */
  8897. getDepthScale(): number;
  8898. /**
  8899. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8900. * @returns true if a cube texture needs to be use
  8901. */
  8902. needCube(): boolean;
  8903. /**
  8904. * Detects if the projection matrix requires to be recomputed this frame.
  8905. * @returns true if it requires to be recomputed otherwise, false.
  8906. */
  8907. needProjectionMatrixCompute(): boolean;
  8908. /**
  8909. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8910. */
  8911. forceProjectionMatrixCompute(): void;
  8912. /**
  8913. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8914. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8915. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8916. */
  8917. getShadowDirection(faceIndex?: number): Vector3;
  8918. /**
  8919. * Gets the minZ used for shadow according to both the scene and the light.
  8920. * @param activeCamera The camera we are returning the min for
  8921. * @returns the depth min z
  8922. */
  8923. getDepthMinZ(activeCamera: Camera): number;
  8924. /**
  8925. * Gets the maxZ used for shadow according to both the scene and the light.
  8926. * @param activeCamera The camera we are returning the max for
  8927. * @returns the depth max z
  8928. */
  8929. getDepthMaxZ(activeCamera: Camera): number;
  8930. }
  8931. /**
  8932. * Base implementation IShadowLight
  8933. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8934. */
  8935. export abstract class ShadowLight extends Light implements IShadowLight {
  8936. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8937. protected _position: Vector3;
  8938. protected _setPosition(value: Vector3): void;
  8939. /**
  8940. * Sets the position the shadow will be casted from. Also use as the light position for both
  8941. * point and spot lights.
  8942. */
  8943. /**
  8944. * Sets the position the shadow will be casted from. Also use as the light position for both
  8945. * point and spot lights.
  8946. */
  8947. position: Vector3;
  8948. protected _direction: Vector3;
  8949. protected _setDirection(value: Vector3): void;
  8950. /**
  8951. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8952. * Also use as the light direction on spot and directional lights.
  8953. */
  8954. /**
  8955. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8956. * Also use as the light direction on spot and directional lights.
  8957. */
  8958. direction: Vector3;
  8959. private _shadowMinZ;
  8960. /**
  8961. * Gets the shadow projection clipping minimum z value.
  8962. */
  8963. /**
  8964. * Sets the shadow projection clipping minimum z value.
  8965. */
  8966. shadowMinZ: number;
  8967. private _shadowMaxZ;
  8968. /**
  8969. * Sets the shadow projection clipping maximum z value.
  8970. */
  8971. /**
  8972. * Gets the shadow projection clipping maximum z value.
  8973. */
  8974. shadowMaxZ: number;
  8975. /**
  8976. * Callback defining a custom Projection Matrix Builder.
  8977. * This can be used to override the default projection matrix computation.
  8978. */
  8979. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8980. /**
  8981. * The transformed position. Position of the light in world space taking parenting in account.
  8982. */
  8983. transformedPosition: Vector3;
  8984. /**
  8985. * The transformed direction. Direction of the light in world space taking parenting in account.
  8986. */
  8987. transformedDirection: Vector3;
  8988. private _needProjectionMatrixCompute;
  8989. /**
  8990. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8991. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8992. */
  8993. computeTransformedInformation(): boolean;
  8994. /**
  8995. * Return the depth scale used for the shadow map.
  8996. * @returns the depth scale.
  8997. */
  8998. getDepthScale(): number;
  8999. /**
  9000. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9001. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9002. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9003. */
  9004. getShadowDirection(faceIndex?: number): Vector3;
  9005. /**
  9006. * Returns the ShadowLight absolute position in the World.
  9007. * @returns the position vector in world space
  9008. */
  9009. getAbsolutePosition(): Vector3;
  9010. /**
  9011. * Sets the ShadowLight direction toward the passed target.
  9012. * @param target The point to target in local space
  9013. * @returns the updated ShadowLight direction
  9014. */
  9015. setDirectionToTarget(target: Vector3): Vector3;
  9016. /**
  9017. * Returns the light rotation in euler definition.
  9018. * @returns the x y z rotation in local space.
  9019. */
  9020. getRotation(): Vector3;
  9021. /**
  9022. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9023. * @returns true if a cube texture needs to be use
  9024. */
  9025. needCube(): boolean;
  9026. /**
  9027. * Detects if the projection matrix requires to be recomputed this frame.
  9028. * @returns true if it requires to be recomputed otherwise, false.
  9029. */
  9030. needProjectionMatrixCompute(): boolean;
  9031. /**
  9032. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9033. */
  9034. forceProjectionMatrixCompute(): void;
  9035. /** @hidden */
  9036. _initCache(): void;
  9037. /** @hidden */
  9038. _isSynchronized(): boolean;
  9039. /**
  9040. * Computes the world matrix of the node
  9041. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9042. * @returns the world matrix
  9043. */
  9044. computeWorldMatrix(force?: boolean): Matrix;
  9045. /**
  9046. * Gets the minZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the min for
  9048. * @returns the depth min z
  9049. */
  9050. getDepthMinZ(activeCamera: Camera): number;
  9051. /**
  9052. * Gets the maxZ used for shadow according to both the scene and the light.
  9053. * @param activeCamera The camera we are returning the max for
  9054. * @returns the depth max z
  9055. */
  9056. getDepthMaxZ(activeCamera: Camera): number;
  9057. /**
  9058. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9059. * @param matrix The materix to updated with the projection information
  9060. * @param viewMatrix The transform matrix of the light
  9061. * @param renderList The list of mesh to render in the map
  9062. * @returns The current light
  9063. */
  9064. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9065. }
  9066. }
  9067. declare module "babylonjs/Materials/materialHelper" {
  9068. import { Nullable } from "babylonjs/types";
  9069. import { Scene } from "babylonjs/scene";
  9070. import { Engine } from "babylonjs/Engines/engine";
  9071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9072. import { Light } from "babylonjs/Lights/light";
  9073. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9074. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9076. /**
  9077. * "Static Class" containing the most commonly used helper while dealing with material for
  9078. * rendering purpose.
  9079. *
  9080. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9081. *
  9082. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9083. */
  9084. export class MaterialHelper {
  9085. /**
  9086. * Bind the current view position to an effect.
  9087. * @param effect The effect to be bound
  9088. * @param scene The scene the eyes position is used from
  9089. */
  9090. static BindEyePosition(effect: Effect, scene: Scene): void;
  9091. /**
  9092. * Helps preparing the defines values about the UVs in used in the effect.
  9093. * UVs are shared as much as we can accross channels in the shaders.
  9094. * @param texture The texture we are preparing the UVs for
  9095. * @param defines The defines to update
  9096. * @param key The channel key "diffuse", "specular"... used in the shader
  9097. */
  9098. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9099. /**
  9100. * Binds a texture matrix value to its corrsponding uniform
  9101. * @param texture The texture to bind the matrix for
  9102. * @param uniformBuffer The uniform buffer receivin the data
  9103. * @param key The channel key "diffuse", "specular"... used in the shader
  9104. */
  9105. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9106. /**
  9107. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9108. * @param mesh defines the current mesh
  9109. * @param scene defines the current scene
  9110. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9111. * @param pointsCloud defines if point cloud rendering has to be turned on
  9112. * @param fogEnabled defines if fog has to be turned on
  9113. * @param alphaTest defines if alpha testing has to be turned on
  9114. * @param defines defines the current list of defines
  9115. */
  9116. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9117. /**
  9118. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9119. * @param scene defines the current scene
  9120. * @param engine defines the current engine
  9121. * @param defines specifies the list of active defines
  9122. * @param useInstances defines if instances have to be turned on
  9123. * @param useClipPlane defines if clip plane have to be turned on
  9124. */
  9125. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9126. /**
  9127. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9128. * @param mesh The mesh containing the geometry data we will draw
  9129. * @param defines The defines to update
  9130. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9131. * @param useBones Precise whether bones should be used or not (override mesh info)
  9132. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9133. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9134. * @returns false if defines are considered not dirty and have not been checked
  9135. */
  9136. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9137. /**
  9138. * Prepares the defines related to the light information passed in parameter
  9139. * @param scene The scene we are intending to draw
  9140. * @param mesh The mesh the effect is compiling for
  9141. * @param defines The defines to update
  9142. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9143. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9144. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9145. * @returns true if normals will be required for the rest of the effect
  9146. */
  9147. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9148. /**
  9149. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9150. * that won t be acctive due to defines being turned off.
  9151. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9152. * @param samplersList The samplers list
  9153. * @param defines The defines helping in the list generation
  9154. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9155. */
  9156. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9157. /**
  9158. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9159. * @param defines The defines to update while falling back
  9160. * @param fallbacks The authorized effect fallbacks
  9161. * @param maxSimultaneousLights The maximum number of lights allowed
  9162. * @param rank the current rank of the Effect
  9163. * @returns The newly affected rank
  9164. */
  9165. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9166. /**
  9167. * Prepares the list of attributes required for morph targets according to the effect defines.
  9168. * @param attribs The current list of supported attribs
  9169. * @param mesh The mesh to prepare the morph targets attributes for
  9170. * @param defines The current Defines of the effect
  9171. */
  9172. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9173. /**
  9174. * Prepares the list of attributes required for bones according to the effect defines.
  9175. * @param attribs The current list of supported attribs
  9176. * @param mesh The mesh to prepare the bones attributes for
  9177. * @param defines The current Defines of the effect
  9178. * @param fallbacks The current efffect fallback strategy
  9179. */
  9180. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9181. /**
  9182. * Prepares the list of attributes required for instances according to the effect defines.
  9183. * @param attribs The current list of supported attribs
  9184. * @param defines The current Defines of the effect
  9185. */
  9186. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9187. /**
  9188. * Binds the light shadow information to the effect for the given mesh.
  9189. * @param light The light containing the generator
  9190. * @param scene The scene the lights belongs to
  9191. * @param mesh The mesh we are binding the information to render
  9192. * @param lightIndex The light index in the effect used to render the mesh
  9193. * @param effect The effect we are binding the data to
  9194. */
  9195. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9196. /**
  9197. * Binds the light information to the effect.
  9198. * @param light The light containing the generator
  9199. * @param effect The effect we are binding the data to
  9200. * @param lightIndex The light index in the effect used to render
  9201. */
  9202. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9203. /**
  9204. * Binds the lights information from the scene to the effect for the given mesh.
  9205. * @param scene The scene the lights belongs to
  9206. * @param mesh The mesh we are binding the information to render
  9207. * @param effect The effect we are binding the data to
  9208. * @param defines The generated defines for the effect
  9209. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9210. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9211. */
  9212. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9213. private static _tempFogColor;
  9214. /**
  9215. * Binds the fog information from the scene to the effect for the given mesh.
  9216. * @param scene The scene the lights belongs to
  9217. * @param mesh The mesh we are binding the information to render
  9218. * @param effect The effect we are binding the data to
  9219. * @param linearSpace Defines if the fog effect is applied in linear space
  9220. */
  9221. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9222. /**
  9223. * Binds the bones information from the mesh to the effect.
  9224. * @param mesh The mesh we are binding the information to render
  9225. * @param effect The effect we are binding the data to
  9226. */
  9227. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9228. /**
  9229. * Binds the morph targets information from the mesh to the effect.
  9230. * @param abstractMesh The mesh we are binding the information to render
  9231. * @param effect The effect we are binding the data to
  9232. */
  9233. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9234. /**
  9235. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9236. * @param defines The generated defines used in the effect
  9237. * @param effect The effect we are binding the data to
  9238. * @param scene The scene we are willing to render with logarithmic scale for
  9239. */
  9240. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9241. /**
  9242. * Binds the clip plane information from the scene to the effect.
  9243. * @param scene The scene the clip plane information are extracted from
  9244. * @param effect The effect we are binding the data to
  9245. */
  9246. static BindClipPlane(effect: Effect, scene: Scene): void;
  9247. }
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9250. /** @hidden */
  9251. export var kernelBlurVaryingDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9257. /** @hidden */
  9258. export var kernelBlurFragment: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9264. /** @hidden */
  9265. export var kernelBlurFragment2: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9271. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9272. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9273. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9274. /** @hidden */
  9275. export var kernelBlurPixelShader: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9281. /** @hidden */
  9282. export var kernelBlurVertex: {
  9283. name: string;
  9284. shader: string;
  9285. };
  9286. }
  9287. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9288. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9289. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9290. /** @hidden */
  9291. export var kernelBlurVertexShader: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9297. import { Vector2 } from "babylonjs/Maths/math";
  9298. import { Nullable } from "babylonjs/types";
  9299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9300. import { Camera } from "babylonjs/Cameras/camera";
  9301. import { Effect } from "babylonjs/Materials/effect";
  9302. import { Engine } from "babylonjs/Engines/engine";
  9303. import "babylonjs/Shaders/kernelBlur.fragment";
  9304. import "babylonjs/Shaders/kernelBlur.vertex";
  9305. /**
  9306. * The Blur Post Process which blurs an image based on a kernel and direction.
  9307. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9308. */
  9309. export class BlurPostProcess extends PostProcess {
  9310. /** The direction in which to blur the image. */
  9311. direction: Vector2;
  9312. private blockCompilation;
  9313. protected _kernel: number;
  9314. protected _idealKernel: number;
  9315. protected _packedFloat: boolean;
  9316. private _staticDefines;
  9317. /**
  9318. * Sets the length in pixels of the blur sample region
  9319. */
  9320. /**
  9321. * Gets the length in pixels of the blur sample region
  9322. */
  9323. kernel: number;
  9324. /**
  9325. * Sets wether or not the blur needs to unpack/repack floats
  9326. */
  9327. /**
  9328. * Gets wether or not the blur is unpacking/repacking floats
  9329. */
  9330. packedFloat: boolean;
  9331. /**
  9332. * Creates a new instance BlurPostProcess
  9333. * @param name The name of the effect.
  9334. * @param direction The direction in which to blur the image.
  9335. * @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.
  9336. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9337. * @param camera The camera to apply the render pass to.
  9338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9339. * @param engine The engine which the post process will be applied. (default: current engine)
  9340. * @param reusable If the post process can be reused on the same frame. (default: false)
  9341. * @param textureType Type of textures used when performing the post process. (default: 0)
  9342. * @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)
  9343. */
  9344. constructor(name: string,
  9345. /** The direction in which to blur the image. */
  9346. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9347. /**
  9348. * Updates the effect with the current post process compile time values and recompiles the shader.
  9349. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9350. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9351. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9352. * @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
  9353. * @param onCompiled Called when the shader has been compiled.
  9354. * @param onError Called if there is an error when compiling a shader.
  9355. */
  9356. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9357. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9358. /**
  9359. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9360. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9361. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9362. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9363. * The gaps between physical kernels are compensated for in the weighting of the samples
  9364. * @param idealKernel Ideal blur kernel.
  9365. * @return Nearest best kernel.
  9366. */
  9367. protected _nearestBestKernel(idealKernel: number): number;
  9368. /**
  9369. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9370. * @param x The point on the Gaussian distribution to sample.
  9371. * @return the value of the Gaussian function at x.
  9372. */
  9373. protected _gaussianWeight(x: number): number;
  9374. /**
  9375. * Generates a string that can be used as a floating point number in GLSL.
  9376. * @param x Value to print.
  9377. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9378. * @return GLSL float string.
  9379. */
  9380. protected _glslFloat(x: number, decimalFigures?: number): string;
  9381. }
  9382. }
  9383. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9384. /** @hidden */
  9385. export var shadowMapPixelShader: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9391. /** @hidden */
  9392. export var bonesDeclaration: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9398. /** @hidden */
  9399. export var morphTargetsVertexGlobalDeclaration: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9405. /** @hidden */
  9406. export var morphTargetsVertexDeclaration: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9412. /** @hidden */
  9413. export var instancesDeclaration: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9419. /** @hidden */
  9420. export var helperFunctions: {
  9421. name: string;
  9422. shader: string;
  9423. };
  9424. }
  9425. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9426. /** @hidden */
  9427. export var morphTargetsVertex: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9433. /** @hidden */
  9434. export var instancesVertex: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9440. /** @hidden */
  9441. export var bonesVertex: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9447. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9448. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9449. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9450. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9451. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9452. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9453. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9454. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9455. /** @hidden */
  9456. export var shadowMapVertexShader: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9462. /** @hidden */
  9463. export var depthBoxBlurPixelShader: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9469. import { Nullable } from "babylonjs/types";
  9470. import { Scene } from "babylonjs/scene";
  9471. import { Matrix } from "babylonjs/Maths/math";
  9472. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9474. import { Mesh } from "babylonjs/Meshes/mesh";
  9475. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9476. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9477. import { Effect } from "babylonjs/Materials/effect";
  9478. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9479. import "babylonjs/Shaders/shadowMap.fragment";
  9480. import "babylonjs/Shaders/shadowMap.vertex";
  9481. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9482. import { Observable } from "babylonjs/Misc/observable";
  9483. /**
  9484. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9485. */
  9486. export interface ICustomShaderOptions {
  9487. /**
  9488. * Gets or sets the custom shader name to use
  9489. */
  9490. shaderName: string;
  9491. /**
  9492. * The list of attribute names used in the shader
  9493. */
  9494. attributes?: string[];
  9495. /**
  9496. * The list of unifrom names used in the shader
  9497. */
  9498. uniforms?: string[];
  9499. /**
  9500. * The list of sampler names used in the shader
  9501. */
  9502. samplers?: string[];
  9503. /**
  9504. * The list of defines used in the shader
  9505. */
  9506. defines?: string[];
  9507. }
  9508. /**
  9509. * Interface to implement to create a shadow generator compatible with BJS.
  9510. */
  9511. export interface IShadowGenerator {
  9512. /**
  9513. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9514. * @returns The render target texture if present otherwise, null
  9515. */
  9516. getShadowMap(): Nullable<RenderTargetTexture>;
  9517. /**
  9518. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9519. * @returns The render target texture if the shadow map is present otherwise, null
  9520. */
  9521. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9522. /**
  9523. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9524. * @param subMesh The submesh we want to render in the shadow map
  9525. * @param useInstances Defines wether will draw in the map using instances
  9526. * @returns true if ready otherwise, false
  9527. */
  9528. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9529. /**
  9530. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9531. * @param defines Defines of the material we want to update
  9532. * @param lightIndex Index of the light in the enabled light list of the material
  9533. */
  9534. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9535. /**
  9536. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9537. * defined in the generator but impacting the effect).
  9538. * It implies the unifroms available on the materials are the standard BJS ones.
  9539. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9540. * @param effect The effect we are binfing the information for
  9541. */
  9542. bindShadowLight(lightIndex: string, effect: Effect): void;
  9543. /**
  9544. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9545. * (eq to shadow prjection matrix * light transform matrix)
  9546. * @returns The transform matrix used to create the shadow map
  9547. */
  9548. getTransformMatrix(): Matrix;
  9549. /**
  9550. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9551. * Cube and 2D textures for instance.
  9552. */
  9553. recreateShadowMap(): void;
  9554. /**
  9555. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9556. * @param onCompiled Callback triggered at the and of the effects compilation
  9557. * @param options Sets of optional options forcing the compilation with different modes
  9558. */
  9559. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9560. useInstances: boolean;
  9561. }>): void;
  9562. /**
  9563. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9564. * @param options Sets of optional options forcing the compilation with different modes
  9565. * @returns A promise that resolves when the compilation completes
  9566. */
  9567. forceCompilationAsync(options?: Partial<{
  9568. useInstances: boolean;
  9569. }>): Promise<void>;
  9570. /**
  9571. * Serializes the shadow generator setup to a json object.
  9572. * @returns The serialized JSON object
  9573. */
  9574. serialize(): any;
  9575. /**
  9576. * Disposes the Shadow map and related Textures and effects.
  9577. */
  9578. dispose(): void;
  9579. }
  9580. /**
  9581. * Default implementation IShadowGenerator.
  9582. * This is the main object responsible of generating shadows in the framework.
  9583. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9584. */
  9585. export class ShadowGenerator implements IShadowGenerator {
  9586. /**
  9587. * Shadow generator mode None: no filtering applied.
  9588. */
  9589. static readonly FILTER_NONE: number;
  9590. /**
  9591. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9592. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9593. */
  9594. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9595. /**
  9596. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9597. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9598. */
  9599. static readonly FILTER_POISSONSAMPLING: number;
  9600. /**
  9601. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9602. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9603. */
  9604. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9605. /**
  9606. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9607. * edge artifacts on steep falloff.
  9608. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9609. */
  9610. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9611. /**
  9612. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9613. * edge artifacts on steep falloff.
  9614. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9615. */
  9616. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9617. /**
  9618. * Shadow generator mode PCF: Percentage Closer Filtering
  9619. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9620. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9621. */
  9622. static readonly FILTER_PCF: number;
  9623. /**
  9624. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9625. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9626. * Contact Hardening
  9627. */
  9628. static readonly FILTER_PCSS: number;
  9629. /**
  9630. * Reserved for PCF and PCSS
  9631. * Highest Quality.
  9632. *
  9633. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9634. *
  9635. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9636. */
  9637. static readonly QUALITY_HIGH: number;
  9638. /**
  9639. * Reserved for PCF and PCSS
  9640. * Good tradeoff for quality/perf cross devices
  9641. *
  9642. * Execute PCF on a 3*3 kernel.
  9643. *
  9644. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9645. */
  9646. static readonly QUALITY_MEDIUM: number;
  9647. /**
  9648. * Reserved for PCF and PCSS
  9649. * The lowest quality but the fastest.
  9650. *
  9651. * Execute PCF on a 1*1 kernel.
  9652. *
  9653. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9654. */
  9655. static readonly QUALITY_LOW: number;
  9656. /** Gets or sets the custom shader name to use */
  9657. customShaderOptions: ICustomShaderOptions;
  9658. /**
  9659. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9660. */
  9661. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9662. /**
  9663. * Observable triggered before a mesh is rendered in the shadow map.
  9664. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9665. */
  9666. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9667. private _bias;
  9668. /**
  9669. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9670. */
  9671. /**
  9672. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9673. */
  9674. bias: number;
  9675. private _normalBias;
  9676. /**
  9677. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9678. */
  9679. /**
  9680. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9681. */
  9682. normalBias: number;
  9683. private _blurBoxOffset;
  9684. /**
  9685. * Gets the blur box offset: offset applied during the blur pass.
  9686. * Only useful if useKernelBlur = false
  9687. */
  9688. /**
  9689. * Sets the blur box offset: offset applied during the blur pass.
  9690. * Only useful if useKernelBlur = false
  9691. */
  9692. blurBoxOffset: number;
  9693. private _blurScale;
  9694. /**
  9695. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9696. * 2 means half of the size.
  9697. */
  9698. /**
  9699. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9700. * 2 means half of the size.
  9701. */
  9702. blurScale: number;
  9703. private _blurKernel;
  9704. /**
  9705. * Gets the blur kernel: kernel size of the blur pass.
  9706. * Only useful if useKernelBlur = true
  9707. */
  9708. /**
  9709. * Sets the blur kernel: kernel size of the blur pass.
  9710. * Only useful if useKernelBlur = true
  9711. */
  9712. blurKernel: number;
  9713. private _useKernelBlur;
  9714. /**
  9715. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9716. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9717. */
  9718. /**
  9719. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9720. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9721. */
  9722. useKernelBlur: boolean;
  9723. private _depthScale;
  9724. /**
  9725. * Gets the depth scale used in ESM mode.
  9726. */
  9727. /**
  9728. * Sets the depth scale used in ESM mode.
  9729. * This can override the scale stored on the light.
  9730. */
  9731. depthScale: number;
  9732. private _filter;
  9733. /**
  9734. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9735. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9736. */
  9737. /**
  9738. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9739. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9740. */
  9741. filter: number;
  9742. /**
  9743. * Gets if the current filter is set to Poisson Sampling.
  9744. */
  9745. /**
  9746. * Sets the current filter to Poisson Sampling.
  9747. */
  9748. usePoissonSampling: boolean;
  9749. /**
  9750. * Gets if the current filter is set to ESM.
  9751. */
  9752. /**
  9753. * Sets the current filter is to ESM.
  9754. */
  9755. useExponentialShadowMap: boolean;
  9756. /**
  9757. * Gets if the current filter is set to filtered ESM.
  9758. */
  9759. /**
  9760. * Gets if the current filter is set to filtered ESM.
  9761. */
  9762. useBlurExponentialShadowMap: boolean;
  9763. /**
  9764. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9765. * exponential to prevent steep falloff artifacts).
  9766. */
  9767. /**
  9768. * Sets the current filter to "close ESM" (using the inverse of the
  9769. * exponential to prevent steep falloff artifacts).
  9770. */
  9771. useCloseExponentialShadowMap: boolean;
  9772. /**
  9773. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9774. * exponential to prevent steep falloff artifacts).
  9775. */
  9776. /**
  9777. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9778. * exponential to prevent steep falloff artifacts).
  9779. */
  9780. useBlurCloseExponentialShadowMap: boolean;
  9781. /**
  9782. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9783. */
  9784. /**
  9785. * Sets the current filter to "PCF" (percentage closer filtering).
  9786. */
  9787. usePercentageCloserFiltering: boolean;
  9788. private _filteringQuality;
  9789. /**
  9790. * Gets the PCF or PCSS Quality.
  9791. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9792. */
  9793. /**
  9794. * Sets the PCF or PCSS Quality.
  9795. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9796. */
  9797. filteringQuality: number;
  9798. /**
  9799. * Gets if the current filter is set to "PCSS" (contact hardening).
  9800. */
  9801. /**
  9802. * Sets the current filter to "PCSS" (contact hardening).
  9803. */
  9804. useContactHardeningShadow: boolean;
  9805. private _contactHardeningLightSizeUVRatio;
  9806. /**
  9807. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9808. * Using a ratio helps keeping shape stability independently of the map size.
  9809. *
  9810. * It does not account for the light projection as it was having too much
  9811. * instability during the light setup or during light position changes.
  9812. *
  9813. * Only valid if useContactHardeningShadow is true.
  9814. */
  9815. /**
  9816. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9817. * Using a ratio helps keeping shape stability independently of the map size.
  9818. *
  9819. * It does not account for the light projection as it was having too much
  9820. * instability during the light setup or during light position changes.
  9821. *
  9822. * Only valid if useContactHardeningShadow is true.
  9823. */
  9824. contactHardeningLightSizeUVRatio: number;
  9825. private _darkness;
  9826. /**
  9827. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9828. * 0 means strongest and 1 would means no shadow.
  9829. * @returns the darkness.
  9830. */
  9831. getDarkness(): number;
  9832. /**
  9833. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9834. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9835. * @returns the shadow generator allowing fluent coding.
  9836. */
  9837. setDarkness(darkness: number): ShadowGenerator;
  9838. private _transparencyShadow;
  9839. /**
  9840. * Sets the ability to have transparent shadow (boolean).
  9841. * @param transparent True if transparent else False
  9842. * @returns the shadow generator allowing fluent coding
  9843. */
  9844. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9845. private _shadowMap;
  9846. private _shadowMap2;
  9847. /**
  9848. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9849. * @returns The render target texture if present otherwise, null
  9850. */
  9851. getShadowMap(): Nullable<RenderTargetTexture>;
  9852. /**
  9853. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9854. * @returns The render target texture if the shadow map is present otherwise, null
  9855. */
  9856. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9857. /**
  9858. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9859. * @param mesh Mesh to add
  9860. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9861. * @returns the Shadow Generator itself
  9862. */
  9863. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9864. /**
  9865. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9866. * @param mesh Mesh to remove
  9867. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9868. * @returns the Shadow Generator itself
  9869. */
  9870. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9871. /**
  9872. * Controls the extent to which the shadows fade out at the edge of the frustum
  9873. * Used only by directionals and spots
  9874. */
  9875. frustumEdgeFalloff: number;
  9876. private _light;
  9877. /**
  9878. * Returns the associated light object.
  9879. * @returns the light generating the shadow
  9880. */
  9881. getLight(): IShadowLight;
  9882. /**
  9883. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9884. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9885. * It might on the other hand introduce peter panning.
  9886. */
  9887. forceBackFacesOnly: boolean;
  9888. private _scene;
  9889. private _lightDirection;
  9890. private _effect;
  9891. private _viewMatrix;
  9892. private _projectionMatrix;
  9893. private _transformMatrix;
  9894. private _cachedPosition;
  9895. private _cachedDirection;
  9896. private _cachedDefines;
  9897. private _currentRenderID;
  9898. private _boxBlurPostprocess;
  9899. private _kernelBlurXPostprocess;
  9900. private _kernelBlurYPostprocess;
  9901. private _blurPostProcesses;
  9902. private _mapSize;
  9903. private _currentFaceIndex;
  9904. private _currentFaceIndexCache;
  9905. private _textureType;
  9906. private _defaultTextureMatrix;
  9907. /** @hidden */
  9908. static _SceneComponentInitialization: (scene: Scene) => void;
  9909. /**
  9910. * Creates a ShadowGenerator object.
  9911. * A ShadowGenerator is the required tool to use the shadows.
  9912. * Each light casting shadows needs to use its own ShadowGenerator.
  9913. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9914. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9915. * @param light The light object generating the shadows.
  9916. * @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.
  9917. */
  9918. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9919. private _initializeGenerator;
  9920. private _initializeShadowMap;
  9921. private _initializeBlurRTTAndPostProcesses;
  9922. private _renderForShadowMap;
  9923. private _renderSubMeshForShadowMap;
  9924. private _applyFilterValues;
  9925. /**
  9926. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9927. * @param onCompiled Callback triggered at the and of the effects compilation
  9928. * @param options Sets of optional options forcing the compilation with different modes
  9929. */
  9930. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9931. useInstances: boolean;
  9932. }>): void;
  9933. /**
  9934. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9935. * @param options Sets of optional options forcing the compilation with different modes
  9936. * @returns A promise that resolves when the compilation completes
  9937. */
  9938. forceCompilationAsync(options?: Partial<{
  9939. useInstances: boolean;
  9940. }>): Promise<void>;
  9941. /**
  9942. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9943. * @param subMesh The submesh we want to render in the shadow map
  9944. * @param useInstances Defines wether will draw in the map using instances
  9945. * @returns true if ready otherwise, false
  9946. */
  9947. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9948. /**
  9949. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9950. * @param defines Defines of the material we want to update
  9951. * @param lightIndex Index of the light in the enabled light list of the material
  9952. */
  9953. prepareDefines(defines: any, lightIndex: number): void;
  9954. /**
  9955. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9956. * defined in the generator but impacting the effect).
  9957. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9958. * @param effect The effect we are binfing the information for
  9959. */
  9960. bindShadowLight(lightIndex: string, effect: Effect): void;
  9961. /**
  9962. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9963. * (eq to shadow prjection matrix * light transform matrix)
  9964. * @returns The transform matrix used to create the shadow map
  9965. */
  9966. getTransformMatrix(): Matrix;
  9967. /**
  9968. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9969. * Cube and 2D textures for instance.
  9970. */
  9971. recreateShadowMap(): void;
  9972. private _disposeBlurPostProcesses;
  9973. private _disposeRTTandPostProcesses;
  9974. /**
  9975. * Disposes the ShadowGenerator.
  9976. * Returns nothing.
  9977. */
  9978. dispose(): void;
  9979. /**
  9980. * Serializes the shadow generator setup to a json object.
  9981. * @returns The serialized JSON object
  9982. */
  9983. serialize(): any;
  9984. /**
  9985. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9986. * @param parsedShadowGenerator The JSON object to parse
  9987. * @param scene The scene to create the shadow map for
  9988. * @returns The parsed shadow generator
  9989. */
  9990. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9991. }
  9992. }
  9993. declare module "babylonjs/Lights/light" {
  9994. import { Nullable } from "babylonjs/types";
  9995. import { Scene } from "babylonjs/scene";
  9996. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9997. import { Node } from "babylonjs/node";
  9998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9999. import { Effect } from "babylonjs/Materials/effect";
  10000. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10001. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10002. /**
  10003. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10004. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10005. * 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.
  10006. */
  10007. export abstract class Light extends Node {
  10008. /**
  10009. * Falloff Default: light is falling off following the material specification:
  10010. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10011. */
  10012. static readonly FALLOFF_DEFAULT: number;
  10013. /**
  10014. * Falloff Physical: light is falling off following the inverse squared distance law.
  10015. */
  10016. static readonly FALLOFF_PHYSICAL: number;
  10017. /**
  10018. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10019. * to enhance interoperability with other engines.
  10020. */
  10021. static readonly FALLOFF_GLTF: number;
  10022. /**
  10023. * Falloff Standard: light is falling off like in the standard material
  10024. * to enhance interoperability with other materials.
  10025. */
  10026. static readonly FALLOFF_STANDARD: number;
  10027. /**
  10028. * If every light affecting the material is in this lightmapMode,
  10029. * material.lightmapTexture adds or multiplies
  10030. * (depends on material.useLightmapAsShadowmap)
  10031. * after every other light calculations.
  10032. */
  10033. static readonly LIGHTMAP_DEFAULT: number;
  10034. /**
  10035. * material.lightmapTexture as only diffuse lighting from this light
  10036. * adds only specular lighting from this light
  10037. * adds dynamic shadows
  10038. */
  10039. static readonly LIGHTMAP_SPECULAR: number;
  10040. /**
  10041. * material.lightmapTexture as only lighting
  10042. * no light calculation from this light
  10043. * only adds dynamic shadows from this light
  10044. */
  10045. static readonly LIGHTMAP_SHADOWSONLY: number;
  10046. /**
  10047. * Each light type uses the default quantity according to its type:
  10048. * point/spot lights use luminous intensity
  10049. * directional lights use illuminance
  10050. */
  10051. static readonly INTENSITYMODE_AUTOMATIC: number;
  10052. /**
  10053. * lumen (lm)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10056. /**
  10057. * candela (lm/sr)
  10058. */
  10059. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10060. /**
  10061. * lux (lm/m^2)
  10062. */
  10063. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10064. /**
  10065. * nit (cd/m^2)
  10066. */
  10067. static readonly INTENSITYMODE_LUMINANCE: number;
  10068. /**
  10069. * Light type const id of the point light.
  10070. */
  10071. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10072. /**
  10073. * Light type const id of the directional light.
  10074. */
  10075. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10076. /**
  10077. * Light type const id of the spot light.
  10078. */
  10079. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10080. /**
  10081. * Light type const id of the hemispheric light.
  10082. */
  10083. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10084. /**
  10085. * Diffuse gives the basic color to an object.
  10086. */
  10087. diffuse: Color3;
  10088. /**
  10089. * Specular produces a highlight color on an object.
  10090. * Note: This is note affecting PBR materials.
  10091. */
  10092. specular: Color3;
  10093. /**
  10094. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10095. * falling off base on range or angle.
  10096. * This can be set to any values in Light.FALLOFF_x.
  10097. *
  10098. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10099. * other types of materials.
  10100. */
  10101. falloffType: number;
  10102. /**
  10103. * Strength of the light.
  10104. * Note: By default it is define in the framework own unit.
  10105. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10106. */
  10107. intensity: number;
  10108. private _range;
  10109. protected _inverseSquaredRange: number;
  10110. /**
  10111. * Defines how far from the source the light is impacting in scene units.
  10112. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10113. */
  10114. /**
  10115. * Defines how far from the source the light is impacting in scene units.
  10116. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10117. */
  10118. range: number;
  10119. /**
  10120. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10121. * of light.
  10122. */
  10123. private _photometricScale;
  10124. private _intensityMode;
  10125. /**
  10126. * Gets the photometric scale used to interpret the intensity.
  10127. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10128. */
  10129. /**
  10130. * Sets the photometric scale used to interpret the intensity.
  10131. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10132. */
  10133. intensityMode: number;
  10134. private _radius;
  10135. /**
  10136. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10137. */
  10138. /**
  10139. * sets the light radius used by PBR Materials to simulate soft area lights.
  10140. */
  10141. radius: number;
  10142. private _renderPriority;
  10143. /**
  10144. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10145. * exceeding the number allowed of the materials.
  10146. */
  10147. renderPriority: number;
  10148. private _shadowEnabled;
  10149. /**
  10150. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10151. * the current shadow generator.
  10152. */
  10153. /**
  10154. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10155. * the current shadow generator.
  10156. */
  10157. shadowEnabled: boolean;
  10158. private _includedOnlyMeshes;
  10159. /**
  10160. * Gets the only meshes impacted by this light.
  10161. */
  10162. /**
  10163. * Sets the only meshes impacted by this light.
  10164. */
  10165. includedOnlyMeshes: AbstractMesh[];
  10166. private _excludedMeshes;
  10167. /**
  10168. * Gets the meshes not impacted by this light.
  10169. */
  10170. /**
  10171. * Sets the meshes not impacted by this light.
  10172. */
  10173. excludedMeshes: AbstractMesh[];
  10174. private _excludeWithLayerMask;
  10175. /**
  10176. * Gets the layer id use to find what meshes are not impacted by the light.
  10177. * Inactive if 0
  10178. */
  10179. /**
  10180. * Sets the layer id use to find what meshes are not impacted by the light.
  10181. * Inactive if 0
  10182. */
  10183. excludeWithLayerMask: number;
  10184. private _includeOnlyWithLayerMask;
  10185. /**
  10186. * Gets the layer id use to find what meshes are impacted by the light.
  10187. * Inactive if 0
  10188. */
  10189. /**
  10190. * Sets the layer id use to find what meshes are impacted by the light.
  10191. * Inactive if 0
  10192. */
  10193. includeOnlyWithLayerMask: number;
  10194. private _lightmapMode;
  10195. /**
  10196. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10197. */
  10198. /**
  10199. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10200. */
  10201. lightmapMode: number;
  10202. /**
  10203. * Shadow generator associted to the light.
  10204. * @hidden Internal use only.
  10205. */
  10206. _shadowGenerator: Nullable<IShadowGenerator>;
  10207. /**
  10208. * @hidden Internal use only.
  10209. */
  10210. _excludedMeshesIds: string[];
  10211. /**
  10212. * @hidden Internal use only.
  10213. */
  10214. _includedOnlyMeshesIds: string[];
  10215. /**
  10216. * The current light unifom buffer.
  10217. * @hidden Internal use only.
  10218. */
  10219. _uniformBuffer: UniformBuffer;
  10220. /**
  10221. * Creates a Light object in the scene.
  10222. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10223. * @param name The firendly name of the light
  10224. * @param scene The scene the light belongs too
  10225. */
  10226. constructor(name: string, scene: Scene);
  10227. protected abstract _buildUniformLayout(): void;
  10228. /**
  10229. * Sets the passed Effect "effect" with the Light information.
  10230. * @param effect The effect to update
  10231. * @param lightIndex The index of the light in the effect to update
  10232. * @returns The light
  10233. */
  10234. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10235. /**
  10236. * Returns the string "Light".
  10237. * @returns the class name
  10238. */
  10239. getClassName(): string;
  10240. /** @hidden */
  10241. readonly _isLight: boolean;
  10242. /**
  10243. * Converts the light information to a readable string for debug purpose.
  10244. * @param fullDetails Supports for multiple levels of logging within scene loading
  10245. * @returns the human readable light info
  10246. */
  10247. toString(fullDetails?: boolean): string;
  10248. /** @hidden */
  10249. protected _syncParentEnabledState(): void;
  10250. /**
  10251. * Set the enabled state of this node.
  10252. * @param value - the new enabled state
  10253. */
  10254. setEnabled(value: boolean): void;
  10255. /**
  10256. * Returns the Light associated shadow generator if any.
  10257. * @return the associated shadow generator.
  10258. */
  10259. getShadowGenerator(): Nullable<IShadowGenerator>;
  10260. /**
  10261. * Returns a Vector3, the absolute light position in the World.
  10262. * @returns the world space position of the light
  10263. */
  10264. getAbsolutePosition(): Vector3;
  10265. /**
  10266. * Specifies if the light will affect the passed mesh.
  10267. * @param mesh The mesh to test against the light
  10268. * @return true the mesh is affected otherwise, false.
  10269. */
  10270. canAffectMesh(mesh: AbstractMesh): boolean;
  10271. /**
  10272. * Sort function to order lights for rendering.
  10273. * @param a First Light object to compare to second.
  10274. * @param b Second Light object to compare first.
  10275. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10276. */
  10277. static CompareLightsPriority(a: Light, b: Light): number;
  10278. /**
  10279. * Releases resources associated with this node.
  10280. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10281. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10282. */
  10283. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10284. /**
  10285. * Returns the light type ID (integer).
  10286. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10287. */
  10288. getTypeID(): number;
  10289. /**
  10290. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10291. * @returns the scaled intensity in intensity mode unit
  10292. */
  10293. getScaledIntensity(): number;
  10294. /**
  10295. * Returns a new Light object, named "name", from the current one.
  10296. * @param name The name of the cloned light
  10297. * @returns the new created light
  10298. */
  10299. clone(name: string): Nullable<Light>;
  10300. /**
  10301. * Serializes the current light into a Serialization object.
  10302. * @returns the serialized object.
  10303. */
  10304. serialize(): any;
  10305. /**
  10306. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10307. * This new light is named "name" and added to the passed scene.
  10308. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10309. * @param name The friendly name of the light
  10310. * @param scene The scene the new light will belong to
  10311. * @returns the constructor function
  10312. */
  10313. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10314. /**
  10315. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10316. * @param parsedLight The JSON representation of the light
  10317. * @param scene The scene to create the parsed light in
  10318. * @returns the created light after parsing
  10319. */
  10320. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10321. private _hookArrayForExcluded;
  10322. private _hookArrayForIncludedOnly;
  10323. private _resyncMeshes;
  10324. /**
  10325. * Forces the meshes to update their light related information in their rendering used effects
  10326. * @hidden Internal Use Only
  10327. */
  10328. _markMeshesAsLightDirty(): void;
  10329. /**
  10330. * Recomputes the cached photometric scale if needed.
  10331. */
  10332. private _computePhotometricScale;
  10333. /**
  10334. * Returns the Photometric Scale according to the light type and intensity mode.
  10335. */
  10336. private _getPhotometricScale;
  10337. /**
  10338. * Reorder the light in the scene according to their defined priority.
  10339. * @hidden Internal Use Only
  10340. */
  10341. _reorderLightsInScene(): void;
  10342. /**
  10343. * Prepares the list of defines specific to the light type.
  10344. * @param defines the list of defines
  10345. * @param lightIndex defines the index of the light for the effect
  10346. */
  10347. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10348. }
  10349. }
  10350. declare module "babylonjs/Actions/action" {
  10351. import { Observable } from "babylonjs/Misc/observable";
  10352. import { Condition } from "babylonjs/Actions/condition";
  10353. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10354. import { ActionManager } from "babylonjs/Actions/actionManager";
  10355. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10356. /**
  10357. * Interface used to define Action
  10358. */
  10359. export interface IAction {
  10360. /**
  10361. * Trigger for the action
  10362. */
  10363. trigger: number;
  10364. /** Options of the trigger */
  10365. triggerOptions: any;
  10366. /**
  10367. * Gets the trigger parameters
  10368. * @returns the trigger parameters
  10369. */
  10370. getTriggerParameter(): any;
  10371. /**
  10372. * Internal only - executes current action event
  10373. * @hidden
  10374. */
  10375. _executeCurrent(evt?: ActionEvent): void;
  10376. /**
  10377. * Serialize placeholder for child classes
  10378. * @param parent of child
  10379. * @returns the serialized object
  10380. */
  10381. serialize(parent: any): any;
  10382. /**
  10383. * Internal only
  10384. * @hidden
  10385. */
  10386. _prepare(): void;
  10387. /**
  10388. * Internal only - manager for action
  10389. * @hidden
  10390. */
  10391. _actionManager: AbstractActionManager;
  10392. }
  10393. /**
  10394. * The action to be carried out following a trigger
  10395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10396. */
  10397. export class Action implements IAction {
  10398. /** the trigger, with or without parameters, for the action */
  10399. triggerOptions: any;
  10400. /**
  10401. * Trigger for the action
  10402. */
  10403. trigger: number;
  10404. /**
  10405. * Internal only - manager for action
  10406. * @hidden
  10407. */
  10408. _actionManager: ActionManager;
  10409. private _nextActiveAction;
  10410. private _child;
  10411. private _condition?;
  10412. private _triggerParameter;
  10413. /**
  10414. * An event triggered prior to action being executed.
  10415. */
  10416. onBeforeExecuteObservable: Observable<Action>;
  10417. /**
  10418. * Creates a new Action
  10419. * @param triggerOptions the trigger, with or without parameters, for the action
  10420. * @param condition an optional determinant of action
  10421. */
  10422. constructor(
  10423. /** the trigger, with or without parameters, for the action */
  10424. triggerOptions: any, condition?: Condition);
  10425. /**
  10426. * Internal only
  10427. * @hidden
  10428. */
  10429. _prepare(): void;
  10430. /**
  10431. * Gets the trigger parameters
  10432. * @returns the trigger parameters
  10433. */
  10434. getTriggerParameter(): any;
  10435. /**
  10436. * Internal only - executes current action event
  10437. * @hidden
  10438. */
  10439. _executeCurrent(evt?: ActionEvent): void;
  10440. /**
  10441. * Execute placeholder for child classes
  10442. * @param evt optional action event
  10443. */
  10444. execute(evt?: ActionEvent): void;
  10445. /**
  10446. * Skips to next active action
  10447. */
  10448. skipToNextActiveAction(): void;
  10449. /**
  10450. * Adds action to chain of actions, may be a DoNothingAction
  10451. * @param action defines the next action to execute
  10452. * @returns The action passed in
  10453. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10454. */
  10455. then(action: Action): Action;
  10456. /**
  10457. * Internal only
  10458. * @hidden
  10459. */
  10460. _getProperty(propertyPath: string): string;
  10461. /**
  10462. * Internal only
  10463. * @hidden
  10464. */
  10465. _getEffectiveTarget(target: any, propertyPath: string): any;
  10466. /**
  10467. * Serialize placeholder for child classes
  10468. * @param parent of child
  10469. * @returns the serialized object
  10470. */
  10471. serialize(parent: any): any;
  10472. /**
  10473. * Internal only called by serialize
  10474. * @hidden
  10475. */
  10476. protected _serialize(serializedAction: any, parent?: any): any;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. static _SerializeValueAsString: (value: any) => string;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10487. name: string;
  10488. targetType: string;
  10489. value: string;
  10490. };
  10491. }
  10492. }
  10493. declare module "babylonjs/Actions/condition" {
  10494. import { ActionManager } from "babylonjs/Actions/actionManager";
  10495. /**
  10496. * A Condition applied to an Action
  10497. */
  10498. export class Condition {
  10499. /**
  10500. * Internal only - manager for action
  10501. * @hidden
  10502. */
  10503. _actionManager: ActionManager;
  10504. /**
  10505. * Internal only
  10506. * @hidden
  10507. */
  10508. _evaluationId: number;
  10509. /**
  10510. * Internal only
  10511. * @hidden
  10512. */
  10513. _currentResult: boolean;
  10514. /**
  10515. * Creates a new Condition
  10516. * @param actionManager the manager of the action the condition is applied to
  10517. */
  10518. constructor(actionManager: ActionManager);
  10519. /**
  10520. * Check if the current condition is valid
  10521. * @returns a boolean
  10522. */
  10523. isValid(): boolean;
  10524. /**
  10525. * Internal only
  10526. * @hidden
  10527. */
  10528. _getProperty(propertyPath: string): string;
  10529. /**
  10530. * Internal only
  10531. * @hidden
  10532. */
  10533. _getEffectiveTarget(target: any, propertyPath: string): any;
  10534. /**
  10535. * Serialize placeholder for child classes
  10536. * @returns the serialized object
  10537. */
  10538. serialize(): any;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. protected _serialize(serializedCondition: any): any;
  10544. }
  10545. /**
  10546. * Defines specific conditional operators as extensions of Condition
  10547. */
  10548. export class ValueCondition extends Condition {
  10549. /** path to specify the property of the target the conditional operator uses */
  10550. propertyPath: string;
  10551. /** the value compared by the conditional operator against the current value of the property */
  10552. value: any;
  10553. /** the conditional operator, default ValueCondition.IsEqual */
  10554. operator: number;
  10555. /**
  10556. * Internal only
  10557. * @hidden
  10558. */
  10559. private static _IsEqual;
  10560. /**
  10561. * Internal only
  10562. * @hidden
  10563. */
  10564. private static _IsDifferent;
  10565. /**
  10566. * Internal only
  10567. * @hidden
  10568. */
  10569. private static _IsGreater;
  10570. /**
  10571. * Internal only
  10572. * @hidden
  10573. */
  10574. private static _IsLesser;
  10575. /**
  10576. * returns the number for IsEqual
  10577. */
  10578. static readonly IsEqual: number;
  10579. /**
  10580. * Returns the number for IsDifferent
  10581. */
  10582. static readonly IsDifferent: number;
  10583. /**
  10584. * Returns the number for IsGreater
  10585. */
  10586. static readonly IsGreater: number;
  10587. /**
  10588. * Returns the number for IsLesser
  10589. */
  10590. static readonly IsLesser: number;
  10591. /**
  10592. * Internal only The action manager for the condition
  10593. * @hidden
  10594. */
  10595. _actionManager: ActionManager;
  10596. /**
  10597. * Internal only
  10598. * @hidden
  10599. */
  10600. private _target;
  10601. /**
  10602. * Internal only
  10603. * @hidden
  10604. */
  10605. private _effectiveTarget;
  10606. /**
  10607. * Internal only
  10608. * @hidden
  10609. */
  10610. private _property;
  10611. /**
  10612. * Creates a new ValueCondition
  10613. * @param actionManager manager for the action the condition applies to
  10614. * @param target for the action
  10615. * @param propertyPath path to specify the property of the target the conditional operator uses
  10616. * @param value the value compared by the conditional operator against the current value of the property
  10617. * @param operator the conditional operator, default ValueCondition.IsEqual
  10618. */
  10619. constructor(actionManager: ActionManager, target: any,
  10620. /** path to specify the property of the target the conditional operator uses */
  10621. propertyPath: string,
  10622. /** the value compared by the conditional operator against the current value of the property */
  10623. value: any,
  10624. /** the conditional operator, default ValueCondition.IsEqual */
  10625. operator?: number);
  10626. /**
  10627. * Compares the given value with the property value for the specified conditional operator
  10628. * @returns the result of the comparison
  10629. */
  10630. isValid(): boolean;
  10631. /**
  10632. * Serialize the ValueCondition into a JSON compatible object
  10633. * @returns serialization object
  10634. */
  10635. serialize(): any;
  10636. /**
  10637. * Gets the name of the conditional operator for the ValueCondition
  10638. * @param operator the conditional operator
  10639. * @returns the name
  10640. */
  10641. static GetOperatorName(operator: number): string;
  10642. }
  10643. /**
  10644. * Defines a predicate condition as an extension of Condition
  10645. */
  10646. export class PredicateCondition extends Condition {
  10647. /** defines the predicate function used to validate the condition */
  10648. predicate: () => boolean;
  10649. /**
  10650. * Internal only - manager for action
  10651. * @hidden
  10652. */
  10653. _actionManager: ActionManager;
  10654. /**
  10655. * Creates a new PredicateCondition
  10656. * @param actionManager manager for the action the condition applies to
  10657. * @param predicate defines the predicate function used to validate the condition
  10658. */
  10659. constructor(actionManager: ActionManager,
  10660. /** defines the predicate function used to validate the condition */
  10661. predicate: () => boolean);
  10662. /**
  10663. * @returns the validity of the predicate condition
  10664. */
  10665. isValid(): boolean;
  10666. }
  10667. /**
  10668. * Defines a state condition as an extension of Condition
  10669. */
  10670. export class StateCondition extends Condition {
  10671. /** Value to compare with target state */
  10672. value: string;
  10673. /**
  10674. * Internal only - manager for action
  10675. * @hidden
  10676. */
  10677. _actionManager: ActionManager;
  10678. /**
  10679. * Internal only
  10680. * @hidden
  10681. */
  10682. private _target;
  10683. /**
  10684. * Creates a new StateCondition
  10685. * @param actionManager manager for the action the condition applies to
  10686. * @param target of the condition
  10687. * @param value to compare with target state
  10688. */
  10689. constructor(actionManager: ActionManager, target: any,
  10690. /** Value to compare with target state */
  10691. value: string);
  10692. /**
  10693. * Gets a boolean indicating if the current condition is met
  10694. * @returns the validity of the state
  10695. */
  10696. isValid(): boolean;
  10697. /**
  10698. * Serialize the StateCondition into a JSON compatible object
  10699. * @returns serialization object
  10700. */
  10701. serialize(): any;
  10702. }
  10703. }
  10704. declare module "babylonjs/Actions/directActions" {
  10705. import { Action } from "babylonjs/Actions/action";
  10706. import { Condition } from "babylonjs/Actions/condition";
  10707. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10708. /**
  10709. * This defines an action responsible to toggle a boolean once triggered.
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10711. */
  10712. export class SwitchBooleanAction extends Action {
  10713. /**
  10714. * The path to the boolean property in the target object
  10715. */
  10716. propertyPath: string;
  10717. private _target;
  10718. private _effectiveTarget;
  10719. private _property;
  10720. /**
  10721. * Instantiate the action
  10722. * @param triggerOptions defines the trigger options
  10723. * @param target defines the object containing the boolean
  10724. * @param propertyPath defines the path to the boolean property in the target object
  10725. * @param condition defines the trigger related conditions
  10726. */
  10727. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10728. /** @hidden */
  10729. _prepare(): void;
  10730. /**
  10731. * Execute the action toggle the boolean value.
  10732. */
  10733. execute(): void;
  10734. /**
  10735. * Serializes the actions and its related information.
  10736. * @param parent defines the object to serialize in
  10737. * @returns the serialized object
  10738. */
  10739. serialize(parent: any): any;
  10740. }
  10741. /**
  10742. * This defines an action responsible to set a the state field of the target
  10743. * to a desired value once triggered.
  10744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10745. */
  10746. export class SetStateAction extends Action {
  10747. /**
  10748. * The value to store in the state field.
  10749. */
  10750. value: string;
  10751. private _target;
  10752. /**
  10753. * Instantiate the action
  10754. * @param triggerOptions defines the trigger options
  10755. * @param target defines the object containing the state property
  10756. * @param value defines the value to store in the state field
  10757. * @param condition defines the trigger related conditions
  10758. */
  10759. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10760. /**
  10761. * Execute the action and store the value on the target state property.
  10762. */
  10763. execute(): void;
  10764. /**
  10765. * Serializes the actions and its related information.
  10766. * @param parent defines the object to serialize in
  10767. * @returns the serialized object
  10768. */
  10769. serialize(parent: any): any;
  10770. }
  10771. /**
  10772. * This defines an action responsible to set a property of the target
  10773. * to a desired value once triggered.
  10774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10775. */
  10776. export class SetValueAction extends Action {
  10777. /**
  10778. * The path of the property to set in the target.
  10779. */
  10780. propertyPath: string;
  10781. /**
  10782. * The value to set in the property
  10783. */
  10784. value: any;
  10785. private _target;
  10786. private _effectiveTarget;
  10787. private _property;
  10788. /**
  10789. * Instantiate the action
  10790. * @param triggerOptions defines the trigger options
  10791. * @param target defines the object containing the property
  10792. * @param propertyPath defines the path of the property to set in the target
  10793. * @param value defines the value to set in the property
  10794. * @param condition defines the trigger related conditions
  10795. */
  10796. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10797. /** @hidden */
  10798. _prepare(): void;
  10799. /**
  10800. * Execute the action and set the targetted property to the desired value.
  10801. */
  10802. execute(): void;
  10803. /**
  10804. * Serializes the actions and its related information.
  10805. * @param parent defines the object to serialize in
  10806. * @returns the serialized object
  10807. */
  10808. serialize(parent: any): any;
  10809. }
  10810. /**
  10811. * This defines an action responsible to increment the target value
  10812. * to a desired value once triggered.
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10814. */
  10815. export class IncrementValueAction extends Action {
  10816. /**
  10817. * The path of the property to increment in the target.
  10818. */
  10819. propertyPath: string;
  10820. /**
  10821. * The value we should increment the property by.
  10822. */
  10823. value: any;
  10824. private _target;
  10825. private _effectiveTarget;
  10826. private _property;
  10827. /**
  10828. * Instantiate the action
  10829. * @param triggerOptions defines the trigger options
  10830. * @param target defines the object containing the property
  10831. * @param propertyPath defines the path of the property to increment in the target
  10832. * @param value defines the value value we should increment the property by
  10833. * @param condition defines the trigger related conditions
  10834. */
  10835. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10836. /** @hidden */
  10837. _prepare(): void;
  10838. /**
  10839. * Execute the action and increment the target of the value amount.
  10840. */
  10841. execute(): void;
  10842. /**
  10843. * Serializes the actions and its related information.
  10844. * @param parent defines the object to serialize in
  10845. * @returns the serialized object
  10846. */
  10847. serialize(parent: any): any;
  10848. }
  10849. /**
  10850. * This defines an action responsible to start an animation once triggered.
  10851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10852. */
  10853. export class PlayAnimationAction extends Action {
  10854. /**
  10855. * Where the animation should start (animation frame)
  10856. */
  10857. from: number;
  10858. /**
  10859. * Where the animation should stop (animation frame)
  10860. */
  10861. to: number;
  10862. /**
  10863. * Define if the animation should loop or stop after the first play.
  10864. */
  10865. loop?: boolean;
  10866. private _target;
  10867. /**
  10868. * Instantiate the action
  10869. * @param triggerOptions defines the trigger options
  10870. * @param target defines the target animation or animation name
  10871. * @param from defines from where the animation should start (animation frame)
  10872. * @param end defines where the animation should stop (animation frame)
  10873. * @param loop defines if the animation should loop or stop after the first play
  10874. * @param condition defines the trigger related conditions
  10875. */
  10876. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10877. /** @hidden */
  10878. _prepare(): void;
  10879. /**
  10880. * Execute the action and play the animation.
  10881. */
  10882. execute(): void;
  10883. /**
  10884. * Serializes the actions and its related information.
  10885. * @param parent defines the object to serialize in
  10886. * @returns the serialized object
  10887. */
  10888. serialize(parent: any): any;
  10889. }
  10890. /**
  10891. * This defines an action responsible to stop an animation once triggered.
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10893. */
  10894. export class StopAnimationAction extends Action {
  10895. private _target;
  10896. /**
  10897. * Instantiate the action
  10898. * @param triggerOptions defines the trigger options
  10899. * @param target defines the target animation or animation name
  10900. * @param condition defines the trigger related conditions
  10901. */
  10902. constructor(triggerOptions: any, target: any, condition?: Condition);
  10903. /** @hidden */
  10904. _prepare(): void;
  10905. /**
  10906. * Execute the action and stop the animation.
  10907. */
  10908. execute(): void;
  10909. /**
  10910. * Serializes the actions and its related information.
  10911. * @param parent defines the object to serialize in
  10912. * @returns the serialized object
  10913. */
  10914. serialize(parent: any): any;
  10915. }
  10916. /**
  10917. * This defines an action responsible that does nothing once triggered.
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10919. */
  10920. export class DoNothingAction extends Action {
  10921. /**
  10922. * Instantiate the action
  10923. * @param triggerOptions defines the trigger options
  10924. * @param condition defines the trigger related conditions
  10925. */
  10926. constructor(triggerOptions?: any, condition?: Condition);
  10927. /**
  10928. * Execute the action and do nothing.
  10929. */
  10930. execute(): void;
  10931. /**
  10932. * Serializes the actions and its related information.
  10933. * @param parent defines the object to serialize in
  10934. * @returns the serialized object
  10935. */
  10936. serialize(parent: any): any;
  10937. }
  10938. /**
  10939. * This defines an action responsible to trigger several actions once triggered.
  10940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10941. */
  10942. export class CombineAction extends Action {
  10943. /**
  10944. * The list of aggregated animations to run.
  10945. */
  10946. children: Action[];
  10947. /**
  10948. * Instantiate the action
  10949. * @param triggerOptions defines the trigger options
  10950. * @param children defines the list of aggregated animations to run
  10951. * @param condition defines the trigger related conditions
  10952. */
  10953. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10954. /** @hidden */
  10955. _prepare(): void;
  10956. /**
  10957. * Execute the action and executes all the aggregated actions.
  10958. */
  10959. execute(evt: ActionEvent): void;
  10960. /**
  10961. * Serializes the actions and its related information.
  10962. * @param parent defines the object to serialize in
  10963. * @returns the serialized object
  10964. */
  10965. serialize(parent: any): any;
  10966. }
  10967. /**
  10968. * This defines an action responsible to run code (external event) once triggered.
  10969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10970. */
  10971. export class ExecuteCodeAction extends Action {
  10972. /**
  10973. * The callback function to run.
  10974. */
  10975. func: (evt: ActionEvent) => void;
  10976. /**
  10977. * Instantiate the action
  10978. * @param triggerOptions defines the trigger options
  10979. * @param func defines the callback function to run
  10980. * @param condition defines the trigger related conditions
  10981. */
  10982. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10983. /**
  10984. * Execute the action and run the attached code.
  10985. */
  10986. execute(evt: ActionEvent): void;
  10987. }
  10988. /**
  10989. * This defines an action responsible to set the parent property of the target once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class SetParentAction extends Action {
  10993. private _parent;
  10994. private _target;
  10995. /**
  10996. * Instantiate the action
  10997. * @param triggerOptions defines the trigger options
  10998. * @param target defines the target containing the parent property
  10999. * @param parent defines from where the animation should start (animation frame)
  11000. * @param condition defines the trigger related conditions
  11001. */
  11002. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11003. /** @hidden */
  11004. _prepare(): void;
  11005. /**
  11006. * Execute the action and set the parent property.
  11007. */
  11008. execute(): void;
  11009. /**
  11010. * Serializes the actions and its related information.
  11011. * @param parent defines the object to serialize in
  11012. * @returns the serialized object
  11013. */
  11014. serialize(parent: any): any;
  11015. }
  11016. }
  11017. declare module "babylonjs/Actions/actionManager" {
  11018. import { Nullable } from "babylonjs/types";
  11019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11020. import { Scene } from "babylonjs/scene";
  11021. import { IAction } from "babylonjs/Actions/action";
  11022. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11023. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11024. /**
  11025. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11026. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11028. */
  11029. export class ActionManager extends AbstractActionManager {
  11030. /**
  11031. * Nothing
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11033. */
  11034. static readonly NothingTrigger: number;
  11035. /**
  11036. * On pick
  11037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11038. */
  11039. static readonly OnPickTrigger: number;
  11040. /**
  11041. * On left pick
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11043. */
  11044. static readonly OnLeftPickTrigger: number;
  11045. /**
  11046. * On right pick
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11048. */
  11049. static readonly OnRightPickTrigger: number;
  11050. /**
  11051. * On center pick
  11052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11053. */
  11054. static readonly OnCenterPickTrigger: number;
  11055. /**
  11056. * On pick down
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnPickDownTrigger: number;
  11060. /**
  11061. * On double pick
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnDoublePickTrigger: number;
  11065. /**
  11066. * On pick up
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnPickUpTrigger: number;
  11070. /**
  11071. * On pick out.
  11072. * This trigger will only be raised if you also declared a OnPickDown
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnPickOutTrigger: number;
  11076. /**
  11077. * On long press
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnLongPressTrigger: number;
  11081. /**
  11082. * On pointer over
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnPointerOverTrigger: number;
  11086. /**
  11087. * On pointer out
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnPointerOutTrigger: number;
  11091. /**
  11092. * On every frame
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11094. */
  11095. static readonly OnEveryFrameTrigger: number;
  11096. /**
  11097. * On intersection enter
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11099. */
  11100. static readonly OnIntersectionEnterTrigger: number;
  11101. /**
  11102. * On intersection exit
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly OnIntersectionExitTrigger: number;
  11106. /**
  11107. * On key down
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnKeyDownTrigger: number;
  11111. /**
  11112. * On key up
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnKeyUpTrigger: number;
  11116. private _scene;
  11117. /**
  11118. * Creates a new action manager
  11119. * @param scene defines the hosting scene
  11120. */
  11121. constructor(scene: Scene);
  11122. /**
  11123. * Releases all associated resources
  11124. */
  11125. dispose(): void;
  11126. /**
  11127. * Gets hosting scene
  11128. * @returns the hosting scene
  11129. */
  11130. getScene(): Scene;
  11131. /**
  11132. * Does this action manager handles actions of any of the given triggers
  11133. * @param triggers defines the triggers to be tested
  11134. * @return a boolean indicating whether one (or more) of the triggers is handled
  11135. */
  11136. hasSpecificTriggers(triggers: number[]): boolean;
  11137. /**
  11138. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11139. * speed.
  11140. * @param triggerA defines the trigger to be tested
  11141. * @param triggerB defines the trigger to be tested
  11142. * @return a boolean indicating whether one (or more) of the triggers is handled
  11143. */
  11144. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11145. /**
  11146. * Does this action manager handles actions of a given trigger
  11147. * @param trigger defines the trigger to be tested
  11148. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11149. * @return whether the trigger is handled
  11150. */
  11151. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11152. /**
  11153. * Does this action manager has pointer triggers
  11154. */
  11155. readonly hasPointerTriggers: boolean;
  11156. /**
  11157. * Does this action manager has pick triggers
  11158. */
  11159. readonly hasPickTriggers: boolean;
  11160. /**
  11161. * Registers an action to this action manager
  11162. * @param action defines the action to be registered
  11163. * @return the action amended (prepared) after registration
  11164. */
  11165. registerAction(action: IAction): Nullable<IAction>;
  11166. /**
  11167. * Unregisters an action to this action manager
  11168. * @param action defines the action to be unregistered
  11169. * @return a boolean indicating whether the action has been unregistered
  11170. */
  11171. unregisterAction(action: IAction): Boolean;
  11172. /**
  11173. * Process a specific trigger
  11174. * @param trigger defines the trigger to process
  11175. * @param evt defines the event details to be processed
  11176. */
  11177. processTrigger(trigger: number, evt?: IActionEvent): void;
  11178. /** @hidden */
  11179. _getEffectiveTarget(target: any, propertyPath: string): any;
  11180. /** @hidden */
  11181. _getProperty(propertyPath: string): string;
  11182. /**
  11183. * Serialize this manager to a JSON object
  11184. * @param name defines the property name to store this manager
  11185. * @returns a JSON representation of this manager
  11186. */
  11187. serialize(name: string): any;
  11188. /**
  11189. * Creates a new ActionManager from a JSON data
  11190. * @param parsedActions defines the JSON data to read from
  11191. * @param object defines the hosting mesh
  11192. * @param scene defines the hosting scene
  11193. */
  11194. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11195. /**
  11196. * Get a trigger name by index
  11197. * @param trigger defines the trigger index
  11198. * @returns a trigger name
  11199. */
  11200. static GetTriggerName(trigger: number): string;
  11201. }
  11202. }
  11203. declare module "babylonjs/Culling/ray" {
  11204. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11205. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11207. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11208. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11209. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11210. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11211. /**
  11212. * Class representing a ray with position and direction
  11213. */
  11214. export class Ray {
  11215. /** origin point */
  11216. origin: Vector3;
  11217. /** direction */
  11218. direction: Vector3;
  11219. /** length of the ray */
  11220. length: number;
  11221. private static readonly TmpVector3;
  11222. private _tmpRay;
  11223. /**
  11224. * Creates a new ray
  11225. * @param origin origin point
  11226. * @param direction direction
  11227. * @param length length of the ray
  11228. */
  11229. constructor(
  11230. /** origin point */
  11231. origin: Vector3,
  11232. /** direction */
  11233. direction: Vector3,
  11234. /** length of the ray */
  11235. length?: number);
  11236. /**
  11237. * Checks if the ray intersects a box
  11238. * @param minimum bound of the box
  11239. * @param maximum bound of the box
  11240. * @param intersectionTreshold extra extend to be added to the box in all direction
  11241. * @returns if the box was hit
  11242. */
  11243. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11244. /**
  11245. * Checks if the ray intersects a box
  11246. * @param box the bounding box to check
  11247. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11248. * @returns if the box was hit
  11249. */
  11250. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11251. /**
  11252. * If the ray hits a sphere
  11253. * @param sphere the bounding sphere to check
  11254. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11255. * @returns true if it hits the sphere
  11256. */
  11257. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11258. /**
  11259. * If the ray hits a triange
  11260. * @param vertex0 triangle vertex
  11261. * @param vertex1 triangle vertex
  11262. * @param vertex2 triangle vertex
  11263. * @returns intersection information if hit
  11264. */
  11265. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11266. /**
  11267. * Checks if ray intersects a plane
  11268. * @param plane the plane to check
  11269. * @returns the distance away it was hit
  11270. */
  11271. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11272. /**
  11273. * Checks if ray intersects a mesh
  11274. * @param mesh the mesh to check
  11275. * @param fastCheck if only the bounding box should checked
  11276. * @returns picking info of the intersecton
  11277. */
  11278. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11279. /**
  11280. * Checks if ray intersects a mesh
  11281. * @param meshes the meshes to check
  11282. * @param fastCheck if only the bounding box should checked
  11283. * @param results array to store result in
  11284. * @returns Array of picking infos
  11285. */
  11286. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11287. private _comparePickingInfo;
  11288. private static smallnum;
  11289. private static rayl;
  11290. /**
  11291. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11292. * @param sega the first point of the segment to test the intersection against
  11293. * @param segb the second point of the segment to test the intersection against
  11294. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11295. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11296. */
  11297. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11298. /**
  11299. * Update the ray from viewport position
  11300. * @param x position
  11301. * @param y y position
  11302. * @param viewportWidth viewport width
  11303. * @param viewportHeight viewport height
  11304. * @param world world matrix
  11305. * @param view view matrix
  11306. * @param projection projection matrix
  11307. * @returns this ray updated
  11308. */
  11309. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11310. /**
  11311. * Creates a ray with origin and direction of 0,0,0
  11312. * @returns the new ray
  11313. */
  11314. static Zero(): Ray;
  11315. /**
  11316. * Creates a new ray from screen space and viewport
  11317. * @param x position
  11318. * @param y y position
  11319. * @param viewportWidth viewport width
  11320. * @param viewportHeight viewport height
  11321. * @param world world matrix
  11322. * @param view view matrix
  11323. * @param projection projection matrix
  11324. * @returns new ray
  11325. */
  11326. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11327. /**
  11328. * 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
  11329. * transformed to the given world matrix.
  11330. * @param origin The origin point
  11331. * @param end The end point
  11332. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11333. * @returns the new ray
  11334. */
  11335. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11336. /**
  11337. * Transforms a ray by a matrix
  11338. * @param ray ray to transform
  11339. * @param matrix matrix to apply
  11340. * @returns the resulting new ray
  11341. */
  11342. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11343. /**
  11344. * Transforms a ray by a matrix
  11345. * @param ray ray to transform
  11346. * @param matrix matrix to apply
  11347. * @param result ray to store result in
  11348. */
  11349. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11350. /**
  11351. * Unproject a ray from screen space to object space
  11352. * @param sourceX defines the screen space x coordinate to use
  11353. * @param sourceY defines the screen space y coordinate to use
  11354. * @param viewportWidth defines the current width of the viewport
  11355. * @param viewportHeight defines the current height of the viewport
  11356. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11357. * @param view defines the view matrix to use
  11358. * @param projection defines the projection matrix to use
  11359. */
  11360. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11361. }
  11362. /**
  11363. * Type used to define predicate used to select faces when a mesh intersection is detected
  11364. */
  11365. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11366. module "babylonjs/scene" {
  11367. interface Scene {
  11368. /** @hidden */
  11369. _tempPickingRay: Nullable<Ray>;
  11370. /** @hidden */
  11371. _cachedRayForTransform: Ray;
  11372. /** @hidden */
  11373. _pickWithRayInverseMatrix: Matrix;
  11374. /** @hidden */
  11375. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11376. /** @hidden */
  11377. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11378. }
  11379. }
  11380. }
  11381. declare module "babylonjs/sceneComponent" {
  11382. import { Scene } from "babylonjs/scene";
  11383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11384. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11385. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11386. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11387. import { Nullable } from "babylonjs/types";
  11388. import { Camera } from "babylonjs/Cameras/camera";
  11389. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11390. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11391. import { AbstractScene } from "babylonjs/abstractScene";
  11392. /**
  11393. * Groups all the scene component constants in one place to ease maintenance.
  11394. * @hidden
  11395. */
  11396. export class SceneComponentConstants {
  11397. static readonly NAME_EFFECTLAYER: string;
  11398. static readonly NAME_LAYER: string;
  11399. static readonly NAME_LENSFLARESYSTEM: string;
  11400. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11401. static readonly NAME_PARTICLESYSTEM: string;
  11402. static readonly NAME_GAMEPAD: string;
  11403. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11404. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11405. static readonly NAME_DEPTHRENDERER: string;
  11406. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11407. static readonly NAME_SPRITE: string;
  11408. static readonly NAME_OUTLINERENDERER: string;
  11409. static readonly NAME_PROCEDURALTEXTURE: string;
  11410. static readonly NAME_SHADOWGENERATOR: string;
  11411. static readonly NAME_OCTREE: string;
  11412. static readonly NAME_PHYSICSENGINE: string;
  11413. static readonly NAME_AUDIO: string;
  11414. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11415. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11416. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11417. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11418. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11419. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11420. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11421. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11422. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11423. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11424. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11425. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11426. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11427. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11428. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11429. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11430. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11431. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11432. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11433. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11434. static readonly STEP_AFTERRENDER_AUDIO: number;
  11435. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11436. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11437. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11438. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11439. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11440. static readonly STEP_POINTERMOVE_SPRITE: number;
  11441. static readonly STEP_POINTERDOWN_SPRITE: number;
  11442. static readonly STEP_POINTERUP_SPRITE: number;
  11443. }
  11444. /**
  11445. * This represents a scene component.
  11446. *
  11447. * This is used to decouple the dependency the scene is having on the different workloads like
  11448. * layers, post processes...
  11449. */
  11450. export interface ISceneComponent {
  11451. /**
  11452. * The name of the component. Each component must have a unique name.
  11453. */
  11454. name: string;
  11455. /**
  11456. * The scene the component belongs to.
  11457. */
  11458. scene: Scene;
  11459. /**
  11460. * Register the component to one instance of a scene.
  11461. */
  11462. register(): void;
  11463. /**
  11464. * Rebuilds the elements related to this component in case of
  11465. * context lost for instance.
  11466. */
  11467. rebuild(): void;
  11468. /**
  11469. * Disposes the component and the associated ressources.
  11470. */
  11471. dispose(): void;
  11472. }
  11473. /**
  11474. * This represents a SERIALIZABLE scene component.
  11475. *
  11476. * This extends Scene Component to add Serialization methods on top.
  11477. */
  11478. export interface ISceneSerializableComponent extends ISceneComponent {
  11479. /**
  11480. * Adds all the element from the container to the scene
  11481. * @param container the container holding the elements
  11482. */
  11483. addFromContainer(container: AbstractScene): void;
  11484. /**
  11485. * Removes all the elements in the container from the scene
  11486. * @param container contains the elements to remove
  11487. */
  11488. removeFromContainer(container: AbstractScene): void;
  11489. /**
  11490. * Serializes the component data to the specified json object
  11491. * @param serializationObject The object to serialize to
  11492. */
  11493. serialize(serializationObject: any): void;
  11494. }
  11495. /**
  11496. * Strong typing of a Mesh related stage step action
  11497. */
  11498. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11499. /**
  11500. * Strong typing of a Evaluate Sub Mesh related stage step action
  11501. */
  11502. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11503. /**
  11504. * Strong typing of a Active Mesh related stage step action
  11505. */
  11506. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11507. /**
  11508. * Strong typing of a Camera related stage step action
  11509. */
  11510. export type CameraStageAction = (camera: Camera) => void;
  11511. /**
  11512. * Strong typing of a Render Target related stage step action
  11513. */
  11514. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11515. /**
  11516. * Strong typing of a RenderingGroup related stage step action
  11517. */
  11518. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11519. /**
  11520. * Strong typing of a Mesh Render related stage step action
  11521. */
  11522. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11523. /**
  11524. * Strong typing of a simple stage step action
  11525. */
  11526. export type SimpleStageAction = () => void;
  11527. /**
  11528. * Strong typing of a render target action.
  11529. */
  11530. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11531. /**
  11532. * Strong typing of a pointer move action.
  11533. */
  11534. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11535. /**
  11536. * Strong typing of a pointer up/down action.
  11537. */
  11538. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11539. /**
  11540. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11541. * @hidden
  11542. */
  11543. export class Stage<T extends Function> extends Array<{
  11544. index: number;
  11545. component: ISceneComponent;
  11546. action: T;
  11547. }> {
  11548. /**
  11549. * Hide ctor from the rest of the world.
  11550. * @param items The items to add.
  11551. */
  11552. private constructor();
  11553. /**
  11554. * Creates a new Stage.
  11555. * @returns A new instance of a Stage
  11556. */
  11557. static Create<T extends Function>(): Stage<T>;
  11558. /**
  11559. * Registers a step in an ordered way in the targeted stage.
  11560. * @param index Defines the position to register the step in
  11561. * @param component Defines the component attached to the step
  11562. * @param action Defines the action to launch during the step
  11563. */
  11564. registerStep(index: number, component: ISceneComponent, action: T): void;
  11565. /**
  11566. * Clears all the steps from the stage.
  11567. */
  11568. clear(): void;
  11569. }
  11570. }
  11571. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11572. import { Nullable } from "babylonjs/types";
  11573. import { Observable } from "babylonjs/Misc/observable";
  11574. import { Scene } from "babylonjs/scene";
  11575. import { Sprite } from "babylonjs/Sprites/sprite";
  11576. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11577. import { Ray } from "babylonjs/Culling/ray";
  11578. import { Camera } from "babylonjs/Cameras/camera";
  11579. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11580. import { ISceneComponent } from "babylonjs/sceneComponent";
  11581. module "babylonjs/scene" {
  11582. interface Scene {
  11583. /** @hidden */
  11584. _pointerOverSprite: Nullable<Sprite>;
  11585. /** @hidden */
  11586. _pickedDownSprite: Nullable<Sprite>;
  11587. /** @hidden */
  11588. _tempSpritePickingRay: Nullable<Ray>;
  11589. /**
  11590. * All of the sprite managers added to this scene
  11591. * @see http://doc.babylonjs.com/babylon101/sprites
  11592. */
  11593. spriteManagers: Array<ISpriteManager>;
  11594. /**
  11595. * An event triggered when sprites rendering is about to start
  11596. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11597. */
  11598. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11599. /**
  11600. * An event triggered when sprites rendering is done
  11601. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11602. */
  11603. onAfterSpritesRenderingObservable: Observable<Scene>;
  11604. /** @hidden */
  11605. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11606. /** Launch a ray to try to pick a sprite in the scene
  11607. * @param x position on screen
  11608. * @param y position on screen
  11609. * @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
  11610. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11611. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11612. * @returns a PickingInfo
  11613. */
  11614. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11615. /** Use the given ray to pick a sprite in the scene
  11616. * @param ray The ray (in world space) to use to pick meshes
  11617. * @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
  11618. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11619. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11620. * @returns a PickingInfo
  11621. */
  11622. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11623. /**
  11624. * Force the sprite under the pointer
  11625. * @param sprite defines the sprite to use
  11626. */
  11627. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11628. /**
  11629. * Gets the sprite under the pointer
  11630. * @returns a Sprite or null if no sprite is under the pointer
  11631. */
  11632. getPointerOverSprite(): Nullable<Sprite>;
  11633. }
  11634. }
  11635. /**
  11636. * Defines the sprite scene component responsible to manage sprites
  11637. * in a given scene.
  11638. */
  11639. export class SpriteSceneComponent implements ISceneComponent {
  11640. /**
  11641. * The component name helpfull to identify the component in the list of scene components.
  11642. */
  11643. readonly name: string;
  11644. /**
  11645. * The scene the component belongs to.
  11646. */
  11647. scene: Scene;
  11648. /** @hidden */
  11649. private _spritePredicate;
  11650. /**
  11651. * Creates a new instance of the component for the given scene
  11652. * @param scene Defines the scene to register the component in
  11653. */
  11654. constructor(scene: Scene);
  11655. /**
  11656. * Registers the component in a given scene
  11657. */
  11658. register(): void;
  11659. /**
  11660. * Rebuilds the elements related to this component in case of
  11661. * context lost for instance.
  11662. */
  11663. rebuild(): void;
  11664. /**
  11665. * Disposes the component and the associated ressources.
  11666. */
  11667. dispose(): void;
  11668. private _pickSpriteButKeepRay;
  11669. private _pointerMove;
  11670. private _pointerDown;
  11671. private _pointerUp;
  11672. }
  11673. }
  11674. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11675. /** @hidden */
  11676. export var fogFragmentDeclaration: {
  11677. name: string;
  11678. shader: string;
  11679. };
  11680. }
  11681. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11682. /** @hidden */
  11683. export var fogFragment: {
  11684. name: string;
  11685. shader: string;
  11686. };
  11687. }
  11688. declare module "babylonjs/Shaders/sprites.fragment" {
  11689. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11690. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11691. /** @hidden */
  11692. export var spritesPixelShader: {
  11693. name: string;
  11694. shader: string;
  11695. };
  11696. }
  11697. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11698. /** @hidden */
  11699. export var fogVertexDeclaration: {
  11700. name: string;
  11701. shader: string;
  11702. };
  11703. }
  11704. declare module "babylonjs/Shaders/sprites.vertex" {
  11705. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11706. /** @hidden */
  11707. export var spritesVertexShader: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Sprites/spriteManager" {
  11713. import { IDisposable, Scene } from "babylonjs/scene";
  11714. import { Nullable } from "babylonjs/types";
  11715. import { Observable } from "babylonjs/Misc/observable";
  11716. import { Sprite } from "babylonjs/Sprites/sprite";
  11717. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11718. import { Camera } from "babylonjs/Cameras/camera";
  11719. import { Texture } from "babylonjs/Materials/Textures/texture";
  11720. import "babylonjs/Shaders/sprites.fragment";
  11721. import "babylonjs/Shaders/sprites.vertex";
  11722. import { Ray } from "babylonjs/Culling/ray";
  11723. /**
  11724. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11725. */
  11726. export interface ISpriteManager extends IDisposable {
  11727. /**
  11728. * Restricts the camera to viewing objects with the same layerMask.
  11729. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11730. */
  11731. layerMask: number;
  11732. /**
  11733. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11734. */
  11735. isPickable: boolean;
  11736. /**
  11737. * Specifies the rendering group id for this mesh (0 by default)
  11738. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11739. */
  11740. renderingGroupId: number;
  11741. /**
  11742. * Defines the list of sprites managed by the manager.
  11743. */
  11744. sprites: Array<Sprite>;
  11745. /**
  11746. * Tests the intersection of a sprite with a specific ray.
  11747. * @param ray The ray we are sending to test the collision
  11748. * @param camera The camera space we are sending rays in
  11749. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11750. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11751. * @returns picking info or null.
  11752. */
  11753. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11754. /**
  11755. * Renders the list of sprites on screen.
  11756. */
  11757. render(): void;
  11758. }
  11759. /**
  11760. * Class used to manage multiple sprites on the same spritesheet
  11761. * @see http://doc.babylonjs.com/babylon101/sprites
  11762. */
  11763. export class SpriteManager implements ISpriteManager {
  11764. /** defines the manager's name */
  11765. name: string;
  11766. /** Gets the list of sprites */
  11767. sprites: Sprite[];
  11768. /** Gets or sets the rendering group id (0 by default) */
  11769. renderingGroupId: number;
  11770. /** Gets or sets camera layer mask */
  11771. layerMask: number;
  11772. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11773. fogEnabled: boolean;
  11774. /** Gets or sets a boolean indicating if the sprites are pickable */
  11775. isPickable: boolean;
  11776. /** Defines the default width of a cell in the spritesheet */
  11777. cellWidth: number;
  11778. /** Defines the default height of a cell in the spritesheet */
  11779. cellHeight: number;
  11780. /**
  11781. * An event triggered when the manager is disposed.
  11782. */
  11783. onDisposeObservable: Observable<SpriteManager>;
  11784. private _onDisposeObserver;
  11785. /**
  11786. * Callback called when the manager is disposed
  11787. */
  11788. onDispose: () => void;
  11789. private _capacity;
  11790. private _spriteTexture;
  11791. private _epsilon;
  11792. private _scene;
  11793. private _vertexData;
  11794. private _buffer;
  11795. private _vertexBuffers;
  11796. private _indexBuffer;
  11797. private _effectBase;
  11798. private _effectFog;
  11799. /**
  11800. * Gets or sets the spritesheet texture
  11801. */
  11802. texture: Texture;
  11803. /**
  11804. * Creates a new sprite manager
  11805. * @param name defines the manager's name
  11806. * @param imgUrl defines the sprite sheet url
  11807. * @param capacity defines the maximum allowed number of sprites
  11808. * @param cellSize defines the size of a sprite cell
  11809. * @param scene defines the hosting scene
  11810. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11811. * @param samplingMode defines the smapling mode to use with spritesheet
  11812. */
  11813. constructor(
  11814. /** defines the manager's name */
  11815. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11816. private _appendSpriteVertex;
  11817. /**
  11818. * Intersects the sprites with a ray
  11819. * @param ray defines the ray to intersect with
  11820. * @param camera defines the current active camera
  11821. * @param predicate defines a predicate used to select candidate sprites
  11822. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11823. * @returns null if no hit or a PickingInfo
  11824. */
  11825. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11826. /**
  11827. * Render all child sprites
  11828. */
  11829. render(): void;
  11830. /**
  11831. * Release associated resources
  11832. */
  11833. dispose(): void;
  11834. }
  11835. }
  11836. declare module "babylonjs/Sprites/sprite" {
  11837. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11838. import { Nullable } from "babylonjs/types";
  11839. import { ActionManager } from "babylonjs/Actions/actionManager";
  11840. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11841. /**
  11842. * Class used to represent a sprite
  11843. * @see http://doc.babylonjs.com/babylon101/sprites
  11844. */
  11845. export class Sprite {
  11846. /** defines the name */
  11847. name: string;
  11848. /** Gets or sets the current world position */
  11849. position: Vector3;
  11850. /** Gets or sets the main color */
  11851. color: Color4;
  11852. /** Gets or sets the width */
  11853. width: number;
  11854. /** Gets or sets the height */
  11855. height: number;
  11856. /** Gets or sets rotation angle */
  11857. angle: number;
  11858. /** Gets or sets the cell index in the sprite sheet */
  11859. cellIndex: number;
  11860. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11861. invertU: number;
  11862. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11863. invertV: number;
  11864. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11865. disposeWhenFinishedAnimating: boolean;
  11866. /** Gets the list of attached animations */
  11867. animations: Animation[];
  11868. /** Gets or sets a boolean indicating if the sprite can be picked */
  11869. isPickable: boolean;
  11870. /**
  11871. * Gets or sets the associated action manager
  11872. */
  11873. actionManager: Nullable<ActionManager>;
  11874. private _animationStarted;
  11875. private _loopAnimation;
  11876. private _fromIndex;
  11877. private _toIndex;
  11878. private _delay;
  11879. private _direction;
  11880. private _manager;
  11881. private _time;
  11882. private _onAnimationEnd;
  11883. /**
  11884. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11885. */
  11886. isVisible: boolean;
  11887. /**
  11888. * Gets or sets the sprite size
  11889. */
  11890. size: number;
  11891. /**
  11892. * Creates a new Sprite
  11893. * @param name defines the name
  11894. * @param manager defines the manager
  11895. */
  11896. constructor(
  11897. /** defines the name */
  11898. name: string, manager: ISpriteManager);
  11899. /**
  11900. * Starts an animation
  11901. * @param from defines the initial key
  11902. * @param to defines the end key
  11903. * @param loop defines if the animation must loop
  11904. * @param delay defines the start delay (in ms)
  11905. * @param onAnimationEnd defines a callback to call when animation ends
  11906. */
  11907. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11908. /** Stops current animation (if any) */
  11909. stopAnimation(): void;
  11910. /** @hidden */
  11911. _animate(deltaTime: number): void;
  11912. /** Release associated resources */
  11913. dispose(): void;
  11914. }
  11915. }
  11916. declare module "babylonjs/Collisions/pickingInfo" {
  11917. import { Nullable } from "babylonjs/types";
  11918. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11920. import { Sprite } from "babylonjs/Sprites/sprite";
  11921. import { Ray } from "babylonjs/Culling/ray";
  11922. /**
  11923. * Information about the result of picking within a scene
  11924. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11925. */
  11926. export class PickingInfo {
  11927. /** @hidden */
  11928. _pickingUnavailable: boolean;
  11929. /**
  11930. * If the pick collided with an object
  11931. */
  11932. hit: boolean;
  11933. /**
  11934. * Distance away where the pick collided
  11935. */
  11936. distance: number;
  11937. /**
  11938. * The location of pick collision
  11939. */
  11940. pickedPoint: Nullable<Vector3>;
  11941. /**
  11942. * The mesh corresponding the the pick collision
  11943. */
  11944. pickedMesh: Nullable<AbstractMesh>;
  11945. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11946. bu: number;
  11947. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11948. bv: number;
  11949. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11950. faceId: number;
  11951. /** Id of the the submesh that was picked */
  11952. subMeshId: number;
  11953. /** If a sprite was picked, this will be the sprite the pick collided with */
  11954. pickedSprite: Nullable<Sprite>;
  11955. /**
  11956. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11957. */
  11958. originMesh: Nullable<AbstractMesh>;
  11959. /**
  11960. * The ray that was used to perform the picking.
  11961. */
  11962. ray: Nullable<Ray>;
  11963. /**
  11964. * Gets the normal correspodning to the face the pick collided with
  11965. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11966. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11967. * @returns The normal correspodning to the face the pick collided with
  11968. */
  11969. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11970. /**
  11971. * Gets the texture coordinates of where the pick occured
  11972. * @returns the vector containing the coordnates of the texture
  11973. */
  11974. getTextureCoordinates(): Nullable<Vector2>;
  11975. }
  11976. }
  11977. declare module "babylonjs/Events/pointerEvents" {
  11978. import { Nullable } from "babylonjs/types";
  11979. import { Vector2 } from "babylonjs/Maths/math";
  11980. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11981. import { Ray } from "babylonjs/Culling/ray";
  11982. /**
  11983. * Gather the list of pointer event types as constants.
  11984. */
  11985. export class PointerEventTypes {
  11986. /**
  11987. * 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.
  11988. */
  11989. static readonly POINTERDOWN: number;
  11990. /**
  11991. * The pointerup event is fired when a pointer is no longer active.
  11992. */
  11993. static readonly POINTERUP: number;
  11994. /**
  11995. * The pointermove event is fired when a pointer changes coordinates.
  11996. */
  11997. static readonly POINTERMOVE: number;
  11998. /**
  11999. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12000. */
  12001. static readonly POINTERWHEEL: number;
  12002. /**
  12003. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12004. */
  12005. static readonly POINTERPICK: number;
  12006. /**
  12007. * The pointertap event is fired when a the object has been touched and released without drag.
  12008. */
  12009. static readonly POINTERTAP: number;
  12010. /**
  12011. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12012. */
  12013. static readonly POINTERDOUBLETAP: number;
  12014. }
  12015. /**
  12016. * Base class of pointer info types.
  12017. */
  12018. export class PointerInfoBase {
  12019. /**
  12020. * Defines the type of event (PointerEventTypes)
  12021. */
  12022. type: number;
  12023. /**
  12024. * Defines the related dom event
  12025. */
  12026. event: PointerEvent | MouseWheelEvent;
  12027. /**
  12028. * Instantiates the base class of pointers info.
  12029. * @param type Defines the type of event (PointerEventTypes)
  12030. * @param event Defines the related dom event
  12031. */
  12032. constructor(
  12033. /**
  12034. * Defines the type of event (PointerEventTypes)
  12035. */
  12036. type: number,
  12037. /**
  12038. * Defines the related dom event
  12039. */
  12040. event: PointerEvent | MouseWheelEvent);
  12041. }
  12042. /**
  12043. * This class is used to store pointer related info for the onPrePointerObservable event.
  12044. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12045. */
  12046. export class PointerInfoPre extends PointerInfoBase {
  12047. /**
  12048. * Ray from a pointer if availible (eg. 6dof controller)
  12049. */
  12050. ray: Nullable<Ray>;
  12051. /**
  12052. * Defines the local position of the pointer on the canvas.
  12053. */
  12054. localPosition: Vector2;
  12055. /**
  12056. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12057. */
  12058. skipOnPointerObservable: boolean;
  12059. /**
  12060. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12061. * @param type Defines the type of event (PointerEventTypes)
  12062. * @param event Defines the related dom event
  12063. * @param localX Defines the local x coordinates of the pointer when the event occured
  12064. * @param localY Defines the local y coordinates of the pointer when the event occured
  12065. */
  12066. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12067. }
  12068. /**
  12069. * This type contains all the data related to a pointer event in Babylon.js.
  12070. * 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.
  12071. */
  12072. export class PointerInfo extends PointerInfoBase {
  12073. /**
  12074. * Defines the picking info associated to the info (if any)\
  12075. */
  12076. pickInfo: Nullable<PickingInfo>;
  12077. /**
  12078. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12079. * @param type Defines the type of event (PointerEventTypes)
  12080. * @param event Defines the related dom event
  12081. * @param pickInfo Defines the picking info associated to the info (if any)\
  12082. */
  12083. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12084. /**
  12085. * Defines the picking info associated to the info (if any)\
  12086. */
  12087. pickInfo: Nullable<PickingInfo>);
  12088. }
  12089. /**
  12090. * Data relating to a touch event on the screen.
  12091. */
  12092. export interface PointerTouch {
  12093. /**
  12094. * X coordinate of touch.
  12095. */
  12096. x: number;
  12097. /**
  12098. * Y coordinate of touch.
  12099. */
  12100. y: number;
  12101. /**
  12102. * Id of touch. Unique for each finger.
  12103. */
  12104. pointerId: number;
  12105. /**
  12106. * Event type passed from DOM.
  12107. */
  12108. type: any;
  12109. }
  12110. }
  12111. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12112. import { Nullable } from "babylonjs/types";
  12113. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12114. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12115. /**
  12116. * Manage the mouse inputs to control the movement of a free camera.
  12117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12118. */
  12119. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12120. /**
  12121. * Define if touch is enabled in the mouse input
  12122. */
  12123. touchEnabled: boolean;
  12124. /**
  12125. * Defines the camera the input is attached to.
  12126. */
  12127. camera: FreeCamera;
  12128. /**
  12129. * Defines the buttons associated with the input to handle camera move.
  12130. */
  12131. buttons: number[];
  12132. /**
  12133. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12134. */
  12135. angularSensibility: number;
  12136. private _pointerInput;
  12137. private _onMouseMove;
  12138. private _observer;
  12139. private previousPosition;
  12140. /**
  12141. * Manage the mouse inputs to control the movement of a free camera.
  12142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12143. * @param touchEnabled Defines if touch is enabled or not
  12144. */
  12145. constructor(
  12146. /**
  12147. * Define if touch is enabled in the mouse input
  12148. */
  12149. touchEnabled?: boolean);
  12150. /**
  12151. * Attach the input controls to a specific dom element to get the input from.
  12152. * @param element Defines the element the controls should be listened from
  12153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12154. */
  12155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12156. /**
  12157. * Called on JS contextmenu event.
  12158. * Override this method to provide functionality.
  12159. */
  12160. protected onContextMenu(evt: PointerEvent): void;
  12161. /**
  12162. * Detach the current controls from the specified dom element.
  12163. * @param element Defines the element to stop listening the inputs from
  12164. */
  12165. detachControl(element: Nullable<HTMLElement>): void;
  12166. /**
  12167. * Gets the class name of the current intput.
  12168. * @returns the class name
  12169. */
  12170. getClassName(): string;
  12171. /**
  12172. * Get the friendly name associated with the input class.
  12173. * @returns the input friendly name
  12174. */
  12175. getSimpleName(): string;
  12176. }
  12177. }
  12178. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12179. import { Nullable } from "babylonjs/types";
  12180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12181. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12182. /**
  12183. * Manage the touch inputs to control the movement of a free camera.
  12184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12185. */
  12186. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12187. /**
  12188. * Defines the camera the input is attached to.
  12189. */
  12190. camera: FreeCamera;
  12191. /**
  12192. * Defines the touch sensibility for rotation.
  12193. * The higher the faster.
  12194. */
  12195. touchAngularSensibility: number;
  12196. /**
  12197. * Defines the touch sensibility for move.
  12198. * The higher the faster.
  12199. */
  12200. touchMoveSensibility: number;
  12201. private _offsetX;
  12202. private _offsetY;
  12203. private _pointerPressed;
  12204. private _pointerInput;
  12205. private _observer;
  12206. private _onLostFocus;
  12207. /**
  12208. * Attach the input controls to a specific dom element to get the input from.
  12209. * @param element Defines the element the controls should be listened from
  12210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12211. */
  12212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12213. /**
  12214. * Detach the current controls from the specified dom element.
  12215. * @param element Defines the element to stop listening the inputs from
  12216. */
  12217. detachControl(element: Nullable<HTMLElement>): void;
  12218. /**
  12219. * Update the current camera state depending on the inputs that have been used this frame.
  12220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12221. */
  12222. checkInputs(): void;
  12223. /**
  12224. * Gets the class name of the current intput.
  12225. * @returns the class name
  12226. */
  12227. getClassName(): string;
  12228. /**
  12229. * Get the friendly name associated with the input class.
  12230. * @returns the input friendly name
  12231. */
  12232. getSimpleName(): string;
  12233. }
  12234. }
  12235. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12236. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12237. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12238. /**
  12239. * Default Inputs manager for the FreeCamera.
  12240. * It groups all the default supported inputs for ease of use.
  12241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12242. */
  12243. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12244. /**
  12245. * Instantiates a new FreeCameraInputsManager.
  12246. * @param camera Defines the camera the inputs belong to
  12247. */
  12248. constructor(camera: FreeCamera);
  12249. /**
  12250. * Add keyboard input support to the input manager.
  12251. * @returns the current input manager
  12252. */
  12253. addKeyboard(): FreeCameraInputsManager;
  12254. /**
  12255. * Add mouse input support to the input manager.
  12256. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12257. * @returns the current input manager
  12258. */
  12259. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12260. /**
  12261. * Add touch input support to the input manager.
  12262. * @returns the current input manager
  12263. */
  12264. addTouch(): FreeCameraInputsManager;
  12265. }
  12266. }
  12267. declare module "babylonjs/Cameras/freeCamera" {
  12268. import { Vector3 } from "babylonjs/Maths/math";
  12269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12270. import { Scene } from "babylonjs/scene";
  12271. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12272. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12273. /**
  12274. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12275. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12276. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12277. */
  12278. export class FreeCamera extends TargetCamera {
  12279. /**
  12280. * Define the collision ellipsoid of the camera.
  12281. * This is helpful to simulate a camera body like the player body around the camera
  12282. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12283. */
  12284. ellipsoid: Vector3;
  12285. /**
  12286. * Define an offset for the position of the ellipsoid around the camera.
  12287. * This can be helpful to determine the center of the body near the gravity center of the body
  12288. * instead of its head.
  12289. */
  12290. ellipsoidOffset: Vector3;
  12291. /**
  12292. * Enable or disable collisions of the camera with the rest of the scene objects.
  12293. */
  12294. checkCollisions: boolean;
  12295. /**
  12296. * Enable or disable gravity on the camera.
  12297. */
  12298. applyGravity: boolean;
  12299. /**
  12300. * Define the input manager associated to the camera.
  12301. */
  12302. inputs: FreeCameraInputsManager;
  12303. /**
  12304. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12305. * Higher values reduce sensitivity.
  12306. */
  12307. /**
  12308. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12309. * Higher values reduce sensitivity.
  12310. */
  12311. angularSensibility: number;
  12312. /**
  12313. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12314. */
  12315. keysUp: number[];
  12316. /**
  12317. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12318. */
  12319. keysDown: number[];
  12320. /**
  12321. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12322. */
  12323. keysLeft: number[];
  12324. /**
  12325. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12326. */
  12327. keysRight: number[];
  12328. /**
  12329. * Event raised when the camera collide with a mesh in the scene.
  12330. */
  12331. onCollide: (collidedMesh: AbstractMesh) => void;
  12332. private _collider;
  12333. private _needMoveForGravity;
  12334. private _oldPosition;
  12335. private _diffPosition;
  12336. private _newPosition;
  12337. /** @hidden */
  12338. _localDirection: Vector3;
  12339. /** @hidden */
  12340. _transformedDirection: Vector3;
  12341. /**
  12342. * Instantiates a Free Camera.
  12343. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12344. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12345. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12346. * @param name Define the name of the camera in the scene
  12347. * @param position Define the start position of the camera in the scene
  12348. * @param scene Define the scene the camera belongs to
  12349. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12350. */
  12351. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12352. /**
  12353. * Attached controls to the current camera.
  12354. * @param element Defines the element the controls should be listened from
  12355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12356. */
  12357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12358. /**
  12359. * Detach the current controls from the camera.
  12360. * The camera will stop reacting to inputs.
  12361. * @param element Defines the element to stop listening the inputs from
  12362. */
  12363. detachControl(element: HTMLElement): void;
  12364. private _collisionMask;
  12365. /**
  12366. * Define a collision mask to limit the list of object the camera can collide with
  12367. */
  12368. collisionMask: number;
  12369. /** @hidden */
  12370. _collideWithWorld(displacement: Vector3): void;
  12371. private _onCollisionPositionChange;
  12372. /** @hidden */
  12373. _checkInputs(): void;
  12374. /** @hidden */
  12375. _decideIfNeedsToMove(): boolean;
  12376. /** @hidden */
  12377. _updatePosition(): void;
  12378. /**
  12379. * Destroy the camera and release the current resources hold by it.
  12380. */
  12381. dispose(): void;
  12382. /**
  12383. * Gets the current object class name.
  12384. * @return the class name
  12385. */
  12386. getClassName(): string;
  12387. }
  12388. }
  12389. declare module "babylonjs/Gamepads/gamepad" {
  12390. import { Observable } from "babylonjs/Misc/observable";
  12391. /**
  12392. * Represents a gamepad control stick position
  12393. */
  12394. export class StickValues {
  12395. /**
  12396. * The x component of the control stick
  12397. */
  12398. x: number;
  12399. /**
  12400. * The y component of the control stick
  12401. */
  12402. y: number;
  12403. /**
  12404. * Initializes the gamepad x and y control stick values
  12405. * @param x The x component of the gamepad control stick value
  12406. * @param y The y component of the gamepad control stick value
  12407. */
  12408. constructor(
  12409. /**
  12410. * The x component of the control stick
  12411. */
  12412. x: number,
  12413. /**
  12414. * The y component of the control stick
  12415. */
  12416. y: number);
  12417. }
  12418. /**
  12419. * An interface which manages callbacks for gamepad button changes
  12420. */
  12421. export interface GamepadButtonChanges {
  12422. /**
  12423. * Called when a gamepad has been changed
  12424. */
  12425. changed: boolean;
  12426. /**
  12427. * Called when a gamepad press event has been triggered
  12428. */
  12429. pressChanged: boolean;
  12430. /**
  12431. * Called when a touch event has been triggered
  12432. */
  12433. touchChanged: boolean;
  12434. /**
  12435. * Called when a value has changed
  12436. */
  12437. valueChanged: boolean;
  12438. }
  12439. /**
  12440. * Represents a gamepad
  12441. */
  12442. export class Gamepad {
  12443. /**
  12444. * The id of the gamepad
  12445. */
  12446. id: string;
  12447. /**
  12448. * The index of the gamepad
  12449. */
  12450. index: number;
  12451. /**
  12452. * The browser gamepad
  12453. */
  12454. browserGamepad: any;
  12455. /**
  12456. * Specifies what type of gamepad this represents
  12457. */
  12458. type: number;
  12459. private _leftStick;
  12460. private _rightStick;
  12461. /** @hidden */
  12462. _isConnected: boolean;
  12463. private _leftStickAxisX;
  12464. private _leftStickAxisY;
  12465. private _rightStickAxisX;
  12466. private _rightStickAxisY;
  12467. /**
  12468. * Triggered when the left control stick has been changed
  12469. */
  12470. private _onleftstickchanged;
  12471. /**
  12472. * Triggered when the right control stick has been changed
  12473. */
  12474. private _onrightstickchanged;
  12475. /**
  12476. * Represents a gamepad controller
  12477. */
  12478. static GAMEPAD: number;
  12479. /**
  12480. * Represents a generic controller
  12481. */
  12482. static GENERIC: number;
  12483. /**
  12484. * Represents an XBox controller
  12485. */
  12486. static XBOX: number;
  12487. /**
  12488. * Represents a pose-enabled controller
  12489. */
  12490. static POSE_ENABLED: number;
  12491. /**
  12492. * Specifies whether the left control stick should be Y-inverted
  12493. */
  12494. protected _invertLeftStickY: boolean;
  12495. /**
  12496. * Specifies if the gamepad has been connected
  12497. */
  12498. readonly isConnected: boolean;
  12499. /**
  12500. * Initializes the gamepad
  12501. * @param id The id of the gamepad
  12502. * @param index The index of the gamepad
  12503. * @param browserGamepad The browser gamepad
  12504. * @param leftStickX The x component of the left joystick
  12505. * @param leftStickY The y component of the left joystick
  12506. * @param rightStickX The x component of the right joystick
  12507. * @param rightStickY The y component of the right joystick
  12508. */
  12509. constructor(
  12510. /**
  12511. * The id of the gamepad
  12512. */
  12513. id: string,
  12514. /**
  12515. * The index of the gamepad
  12516. */
  12517. index: number,
  12518. /**
  12519. * The browser gamepad
  12520. */
  12521. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12522. /**
  12523. * Callback triggered when the left joystick has changed
  12524. * @param callback
  12525. */
  12526. onleftstickchanged(callback: (values: StickValues) => void): void;
  12527. /**
  12528. * Callback triggered when the right joystick has changed
  12529. * @param callback
  12530. */
  12531. onrightstickchanged(callback: (values: StickValues) => void): void;
  12532. /**
  12533. * Gets the left joystick
  12534. */
  12535. /**
  12536. * Sets the left joystick values
  12537. */
  12538. leftStick: StickValues;
  12539. /**
  12540. * Gets the right joystick
  12541. */
  12542. /**
  12543. * Sets the right joystick value
  12544. */
  12545. rightStick: StickValues;
  12546. /**
  12547. * Updates the gamepad joystick positions
  12548. */
  12549. update(): void;
  12550. /**
  12551. * Disposes the gamepad
  12552. */
  12553. dispose(): void;
  12554. }
  12555. /**
  12556. * Represents a generic gamepad
  12557. */
  12558. export class GenericPad extends Gamepad {
  12559. private _buttons;
  12560. private _onbuttondown;
  12561. private _onbuttonup;
  12562. /**
  12563. * Observable triggered when a button has been pressed
  12564. */
  12565. onButtonDownObservable: Observable<number>;
  12566. /**
  12567. * Observable triggered when a button has been released
  12568. */
  12569. onButtonUpObservable: Observable<number>;
  12570. /**
  12571. * Callback triggered when a button has been pressed
  12572. * @param callback Called when a button has been pressed
  12573. */
  12574. onbuttondown(callback: (buttonPressed: number) => void): void;
  12575. /**
  12576. * Callback triggered when a button has been released
  12577. * @param callback Called when a button has been released
  12578. */
  12579. onbuttonup(callback: (buttonReleased: number) => void): void;
  12580. /**
  12581. * Initializes the generic gamepad
  12582. * @param id The id of the generic gamepad
  12583. * @param index The index of the generic gamepad
  12584. * @param browserGamepad The browser gamepad
  12585. */
  12586. constructor(id: string, index: number, browserGamepad: any);
  12587. private _setButtonValue;
  12588. /**
  12589. * Updates the generic gamepad
  12590. */
  12591. update(): void;
  12592. /**
  12593. * Disposes the generic gamepad
  12594. */
  12595. dispose(): void;
  12596. }
  12597. }
  12598. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12599. import { Observable } from "babylonjs/Misc/observable";
  12600. import { Nullable } from "babylonjs/types";
  12601. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12602. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12604. import { Ray } from "babylonjs/Culling/ray";
  12605. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12606. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12607. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12608. /**
  12609. * Defines the types of pose enabled controllers that are supported
  12610. */
  12611. export enum PoseEnabledControllerType {
  12612. /**
  12613. * HTC Vive
  12614. */
  12615. VIVE = 0,
  12616. /**
  12617. * Oculus Rift
  12618. */
  12619. OCULUS = 1,
  12620. /**
  12621. * Windows mixed reality
  12622. */
  12623. WINDOWS = 2,
  12624. /**
  12625. * Samsung gear VR
  12626. */
  12627. GEAR_VR = 3,
  12628. /**
  12629. * Google Daydream
  12630. */
  12631. DAYDREAM = 4,
  12632. /**
  12633. * Generic
  12634. */
  12635. GENERIC = 5
  12636. }
  12637. /**
  12638. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12639. */
  12640. export interface MutableGamepadButton {
  12641. /**
  12642. * Value of the button/trigger
  12643. */
  12644. value: number;
  12645. /**
  12646. * If the button/trigger is currently touched
  12647. */
  12648. touched: boolean;
  12649. /**
  12650. * If the button/trigger is currently pressed
  12651. */
  12652. pressed: boolean;
  12653. }
  12654. /**
  12655. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12656. * @hidden
  12657. */
  12658. export interface ExtendedGamepadButton extends GamepadButton {
  12659. /**
  12660. * If the button/trigger is currently pressed
  12661. */
  12662. readonly pressed: boolean;
  12663. /**
  12664. * If the button/trigger is currently touched
  12665. */
  12666. readonly touched: boolean;
  12667. /**
  12668. * Value of the button/trigger
  12669. */
  12670. readonly value: number;
  12671. }
  12672. /** @hidden */
  12673. export interface _GamePadFactory {
  12674. /**
  12675. * Returns wether or not the current gamepad can be created for this type of controller.
  12676. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12677. * @returns true if it can be created, otherwise false
  12678. */
  12679. canCreate(gamepadInfo: any): boolean;
  12680. /**
  12681. * Creates a new instance of the Gamepad.
  12682. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12683. * @returns the new gamepad instance
  12684. */
  12685. create(gamepadInfo: any): Gamepad;
  12686. }
  12687. /**
  12688. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12689. */
  12690. export class PoseEnabledControllerHelper {
  12691. /** @hidden */
  12692. static _ControllerFactories: _GamePadFactory[];
  12693. /** @hidden */
  12694. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12695. /**
  12696. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12697. * @param vrGamepad the gamepad to initialized
  12698. * @returns a vr controller of the type the gamepad identified as
  12699. */
  12700. static InitiateController(vrGamepad: any): Gamepad;
  12701. }
  12702. /**
  12703. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12704. */
  12705. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12706. private _deviceRoomPosition;
  12707. private _deviceRoomRotationQuaternion;
  12708. /**
  12709. * The device position in babylon space
  12710. */
  12711. devicePosition: Vector3;
  12712. /**
  12713. * The device rotation in babylon space
  12714. */
  12715. deviceRotationQuaternion: Quaternion;
  12716. /**
  12717. * The scale factor of the device in babylon space
  12718. */
  12719. deviceScaleFactor: number;
  12720. /**
  12721. * (Likely devicePosition should be used instead) The device position in its room space
  12722. */
  12723. position: Vector3;
  12724. /**
  12725. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12726. */
  12727. rotationQuaternion: Quaternion;
  12728. /**
  12729. * The type of controller (Eg. Windows mixed reality)
  12730. */
  12731. controllerType: PoseEnabledControllerType;
  12732. protected _calculatedPosition: Vector3;
  12733. private _calculatedRotation;
  12734. /**
  12735. * The raw pose from the device
  12736. */
  12737. rawPose: DevicePose;
  12738. private _trackPosition;
  12739. private _maxRotationDistFromHeadset;
  12740. private _draggedRoomRotation;
  12741. /**
  12742. * @hidden
  12743. */
  12744. _disableTrackPosition(fixedPosition: Vector3): void;
  12745. /**
  12746. * Internal, the mesh attached to the controller
  12747. * @hidden
  12748. */
  12749. _mesh: Nullable<AbstractMesh>;
  12750. private _poseControlledCamera;
  12751. private _leftHandSystemQuaternion;
  12752. /**
  12753. * Internal, matrix used to convert room space to babylon space
  12754. * @hidden
  12755. */
  12756. _deviceToWorld: Matrix;
  12757. /**
  12758. * Node to be used when casting a ray from the controller
  12759. * @hidden
  12760. */
  12761. _pointingPoseNode: Nullable<TransformNode>;
  12762. /**
  12763. * Name of the child mesh that can be used to cast a ray from the controller
  12764. */
  12765. static readonly POINTING_POSE: string;
  12766. /**
  12767. * Creates a new PoseEnabledController from a gamepad
  12768. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12769. */
  12770. constructor(browserGamepad: any);
  12771. private _workingMatrix;
  12772. /**
  12773. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12774. */
  12775. update(): void;
  12776. /**
  12777. * Updates only the pose device and mesh without doing any button event checking
  12778. */
  12779. protected _updatePoseAndMesh(): void;
  12780. /**
  12781. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12782. * @param poseData raw pose fromthe device
  12783. */
  12784. updateFromDevice(poseData: DevicePose): void;
  12785. /**
  12786. * @hidden
  12787. */
  12788. _meshAttachedObservable: Observable<AbstractMesh>;
  12789. /**
  12790. * Attaches a mesh to the controller
  12791. * @param mesh the mesh to be attached
  12792. */
  12793. attachToMesh(mesh: AbstractMesh): void;
  12794. /**
  12795. * Attaches the controllers mesh to a camera
  12796. * @param camera the camera the mesh should be attached to
  12797. */
  12798. attachToPoseControlledCamera(camera: TargetCamera): void;
  12799. /**
  12800. * Disposes of the controller
  12801. */
  12802. dispose(): void;
  12803. /**
  12804. * The mesh that is attached to the controller
  12805. */
  12806. readonly mesh: Nullable<AbstractMesh>;
  12807. /**
  12808. * Gets the ray of the controller in the direction the controller is pointing
  12809. * @param length the length the resulting ray should be
  12810. * @returns a ray in the direction the controller is pointing
  12811. */
  12812. getForwardRay(length?: number): Ray;
  12813. }
  12814. }
  12815. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12816. import { Observable } from "babylonjs/Misc/observable";
  12817. import { Scene } from "babylonjs/scene";
  12818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12819. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12820. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12821. /**
  12822. * Defines the WebVRController object that represents controllers tracked in 3D space
  12823. */
  12824. export abstract class WebVRController extends PoseEnabledController {
  12825. /**
  12826. * Internal, the default controller model for the controller
  12827. */
  12828. protected _defaultModel: AbstractMesh;
  12829. /**
  12830. * Fired when the trigger state has changed
  12831. */
  12832. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12833. /**
  12834. * Fired when the main button state has changed
  12835. */
  12836. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12837. /**
  12838. * Fired when the secondary button state has changed
  12839. */
  12840. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12841. /**
  12842. * Fired when the pad state has changed
  12843. */
  12844. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12845. /**
  12846. * Fired when controllers stick values have changed
  12847. */
  12848. onPadValuesChangedObservable: Observable<StickValues>;
  12849. /**
  12850. * Array of button availible on the controller
  12851. */
  12852. protected _buttons: Array<MutableGamepadButton>;
  12853. private _onButtonStateChange;
  12854. /**
  12855. * Fired when a controller button's state has changed
  12856. * @param callback the callback containing the button that was modified
  12857. */
  12858. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12859. /**
  12860. * X and Y axis corrisponding to the controllers joystick
  12861. */
  12862. pad: StickValues;
  12863. /**
  12864. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12865. */
  12866. hand: string;
  12867. /**
  12868. * The default controller model for the controller
  12869. */
  12870. readonly defaultModel: AbstractMesh;
  12871. /**
  12872. * Creates a new WebVRController from a gamepad
  12873. * @param vrGamepad the gamepad that the WebVRController should be created from
  12874. */
  12875. constructor(vrGamepad: any);
  12876. /**
  12877. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12878. */
  12879. update(): void;
  12880. /**
  12881. * Function to be called when a button is modified
  12882. */
  12883. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12884. /**
  12885. * Loads a mesh and attaches it to the controller
  12886. * @param scene the scene the mesh should be added to
  12887. * @param meshLoaded callback for when the mesh has been loaded
  12888. */
  12889. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12890. private _setButtonValue;
  12891. private _changes;
  12892. private _checkChanges;
  12893. /**
  12894. * Disposes of th webVRCOntroller
  12895. */
  12896. dispose(): void;
  12897. }
  12898. }
  12899. declare module "babylonjs/Lights/hemisphericLight" {
  12900. import { Nullable } from "babylonjs/types";
  12901. import { Scene } from "babylonjs/scene";
  12902. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12903. import { Effect } from "babylonjs/Materials/effect";
  12904. import { Light } from "babylonjs/Lights/light";
  12905. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12906. /**
  12907. * The HemisphericLight simulates the ambient environment light,
  12908. * so the passed direction is the light reflection direction, not the incoming direction.
  12909. */
  12910. export class HemisphericLight extends Light {
  12911. /**
  12912. * The groundColor is the light in the opposite direction to the one specified during creation.
  12913. * 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.
  12914. */
  12915. groundColor: Color3;
  12916. /**
  12917. * The light reflection direction, not the incoming direction.
  12918. */
  12919. direction: Vector3;
  12920. /**
  12921. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12922. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12923. * The HemisphericLight can't cast shadows.
  12924. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12925. * @param name The friendly name of the light
  12926. * @param direction The direction of the light reflection
  12927. * @param scene The scene the light belongs to
  12928. */
  12929. constructor(name: string, direction: Vector3, scene: Scene);
  12930. protected _buildUniformLayout(): void;
  12931. /**
  12932. * Returns the string "HemisphericLight".
  12933. * @return The class name
  12934. */
  12935. getClassName(): string;
  12936. /**
  12937. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12938. * Returns the updated direction.
  12939. * @param target The target the direction should point to
  12940. * @return The computed direction
  12941. */
  12942. setDirectionToTarget(target: Vector3): Vector3;
  12943. /**
  12944. * Returns the shadow generator associated to the light.
  12945. * @returns Always null for hemispheric lights because it does not support shadows.
  12946. */
  12947. getShadowGenerator(): Nullable<IShadowGenerator>;
  12948. /**
  12949. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12950. * @param effect The effect to update
  12951. * @param lightIndex The index of the light in the effect to update
  12952. * @returns The hemispheric light
  12953. */
  12954. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12955. /**
  12956. * Computes the world matrix of the node
  12957. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12958. * @param useWasUpdatedFlag defines a reserved property
  12959. * @returns the world matrix
  12960. */
  12961. computeWorldMatrix(): Matrix;
  12962. /**
  12963. * Returns the integer 3.
  12964. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12965. */
  12966. getTypeID(): number;
  12967. /**
  12968. * Prepares the list of defines specific to the light type.
  12969. * @param defines the list of defines
  12970. * @param lightIndex defines the index of the light for the effect
  12971. */
  12972. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12973. }
  12974. }
  12975. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12976. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12977. import { Nullable } from "babylonjs/types";
  12978. import { Observable } from "babylonjs/Misc/observable";
  12979. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12980. import { Scene } from "babylonjs/scene";
  12981. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12982. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12983. import { Node } from "babylonjs/node";
  12984. import { Ray } from "babylonjs/Culling/ray";
  12985. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12986. /**
  12987. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12988. * IMPORTANT!! The data is right-hand data.
  12989. * @export
  12990. * @interface DevicePose
  12991. */
  12992. export interface DevicePose {
  12993. /**
  12994. * The position of the device, values in array are [x,y,z].
  12995. */
  12996. readonly position: Nullable<Float32Array>;
  12997. /**
  12998. * The linearVelocity of the device, values in array are [x,y,z].
  12999. */
  13000. readonly linearVelocity: Nullable<Float32Array>;
  13001. /**
  13002. * The linearAcceleration of the device, values in array are [x,y,z].
  13003. */
  13004. readonly linearAcceleration: Nullable<Float32Array>;
  13005. /**
  13006. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13007. */
  13008. readonly orientation: Nullable<Float32Array>;
  13009. /**
  13010. * The angularVelocity of the device, values in array are [x,y,z].
  13011. */
  13012. readonly angularVelocity: Nullable<Float32Array>;
  13013. /**
  13014. * The angularAcceleration of the device, values in array are [x,y,z].
  13015. */
  13016. readonly angularAcceleration: Nullable<Float32Array>;
  13017. }
  13018. /**
  13019. * Interface representing a pose controlled object in Babylon.
  13020. * A pose controlled object has both regular pose values as well as pose values
  13021. * from an external device such as a VR head mounted display
  13022. */
  13023. export interface PoseControlled {
  13024. /**
  13025. * The position of the object in babylon space.
  13026. */
  13027. position: Vector3;
  13028. /**
  13029. * The rotation quaternion of the object in babylon space.
  13030. */
  13031. rotationQuaternion: Quaternion;
  13032. /**
  13033. * The position of the device in babylon space.
  13034. */
  13035. devicePosition?: Vector3;
  13036. /**
  13037. * The rotation quaternion of the device in babylon space.
  13038. */
  13039. deviceRotationQuaternion: Quaternion;
  13040. /**
  13041. * The raw pose coming from the device.
  13042. */
  13043. rawPose: Nullable<DevicePose>;
  13044. /**
  13045. * The scale of the device to be used when translating from device space to babylon space.
  13046. */
  13047. deviceScaleFactor: number;
  13048. /**
  13049. * Updates the poseControlled values based on the input device pose.
  13050. * @param poseData the pose data to update the object with
  13051. */
  13052. updateFromDevice(poseData: DevicePose): void;
  13053. }
  13054. /**
  13055. * Set of options to customize the webVRCamera
  13056. */
  13057. export interface WebVROptions {
  13058. /**
  13059. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13060. */
  13061. trackPosition?: boolean;
  13062. /**
  13063. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13064. */
  13065. positionScale?: number;
  13066. /**
  13067. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13068. */
  13069. displayName?: string;
  13070. /**
  13071. * Should the native controller meshes be initialized. (default: true)
  13072. */
  13073. controllerMeshes?: boolean;
  13074. /**
  13075. * Creating a default HemiLight only on controllers. (default: true)
  13076. */
  13077. defaultLightingOnControllers?: boolean;
  13078. /**
  13079. * If you don't want to use the default VR button of the helper. (default: false)
  13080. */
  13081. useCustomVRButton?: boolean;
  13082. /**
  13083. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13084. */
  13085. customVRButton?: HTMLButtonElement;
  13086. /**
  13087. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13088. */
  13089. rayLength?: number;
  13090. /**
  13091. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13092. */
  13093. defaultHeight?: number;
  13094. }
  13095. /**
  13096. * This represents a WebVR camera.
  13097. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13098. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13099. */
  13100. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13101. private webVROptions;
  13102. /**
  13103. * @hidden
  13104. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13105. */
  13106. _vrDevice: any;
  13107. /**
  13108. * The rawPose of the vrDevice.
  13109. */
  13110. rawPose: Nullable<DevicePose>;
  13111. private _onVREnabled;
  13112. private _specsVersion;
  13113. private _attached;
  13114. private _frameData;
  13115. protected _descendants: Array<Node>;
  13116. private _deviceRoomPosition;
  13117. /** @hidden */
  13118. _deviceRoomRotationQuaternion: Quaternion;
  13119. private _standingMatrix;
  13120. /**
  13121. * Represents device position in babylon space.
  13122. */
  13123. devicePosition: Vector3;
  13124. /**
  13125. * Represents device rotation in babylon space.
  13126. */
  13127. deviceRotationQuaternion: Quaternion;
  13128. /**
  13129. * The scale of the device to be used when translating from device space to babylon space.
  13130. */
  13131. deviceScaleFactor: number;
  13132. private _deviceToWorld;
  13133. private _worldToDevice;
  13134. /**
  13135. * References to the webVR controllers for the vrDevice.
  13136. */
  13137. controllers: Array<WebVRController>;
  13138. /**
  13139. * Emits an event when a controller is attached.
  13140. */
  13141. onControllersAttachedObservable: Observable<WebVRController[]>;
  13142. /**
  13143. * Emits an event when a controller's mesh has been loaded;
  13144. */
  13145. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13146. /**
  13147. * Emits an event when the HMD's pose has been updated.
  13148. */
  13149. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13150. private _poseSet;
  13151. /**
  13152. * If the rig cameras be used as parent instead of this camera.
  13153. */
  13154. rigParenting: boolean;
  13155. private _lightOnControllers;
  13156. private _defaultHeight?;
  13157. /**
  13158. * Instantiates a WebVRFreeCamera.
  13159. * @param name The name of the WebVRFreeCamera
  13160. * @param position The starting anchor position for the camera
  13161. * @param scene The scene the camera belongs to
  13162. * @param webVROptions a set of customizable options for the webVRCamera
  13163. */
  13164. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13165. /**
  13166. * Gets the device distance from the ground in meters.
  13167. * @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.
  13168. */
  13169. deviceDistanceToRoomGround(): number;
  13170. /**
  13171. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13172. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13173. */
  13174. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13175. /**
  13176. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13177. * @returns A promise with a boolean set to if the standing matrix is supported.
  13178. */
  13179. useStandingMatrixAsync(): Promise<boolean>;
  13180. /**
  13181. * Disposes the camera
  13182. */
  13183. dispose(): void;
  13184. /**
  13185. * Gets a vrController by name.
  13186. * @param name The name of the controller to retreive
  13187. * @returns the controller matching the name specified or null if not found
  13188. */
  13189. getControllerByName(name: string): Nullable<WebVRController>;
  13190. private _leftController;
  13191. /**
  13192. * The controller corrisponding to the users left hand.
  13193. */
  13194. readonly leftController: Nullable<WebVRController>;
  13195. private _rightController;
  13196. /**
  13197. * The controller corrisponding to the users right hand.
  13198. */
  13199. readonly rightController: Nullable<WebVRController>;
  13200. /**
  13201. * Casts a ray forward from the vrCamera's gaze.
  13202. * @param length Length of the ray (default: 100)
  13203. * @returns the ray corrisponding to the gaze
  13204. */
  13205. getForwardRay(length?: number): Ray;
  13206. /**
  13207. * @hidden
  13208. * Updates the camera based on device's frame data
  13209. */
  13210. _checkInputs(): void;
  13211. /**
  13212. * Updates the poseControlled values based on the input device pose.
  13213. * @param poseData Pose coming from the device
  13214. */
  13215. updateFromDevice(poseData: DevicePose): void;
  13216. private _htmlElementAttached;
  13217. private _detachIfAttached;
  13218. /**
  13219. * WebVR's attach control will start broadcasting frames to the device.
  13220. * Note that in certain browsers (chrome for example) this function must be called
  13221. * within a user-interaction callback. Example:
  13222. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13223. *
  13224. * @param element html element to attach the vrDevice to
  13225. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13226. */
  13227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13228. /**
  13229. * Detaches the camera from the html element and disables VR
  13230. *
  13231. * @param element html element to detach from
  13232. */
  13233. detachControl(element: HTMLElement): void;
  13234. /**
  13235. * @returns the name of this class
  13236. */
  13237. getClassName(): string;
  13238. /**
  13239. * Calls resetPose on the vrDisplay
  13240. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13241. */
  13242. resetToCurrentRotation(): void;
  13243. /**
  13244. * @hidden
  13245. * Updates the rig cameras (left and right eye)
  13246. */
  13247. _updateRigCameras(): void;
  13248. private _workingVector;
  13249. private _oneVector;
  13250. private _workingMatrix;
  13251. private updateCacheCalled;
  13252. private _correctPositionIfNotTrackPosition;
  13253. /**
  13254. * @hidden
  13255. * Updates the cached values of the camera
  13256. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13257. */
  13258. _updateCache(ignoreParentClass?: boolean): void;
  13259. /**
  13260. * @hidden
  13261. * Get current device position in babylon world
  13262. */
  13263. _computeDevicePosition(): void;
  13264. /**
  13265. * Updates the current device position and rotation in the babylon world
  13266. */
  13267. update(): void;
  13268. /**
  13269. * @hidden
  13270. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13271. * @returns an identity matrix
  13272. */
  13273. _getViewMatrix(): Matrix;
  13274. private _tmpMatrix;
  13275. /**
  13276. * This function is called by the two RIG cameras.
  13277. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13278. * @hidden
  13279. */
  13280. _getWebVRViewMatrix(): Matrix;
  13281. /** @hidden */
  13282. _getWebVRProjectionMatrix(): Matrix;
  13283. private _onGamepadConnectedObserver;
  13284. private _onGamepadDisconnectedObserver;
  13285. private _updateCacheWhenTrackingDisabledObserver;
  13286. /**
  13287. * Initializes the controllers and their meshes
  13288. */
  13289. initControllers(): void;
  13290. }
  13291. }
  13292. declare module "babylonjs/PostProcesses/postProcess" {
  13293. import { Nullable } from "babylonjs/types";
  13294. import { SmartArray } from "babylonjs/Misc/smartArray";
  13295. import { Observable } from "babylonjs/Misc/observable";
  13296. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13297. import { Camera } from "babylonjs/Cameras/camera";
  13298. import { Effect } from "babylonjs/Materials/effect";
  13299. import "babylonjs/Shaders/postprocess.vertex";
  13300. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13301. import { Engine } from "babylonjs/Engines/engine";
  13302. /**
  13303. * Size options for a post process
  13304. */
  13305. export type PostProcessOptions = {
  13306. width: number;
  13307. height: number;
  13308. };
  13309. /**
  13310. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13311. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13312. */
  13313. export class PostProcess {
  13314. /** Name of the PostProcess. */
  13315. name: string;
  13316. /**
  13317. * Gets or sets the unique id of the post process
  13318. */
  13319. uniqueId: number;
  13320. /**
  13321. * Width of the texture to apply the post process on
  13322. */
  13323. width: number;
  13324. /**
  13325. * Height of the texture to apply the post process on
  13326. */
  13327. height: number;
  13328. /**
  13329. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13330. * @hidden
  13331. */
  13332. _outputTexture: Nullable<InternalTexture>;
  13333. /**
  13334. * Sampling mode used by the shader
  13335. * See https://doc.babylonjs.com/classes/3.1/texture
  13336. */
  13337. renderTargetSamplingMode: number;
  13338. /**
  13339. * Clear color to use when screen clearing
  13340. */
  13341. clearColor: Color4;
  13342. /**
  13343. * If the buffer needs to be cleared before applying the post process. (default: true)
  13344. * Should be set to false if shader will overwrite all previous pixels.
  13345. */
  13346. autoClear: boolean;
  13347. /**
  13348. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13349. */
  13350. alphaMode: number;
  13351. /**
  13352. * Sets the setAlphaBlendConstants of the babylon engine
  13353. */
  13354. alphaConstants: Color4;
  13355. /**
  13356. * Animations to be used for the post processing
  13357. */
  13358. animations: import("babylonjs/Animations/animation").Animation[];
  13359. /**
  13360. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13361. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13362. */
  13363. enablePixelPerfectMode: boolean;
  13364. /**
  13365. * Force the postprocess to be applied without taking in account viewport
  13366. */
  13367. forceFullscreenViewport: boolean;
  13368. /**
  13369. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13370. *
  13371. * | Value | Type | Description |
  13372. * | ----- | ----------------------------------- | ----------- |
  13373. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13374. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13375. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13376. *
  13377. */
  13378. scaleMode: number;
  13379. /**
  13380. * Force textures to be a power of two (default: false)
  13381. */
  13382. alwaysForcePOT: boolean;
  13383. private _samples;
  13384. /**
  13385. * Number of sample textures (default: 1)
  13386. */
  13387. samples: number;
  13388. /**
  13389. * Modify the scale of the post process to be the same as the viewport (default: false)
  13390. */
  13391. adaptScaleToCurrentViewport: boolean;
  13392. private _camera;
  13393. private _scene;
  13394. private _engine;
  13395. private _options;
  13396. private _reusable;
  13397. private _textureType;
  13398. /**
  13399. * Smart array of input and output textures for the post process.
  13400. * @hidden
  13401. */
  13402. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13403. /**
  13404. * The index in _textures that corresponds to the output texture.
  13405. * @hidden
  13406. */
  13407. _currentRenderTextureInd: number;
  13408. private _effect;
  13409. private _samplers;
  13410. private _fragmentUrl;
  13411. private _vertexUrl;
  13412. private _parameters;
  13413. private _scaleRatio;
  13414. protected _indexParameters: any;
  13415. private _shareOutputWithPostProcess;
  13416. private _texelSize;
  13417. private _forcedOutputTexture;
  13418. /**
  13419. * Returns the fragment url or shader name used in the post process.
  13420. * @returns the fragment url or name in the shader store.
  13421. */
  13422. getEffectName(): string;
  13423. /**
  13424. * An event triggered when the postprocess is activated.
  13425. */
  13426. onActivateObservable: Observable<Camera>;
  13427. private _onActivateObserver;
  13428. /**
  13429. * A function that is added to the onActivateObservable
  13430. */
  13431. onActivate: Nullable<(camera: Camera) => void>;
  13432. /**
  13433. * An event triggered when the postprocess changes its size.
  13434. */
  13435. onSizeChangedObservable: Observable<PostProcess>;
  13436. private _onSizeChangedObserver;
  13437. /**
  13438. * A function that is added to the onSizeChangedObservable
  13439. */
  13440. onSizeChanged: (postProcess: PostProcess) => void;
  13441. /**
  13442. * An event triggered when the postprocess applies its effect.
  13443. */
  13444. onApplyObservable: Observable<Effect>;
  13445. private _onApplyObserver;
  13446. /**
  13447. * A function that is added to the onApplyObservable
  13448. */
  13449. onApply: (effect: Effect) => void;
  13450. /**
  13451. * An event triggered before rendering the postprocess
  13452. */
  13453. onBeforeRenderObservable: Observable<Effect>;
  13454. private _onBeforeRenderObserver;
  13455. /**
  13456. * A function that is added to the onBeforeRenderObservable
  13457. */
  13458. onBeforeRender: (effect: Effect) => void;
  13459. /**
  13460. * An event triggered after rendering the postprocess
  13461. */
  13462. onAfterRenderObservable: Observable<Effect>;
  13463. private _onAfterRenderObserver;
  13464. /**
  13465. * A function that is added to the onAfterRenderObservable
  13466. */
  13467. onAfterRender: (efect: Effect) => void;
  13468. /**
  13469. * 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
  13470. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13471. */
  13472. inputTexture: InternalTexture;
  13473. /**
  13474. * Gets the camera which post process is applied to.
  13475. * @returns The camera the post process is applied to.
  13476. */
  13477. getCamera(): Camera;
  13478. /**
  13479. * Gets the texel size of the postprocess.
  13480. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13481. */
  13482. readonly texelSize: Vector2;
  13483. /**
  13484. * Creates a new instance PostProcess
  13485. * @param name The name of the PostProcess.
  13486. * @param fragmentUrl The url of the fragment shader to be used.
  13487. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13488. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13489. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13490. * @param camera The camera to apply the render pass to.
  13491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13492. * @param engine The engine which the post process will be applied. (default: current engine)
  13493. * @param reusable If the post process can be reused on the same frame. (default: false)
  13494. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13495. * @param textureType Type of textures used when performing the post process. (default: 0)
  13496. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13497. * @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
  13498. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13499. */
  13500. constructor(
  13501. /** Name of the PostProcess. */
  13502. 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);
  13503. /**
  13504. * Gets a string idenfifying the name of the class
  13505. * @returns "PostProcess" string
  13506. */
  13507. getClassName(): string;
  13508. /**
  13509. * Gets the engine which this post process belongs to.
  13510. * @returns The engine the post process was enabled with.
  13511. */
  13512. getEngine(): Engine;
  13513. /**
  13514. * The effect that is created when initializing the post process.
  13515. * @returns The created effect corrisponding the the postprocess.
  13516. */
  13517. getEffect(): Effect;
  13518. /**
  13519. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13520. * @param postProcess The post process to share the output with.
  13521. * @returns This post process.
  13522. */
  13523. shareOutputWith(postProcess: PostProcess): PostProcess;
  13524. /**
  13525. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13526. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13527. */
  13528. useOwnOutput(): void;
  13529. /**
  13530. * Updates the effect with the current post process compile time values and recompiles the shader.
  13531. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13532. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13533. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13534. * @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
  13535. * @param onCompiled Called when the shader has been compiled.
  13536. * @param onError Called if there is an error when compiling a shader.
  13537. */
  13538. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13539. /**
  13540. * The post process is reusable if it can be used multiple times within one frame.
  13541. * @returns If the post process is reusable
  13542. */
  13543. isReusable(): boolean;
  13544. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13545. markTextureDirty(): void;
  13546. /**
  13547. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13548. * 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.
  13549. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13550. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13551. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13552. * @returns The target texture that was bound to be written to.
  13553. */
  13554. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13555. /**
  13556. * If the post process is supported.
  13557. */
  13558. readonly isSupported: boolean;
  13559. /**
  13560. * The aspect ratio of the output texture.
  13561. */
  13562. readonly aspectRatio: number;
  13563. /**
  13564. * Get a value indicating if the post-process is ready to be used
  13565. * @returns true if the post-process is ready (shader is compiled)
  13566. */
  13567. isReady(): boolean;
  13568. /**
  13569. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13570. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13571. */
  13572. apply(): Nullable<Effect>;
  13573. private _disposeTextures;
  13574. /**
  13575. * Disposes the post process.
  13576. * @param camera The camera to dispose the post process on.
  13577. */
  13578. dispose(camera?: Camera): void;
  13579. }
  13580. }
  13581. declare module "babylonjs/PostProcesses/postProcessManager" {
  13582. import { Nullable } from "babylonjs/types";
  13583. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13584. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13585. import { Scene } from "babylonjs/scene";
  13586. /**
  13587. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13588. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13589. */
  13590. export class PostProcessManager {
  13591. private _scene;
  13592. private _indexBuffer;
  13593. private _vertexBuffers;
  13594. /**
  13595. * Creates a new instance PostProcess
  13596. * @param scene The scene that the post process is associated with.
  13597. */
  13598. constructor(scene: Scene);
  13599. private _prepareBuffers;
  13600. private _buildIndexBuffer;
  13601. /**
  13602. * Rebuilds the vertex buffers of the manager.
  13603. * @hidden
  13604. */
  13605. _rebuild(): void;
  13606. /**
  13607. * Prepares a frame to be run through a post process.
  13608. * @param sourceTexture The input texture to the post procesess. (default: null)
  13609. * @param postProcesses An array of post processes to be run. (default: null)
  13610. * @returns True if the post processes were able to be run.
  13611. * @hidden
  13612. */
  13613. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13614. /**
  13615. * Manually render a set of post processes to a texture.
  13616. * @param postProcesses An array of post processes to be run.
  13617. * @param targetTexture The target texture to render to.
  13618. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13619. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13620. * @param lodLevel defines which lod of the texture to render to
  13621. */
  13622. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13623. /**
  13624. * Finalize the result of the output of the postprocesses.
  13625. * @param doNotPresent If true the result will not be displayed to the screen.
  13626. * @param targetTexture The target texture to render to.
  13627. * @param faceIndex The index of the face to bind the target texture to.
  13628. * @param postProcesses The array of post processes to render.
  13629. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13630. * @hidden
  13631. */
  13632. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13633. /**
  13634. * Disposes of the post process manager.
  13635. */
  13636. dispose(): void;
  13637. }
  13638. }
  13639. declare module "babylonjs/Layers/layerSceneComponent" {
  13640. import { Scene } from "babylonjs/scene";
  13641. import { ISceneComponent } from "babylonjs/sceneComponent";
  13642. import { Layer } from "babylonjs/Layers/layer";
  13643. module "babylonjs/abstractScene" {
  13644. interface AbstractScene {
  13645. /**
  13646. * The list of layers (background and foreground) of the scene
  13647. */
  13648. layers: Array<Layer>;
  13649. }
  13650. }
  13651. /**
  13652. * Defines the layer scene component responsible to manage any layers
  13653. * in a given scene.
  13654. */
  13655. export class LayerSceneComponent implements ISceneComponent {
  13656. /**
  13657. * The component name helpfull to identify the component in the list of scene components.
  13658. */
  13659. readonly name: string;
  13660. /**
  13661. * The scene the component belongs to.
  13662. */
  13663. scene: Scene;
  13664. private _engine;
  13665. /**
  13666. * Creates a new instance of the component for the given scene
  13667. * @param scene Defines the scene to register the component in
  13668. */
  13669. constructor(scene: Scene);
  13670. /**
  13671. * Registers the component in a given scene
  13672. */
  13673. register(): void;
  13674. /**
  13675. * Rebuilds the elements related to this component in case of
  13676. * context lost for instance.
  13677. */
  13678. rebuild(): void;
  13679. /**
  13680. * Disposes the component and the associated ressources.
  13681. */
  13682. dispose(): void;
  13683. private _draw;
  13684. private _drawCameraPredicate;
  13685. private _drawCameraBackground;
  13686. private _drawCameraForeground;
  13687. private _drawRenderTargetPredicate;
  13688. private _drawRenderTargetBackground;
  13689. private _drawRenderTargetForeground;
  13690. }
  13691. }
  13692. declare module "babylonjs/Shaders/layer.fragment" {
  13693. /** @hidden */
  13694. export var layerPixelShader: {
  13695. name: string;
  13696. shader: string;
  13697. };
  13698. }
  13699. declare module "babylonjs/Shaders/layer.vertex" {
  13700. /** @hidden */
  13701. export var layerVertexShader: {
  13702. name: string;
  13703. shader: string;
  13704. };
  13705. }
  13706. declare module "babylonjs/Layers/layer" {
  13707. import { Observable } from "babylonjs/Misc/observable";
  13708. import { Nullable } from "babylonjs/types";
  13709. import { Scene } from "babylonjs/scene";
  13710. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13711. import { Texture } from "babylonjs/Materials/Textures/texture";
  13712. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13713. import "babylonjs/Shaders/layer.fragment";
  13714. import "babylonjs/Shaders/layer.vertex";
  13715. /**
  13716. * This represents a full screen 2d layer.
  13717. * This can be useful to display a picture in the background of your scene for instance.
  13718. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13719. */
  13720. export class Layer {
  13721. /**
  13722. * Define the name of the layer.
  13723. */
  13724. name: string;
  13725. /**
  13726. * Define the texture the layer should display.
  13727. */
  13728. texture: Nullable<Texture>;
  13729. /**
  13730. * Is the layer in background or foreground.
  13731. */
  13732. isBackground: boolean;
  13733. /**
  13734. * Define the color of the layer (instead of texture).
  13735. */
  13736. color: Color4;
  13737. /**
  13738. * Define the scale of the layer in order to zoom in out of the texture.
  13739. */
  13740. scale: Vector2;
  13741. /**
  13742. * Define an offset for the layer in order to shift the texture.
  13743. */
  13744. offset: Vector2;
  13745. /**
  13746. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13747. */
  13748. alphaBlendingMode: number;
  13749. /**
  13750. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13751. * Alpha test will not mix with the background color in case of transparency.
  13752. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13753. */
  13754. alphaTest: boolean;
  13755. /**
  13756. * Define a mask to restrict the layer to only some of the scene cameras.
  13757. */
  13758. layerMask: number;
  13759. /**
  13760. * Define the list of render target the layer is visible into.
  13761. */
  13762. renderTargetTextures: RenderTargetTexture[];
  13763. /**
  13764. * Define if the layer is only used in renderTarget or if it also
  13765. * renders in the main frame buffer of the canvas.
  13766. */
  13767. renderOnlyInRenderTargetTextures: boolean;
  13768. private _scene;
  13769. private _vertexBuffers;
  13770. private _indexBuffer;
  13771. private _effect;
  13772. private _alphaTestEffect;
  13773. /**
  13774. * An event triggered when the layer is disposed.
  13775. */
  13776. onDisposeObservable: Observable<Layer>;
  13777. private _onDisposeObserver;
  13778. /**
  13779. * Back compatibility with callback before the onDisposeObservable existed.
  13780. * The set callback will be triggered when the layer has been disposed.
  13781. */
  13782. onDispose: () => void;
  13783. /**
  13784. * An event triggered before rendering the scene
  13785. */
  13786. onBeforeRenderObservable: Observable<Layer>;
  13787. private _onBeforeRenderObserver;
  13788. /**
  13789. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13790. * The set callback will be triggered just before rendering the layer.
  13791. */
  13792. onBeforeRender: () => void;
  13793. /**
  13794. * An event triggered after rendering the scene
  13795. */
  13796. onAfterRenderObservable: Observable<Layer>;
  13797. private _onAfterRenderObserver;
  13798. /**
  13799. * Back compatibility with callback before the onAfterRenderObservable existed.
  13800. * The set callback will be triggered just after rendering the layer.
  13801. */
  13802. onAfterRender: () => void;
  13803. /**
  13804. * Instantiates a new layer.
  13805. * This represents a full screen 2d layer.
  13806. * This can be useful to display a picture in the background of your scene for instance.
  13807. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13808. * @param name Define the name of the layer in the scene
  13809. * @param imgUrl Define the url of the texture to display in the layer
  13810. * @param scene Define the scene the layer belongs to
  13811. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13812. * @param color Defines a color for the layer
  13813. */
  13814. constructor(
  13815. /**
  13816. * Define the name of the layer.
  13817. */
  13818. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13819. private _createIndexBuffer;
  13820. /** @hidden */
  13821. _rebuild(): void;
  13822. /**
  13823. * Renders the layer in the scene.
  13824. */
  13825. render(): void;
  13826. /**
  13827. * Disposes and releases the associated ressources.
  13828. */
  13829. dispose(): void;
  13830. }
  13831. }
  13832. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13833. import { Scene } from "babylonjs/scene";
  13834. import { ISceneComponent } from "babylonjs/sceneComponent";
  13835. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13836. module "babylonjs/abstractScene" {
  13837. interface AbstractScene {
  13838. /**
  13839. * The list of procedural textures added to the scene
  13840. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13841. */
  13842. proceduralTextures: Array<ProceduralTexture>;
  13843. }
  13844. }
  13845. /**
  13846. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13847. * in a given scene.
  13848. */
  13849. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13850. /**
  13851. * The component name helpfull to identify the component in the list of scene components.
  13852. */
  13853. readonly name: string;
  13854. /**
  13855. * The scene the component belongs to.
  13856. */
  13857. scene: Scene;
  13858. /**
  13859. * Creates a new instance of the component for the given scene
  13860. * @param scene Defines the scene to register the component in
  13861. */
  13862. constructor(scene: Scene);
  13863. /**
  13864. * Registers the component in a given scene
  13865. */
  13866. register(): void;
  13867. /**
  13868. * Rebuilds the elements related to this component in case of
  13869. * context lost for instance.
  13870. */
  13871. rebuild(): void;
  13872. /**
  13873. * Disposes the component and the associated ressources.
  13874. */
  13875. dispose(): void;
  13876. private _beforeClear;
  13877. }
  13878. }
  13879. declare module "babylonjs/Shaders/procedural.vertex" {
  13880. /** @hidden */
  13881. export var proceduralVertexShader: {
  13882. name: string;
  13883. shader: string;
  13884. };
  13885. }
  13886. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13887. import { Observable } from "babylonjs/Misc/observable";
  13888. import { Nullable } from "babylonjs/types";
  13889. import { Scene } from "babylonjs/scene";
  13890. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13891. import { Effect } from "babylonjs/Materials/effect";
  13892. import { Texture } from "babylonjs/Materials/Textures/texture";
  13893. import "babylonjs/Shaders/procedural.vertex";
  13894. /**
  13895. * 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.
  13896. * This is the base class of any Procedural texture and contains most of the shareable code.
  13897. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13898. */
  13899. export class ProceduralTexture extends Texture {
  13900. isCube: boolean;
  13901. /**
  13902. * Define if the texture is enabled or not (disabled texture will not render)
  13903. */
  13904. isEnabled: boolean;
  13905. /**
  13906. * Define if the texture must be cleared before rendering (default is true)
  13907. */
  13908. autoClear: boolean;
  13909. /**
  13910. * Callback called when the texture is generated
  13911. */
  13912. onGenerated: () => void;
  13913. /**
  13914. * Event raised when the texture is generated
  13915. */
  13916. onGeneratedObservable: Observable<ProceduralTexture>;
  13917. /** @hidden */
  13918. _generateMipMaps: boolean;
  13919. /** @hidden **/
  13920. _effect: Effect;
  13921. /** @hidden */
  13922. _textures: {
  13923. [key: string]: Texture;
  13924. };
  13925. private _size;
  13926. private _currentRefreshId;
  13927. private _refreshRate;
  13928. private _vertexBuffers;
  13929. private _indexBuffer;
  13930. private _uniforms;
  13931. private _samplers;
  13932. private _fragment;
  13933. private _floats;
  13934. private _ints;
  13935. private _floatsArrays;
  13936. private _colors3;
  13937. private _colors4;
  13938. private _vectors2;
  13939. private _vectors3;
  13940. private _matrices;
  13941. private _fallbackTexture;
  13942. private _fallbackTextureUsed;
  13943. private _engine;
  13944. private _cachedDefines;
  13945. private _contentUpdateId;
  13946. private _contentData;
  13947. /**
  13948. * Instantiates a new procedural texture.
  13949. * 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.
  13950. * This is the base class of any Procedural texture and contains most of the shareable code.
  13951. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13952. * @param name Define the name of the texture
  13953. * @param size Define the size of the texture to create
  13954. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13955. * @param scene Define the scene the texture belongs to
  13956. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13957. * @param generateMipMaps Define if the texture should creates mip maps or not
  13958. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13959. */
  13960. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13961. /**
  13962. * The effect that is created when initializing the post process.
  13963. * @returns The created effect corrisponding the the postprocess.
  13964. */
  13965. getEffect(): Effect;
  13966. /**
  13967. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13968. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13969. */
  13970. getContent(): Nullable<ArrayBufferView>;
  13971. private _createIndexBuffer;
  13972. /** @hidden */
  13973. _rebuild(): void;
  13974. /**
  13975. * Resets the texture in order to recreate its associated resources.
  13976. * This can be called in case of context loss
  13977. */
  13978. reset(): void;
  13979. protected _getDefines(): string;
  13980. /**
  13981. * Is the texture ready to be used ? (rendered at least once)
  13982. * @returns true if ready, otherwise, false.
  13983. */
  13984. isReady(): boolean;
  13985. /**
  13986. * Resets the refresh counter of the texture and start bak from scratch.
  13987. * Could be useful to regenerate the texture if it is setup to render only once.
  13988. */
  13989. resetRefreshCounter(): void;
  13990. /**
  13991. * Set the fragment shader to use in order to render the texture.
  13992. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13993. */
  13994. setFragment(fragment: any): void;
  13995. /**
  13996. * Define the refresh rate of the texture or the rendering frequency.
  13997. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13998. */
  13999. refreshRate: number;
  14000. /** @hidden */
  14001. _shouldRender(): boolean;
  14002. /**
  14003. * Get the size the texture is rendering at.
  14004. * @returns the size (texture is always squared)
  14005. */
  14006. getRenderSize(): number;
  14007. /**
  14008. * Resize the texture to new value.
  14009. * @param size Define the new size the texture should have
  14010. * @param generateMipMaps Define whether the new texture should create mip maps
  14011. */
  14012. resize(size: number, generateMipMaps: boolean): void;
  14013. private _checkUniform;
  14014. /**
  14015. * Set a texture in the shader program used to render.
  14016. * @param name Define the name of the uniform samplers as defined in the shader
  14017. * @param texture Define the texture to bind to this sampler
  14018. * @return the texture itself allowing "fluent" like uniform updates
  14019. */
  14020. setTexture(name: string, texture: Texture): ProceduralTexture;
  14021. /**
  14022. * Set a float in the shader.
  14023. * @param name Define the name of the uniform as defined in the shader
  14024. * @param value Define the value to give to the uniform
  14025. * @return the texture itself allowing "fluent" like uniform updates
  14026. */
  14027. setFloat(name: string, value: number): ProceduralTexture;
  14028. /**
  14029. * Set a int in the shader.
  14030. * @param name Define the name of the uniform as defined in the shader
  14031. * @param value Define the value to give to the uniform
  14032. * @return the texture itself allowing "fluent" like uniform updates
  14033. */
  14034. setInt(name: string, value: number): ProceduralTexture;
  14035. /**
  14036. * Set an array of floats in the shader.
  14037. * @param name Define the name of the uniform as defined in the shader
  14038. * @param value Define the value to give to the uniform
  14039. * @return the texture itself allowing "fluent" like uniform updates
  14040. */
  14041. setFloats(name: string, value: number[]): ProceduralTexture;
  14042. /**
  14043. * Set a vec3 in the shader from a Color3.
  14044. * @param name Define the name of the uniform as defined in the shader
  14045. * @param value Define the value to give to the uniform
  14046. * @return the texture itself allowing "fluent" like uniform updates
  14047. */
  14048. setColor3(name: string, value: Color3): ProceduralTexture;
  14049. /**
  14050. * Set a vec4 in the shader from a Color4.
  14051. * @param name Define the name of the uniform as defined in the shader
  14052. * @param value Define the value to give to the uniform
  14053. * @return the texture itself allowing "fluent" like uniform updates
  14054. */
  14055. setColor4(name: string, value: Color4): ProceduralTexture;
  14056. /**
  14057. * Set a vec2 in the shader from a Vector2.
  14058. * @param name Define the name of the uniform as defined in the shader
  14059. * @param value Define the value to give to the uniform
  14060. * @return the texture itself allowing "fluent" like uniform updates
  14061. */
  14062. setVector2(name: string, value: Vector2): ProceduralTexture;
  14063. /**
  14064. * Set a vec3 in the shader from a Vector3.
  14065. * @param name Define the name of the uniform as defined in the shader
  14066. * @param value Define the value to give to the uniform
  14067. * @return the texture itself allowing "fluent" like uniform updates
  14068. */
  14069. setVector3(name: string, value: Vector3): ProceduralTexture;
  14070. /**
  14071. * Set a mat4 in the shader from a MAtrix.
  14072. * @param name Define the name of the uniform as defined in the shader
  14073. * @param value Define the value to give to the uniform
  14074. * @return the texture itself allowing "fluent" like uniform updates
  14075. */
  14076. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14077. /**
  14078. * Render the texture to its associated render target.
  14079. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14080. */
  14081. render(useCameraPostProcess?: boolean): void;
  14082. /**
  14083. * Clone the texture.
  14084. * @returns the cloned texture
  14085. */
  14086. clone(): ProceduralTexture;
  14087. /**
  14088. * Dispose the texture and release its asoociated resources.
  14089. */
  14090. dispose(): void;
  14091. }
  14092. }
  14093. declare module "babylonjs/Particles/baseParticleSystem" {
  14094. import { Nullable } from "babylonjs/types";
  14095. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14097. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14098. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14099. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14100. import { Scene } from "babylonjs/scene";
  14101. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14102. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14103. import { Texture } from "babylonjs/Materials/Textures/texture";
  14104. import { Animation } from "babylonjs/Animations/animation";
  14105. /**
  14106. * This represents the base class for particle system in Babylon.
  14107. * 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.
  14108. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14109. * @example https://doc.babylonjs.com/babylon101/particles
  14110. */
  14111. export class BaseParticleSystem {
  14112. /**
  14113. * Source color is added to the destination color without alpha affecting the result
  14114. */
  14115. static BLENDMODE_ONEONE: number;
  14116. /**
  14117. * Blend current color and particle color using particle’s alpha
  14118. */
  14119. static BLENDMODE_STANDARD: number;
  14120. /**
  14121. * Add current color and particle color multiplied by particle’s alpha
  14122. */
  14123. static BLENDMODE_ADD: number;
  14124. /**
  14125. * Multiply current color with particle color
  14126. */
  14127. static BLENDMODE_MULTIPLY: number;
  14128. /**
  14129. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14130. */
  14131. static BLENDMODE_MULTIPLYADD: number;
  14132. /**
  14133. * List of animations used by the particle system.
  14134. */
  14135. animations: Animation[];
  14136. /**
  14137. * The id of the Particle system.
  14138. */
  14139. id: string;
  14140. /**
  14141. * The friendly name of the Particle system.
  14142. */
  14143. name: string;
  14144. /**
  14145. * The rendering group used by the Particle system to chose when to render.
  14146. */
  14147. renderingGroupId: number;
  14148. /**
  14149. * The emitter represents the Mesh or position we are attaching the particle system to.
  14150. */
  14151. emitter: Nullable<AbstractMesh | Vector3>;
  14152. /**
  14153. * The maximum number of particles to emit per frame
  14154. */
  14155. emitRate: number;
  14156. /**
  14157. * If you want to launch only a few particles at once, that can be done, as well.
  14158. */
  14159. manualEmitCount: number;
  14160. /**
  14161. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14162. */
  14163. updateSpeed: number;
  14164. /**
  14165. * The amount of time the particle system is running (depends of the overall update speed).
  14166. */
  14167. targetStopDuration: number;
  14168. /**
  14169. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14170. */
  14171. disposeOnStop: boolean;
  14172. /**
  14173. * Minimum power of emitting particles.
  14174. */
  14175. minEmitPower: number;
  14176. /**
  14177. * Maximum power of emitting particles.
  14178. */
  14179. maxEmitPower: number;
  14180. /**
  14181. * Minimum life time of emitting particles.
  14182. */
  14183. minLifeTime: number;
  14184. /**
  14185. * Maximum life time of emitting particles.
  14186. */
  14187. maxLifeTime: number;
  14188. /**
  14189. * Minimum Size of emitting particles.
  14190. */
  14191. minSize: number;
  14192. /**
  14193. * Maximum Size of emitting particles.
  14194. */
  14195. maxSize: number;
  14196. /**
  14197. * Minimum scale of emitting particles on X axis.
  14198. */
  14199. minScaleX: number;
  14200. /**
  14201. * Maximum scale of emitting particles on X axis.
  14202. */
  14203. maxScaleX: number;
  14204. /**
  14205. * Minimum scale of emitting particles on Y axis.
  14206. */
  14207. minScaleY: number;
  14208. /**
  14209. * Maximum scale of emitting particles on Y axis.
  14210. */
  14211. maxScaleY: number;
  14212. /**
  14213. * Gets or sets the minimal initial rotation in radians.
  14214. */
  14215. minInitialRotation: number;
  14216. /**
  14217. * Gets or sets the maximal initial rotation in radians.
  14218. */
  14219. maxInitialRotation: number;
  14220. /**
  14221. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14222. */
  14223. minAngularSpeed: number;
  14224. /**
  14225. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14226. */
  14227. maxAngularSpeed: number;
  14228. /**
  14229. * The texture used to render each particle. (this can be a spritesheet)
  14230. */
  14231. particleTexture: Nullable<Texture>;
  14232. /**
  14233. * The layer mask we are rendering the particles through.
  14234. */
  14235. layerMask: number;
  14236. /**
  14237. * This can help using your own shader to render the particle system.
  14238. * The according effect will be created
  14239. */
  14240. customShader: any;
  14241. /**
  14242. * By default particle system starts as soon as they are created. This prevents the
  14243. * automatic start to happen and let you decide when to start emitting particles.
  14244. */
  14245. preventAutoStart: boolean;
  14246. private _noiseTexture;
  14247. /**
  14248. * Gets or sets a texture used to add random noise to particle positions
  14249. */
  14250. noiseTexture: Nullable<ProceduralTexture>;
  14251. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14252. noiseStrength: Vector3;
  14253. /**
  14254. * Callback triggered when the particle animation is ending.
  14255. */
  14256. onAnimationEnd: Nullable<() => void>;
  14257. /**
  14258. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14259. */
  14260. blendMode: number;
  14261. /**
  14262. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14263. * to override the particles.
  14264. */
  14265. forceDepthWrite: boolean;
  14266. /** 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 */
  14267. preWarmCycles: number;
  14268. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14269. preWarmStepOffset: number;
  14270. /**
  14271. * 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)
  14272. */
  14273. spriteCellChangeSpeed: number;
  14274. /**
  14275. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14276. */
  14277. startSpriteCellID: number;
  14278. /**
  14279. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14280. */
  14281. endSpriteCellID: number;
  14282. /**
  14283. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14284. */
  14285. spriteCellWidth: number;
  14286. /**
  14287. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14288. */
  14289. spriteCellHeight: number;
  14290. /**
  14291. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14292. */
  14293. spriteRandomStartCell: boolean;
  14294. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14295. translationPivot: Vector2;
  14296. /** @hidden */
  14297. protected _isAnimationSheetEnabled: boolean;
  14298. /**
  14299. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14300. */
  14301. beginAnimationOnStart: boolean;
  14302. /**
  14303. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14304. */
  14305. beginAnimationFrom: number;
  14306. /**
  14307. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14308. */
  14309. beginAnimationTo: number;
  14310. /**
  14311. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14312. */
  14313. beginAnimationLoop: boolean;
  14314. /**
  14315. * Gets or sets a world offset applied to all particles
  14316. */
  14317. worldOffset: Vector3;
  14318. /**
  14319. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14320. */
  14321. isAnimationSheetEnabled: boolean;
  14322. /**
  14323. * Get hosting scene
  14324. * @returns the scene
  14325. */
  14326. getScene(): Scene;
  14327. /**
  14328. * You can use gravity if you want to give an orientation to your particles.
  14329. */
  14330. gravity: Vector3;
  14331. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14332. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14333. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14334. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14335. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14336. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14337. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14338. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14339. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14340. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14341. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14342. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14343. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14344. /**
  14345. * Defines the delay in milliseconds before starting the system (0 by default)
  14346. */
  14347. startDelay: number;
  14348. /**
  14349. * Gets the current list of drag gradients.
  14350. * You must use addDragGradient and removeDragGradient to udpate this list
  14351. * @returns the list of drag gradients
  14352. */
  14353. getDragGradients(): Nullable<Array<FactorGradient>>;
  14354. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14355. limitVelocityDamping: number;
  14356. /**
  14357. * Gets the current list of limit velocity gradients.
  14358. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14359. * @returns the list of limit velocity gradients
  14360. */
  14361. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14362. /**
  14363. * Gets the current list of color gradients.
  14364. * You must use addColorGradient and removeColorGradient to udpate this list
  14365. * @returns the list of color gradients
  14366. */
  14367. getColorGradients(): Nullable<Array<ColorGradient>>;
  14368. /**
  14369. * Gets the current list of size gradients.
  14370. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14371. * @returns the list of size gradients
  14372. */
  14373. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14374. /**
  14375. * Gets the current list of color remap gradients.
  14376. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14377. * @returns the list of color remap gradients
  14378. */
  14379. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14380. /**
  14381. * Gets the current list of alpha remap gradients.
  14382. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14383. * @returns the list of alpha remap gradients
  14384. */
  14385. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14386. /**
  14387. * Gets the current list of life time gradients.
  14388. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14389. * @returns the list of life time gradients
  14390. */
  14391. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14392. /**
  14393. * Gets the current list of angular speed gradients.
  14394. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14395. * @returns the list of angular speed gradients
  14396. */
  14397. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14398. /**
  14399. * Gets the current list of velocity gradients.
  14400. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14401. * @returns the list of velocity gradients
  14402. */
  14403. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14404. /**
  14405. * Gets the current list of start size gradients.
  14406. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14407. * @returns the list of start size gradients
  14408. */
  14409. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14410. /**
  14411. * Gets the current list of emit rate gradients.
  14412. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14413. * @returns the list of emit rate gradients
  14414. */
  14415. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14416. /**
  14417. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14418. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14419. */
  14420. direction1: Vector3;
  14421. /**
  14422. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14423. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14424. */
  14425. direction2: Vector3;
  14426. /**
  14427. * 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.
  14428. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14429. */
  14430. minEmitBox: Vector3;
  14431. /**
  14432. * 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.
  14433. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14434. */
  14435. maxEmitBox: Vector3;
  14436. /**
  14437. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14438. */
  14439. color1: Color4;
  14440. /**
  14441. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14442. */
  14443. color2: Color4;
  14444. /**
  14445. * Color the particle will have at the end of its lifetime
  14446. */
  14447. colorDead: Color4;
  14448. /**
  14449. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14450. */
  14451. textureMask: Color4;
  14452. /**
  14453. * The particle emitter type defines the emitter used by the particle system.
  14454. * It can be for example box, sphere, or cone...
  14455. */
  14456. particleEmitterType: IParticleEmitterType;
  14457. /** @hidden */
  14458. _isSubEmitter: boolean;
  14459. /**
  14460. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14461. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14462. */
  14463. billboardMode: number;
  14464. protected _isBillboardBased: boolean;
  14465. /**
  14466. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14467. */
  14468. isBillboardBased: boolean;
  14469. /**
  14470. * The scene the particle system belongs to.
  14471. */
  14472. protected _scene: Scene;
  14473. /**
  14474. * Local cache of defines for image processing.
  14475. */
  14476. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14477. /**
  14478. * Default configuration related to image processing available in the standard Material.
  14479. */
  14480. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14481. /**
  14482. * Gets the image processing configuration used either in this material.
  14483. */
  14484. /**
  14485. * Sets the Default image processing configuration used either in the this material.
  14486. *
  14487. * If sets to null, the scene one is in use.
  14488. */
  14489. imageProcessingConfiguration: ImageProcessingConfiguration;
  14490. /**
  14491. * Attaches a new image processing configuration to the Standard Material.
  14492. * @param configuration
  14493. */
  14494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14495. /** @hidden */
  14496. protected _reset(): void;
  14497. /** @hidden */
  14498. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14499. /**
  14500. * Instantiates a particle system.
  14501. * 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.
  14502. * @param name The name of the particle system
  14503. */
  14504. constructor(name: string);
  14505. /**
  14506. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14509. * @returns the emitter
  14510. */
  14511. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14512. /**
  14513. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14514. * @param radius The radius of the hemisphere to emit from
  14515. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14516. * @returns the emitter
  14517. */
  14518. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14519. /**
  14520. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14521. * @param radius The radius of the sphere to emit from
  14522. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14523. * @returns the emitter
  14524. */
  14525. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14526. /**
  14527. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14528. * @param radius The radius of the sphere to emit from
  14529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14531. * @returns the emitter
  14532. */
  14533. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14534. /**
  14535. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14536. * @param radius The radius of the emission cylinder
  14537. * @param height The height of the emission cylinder
  14538. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14539. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14540. * @returns the emitter
  14541. */
  14542. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14543. /**
  14544. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14545. * @param radius The radius of the cylinder to emit from
  14546. * @param height The height of the emission cylinder
  14547. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14550. * @returns the emitter
  14551. */
  14552. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14553. /**
  14554. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14555. * @param radius The radius of the cone to emit from
  14556. * @param angle The base angle of the cone
  14557. * @returns the emitter
  14558. */
  14559. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14560. /**
  14561. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14562. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14563. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14564. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14565. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14566. * @returns the emitter
  14567. */
  14568. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14569. }
  14570. }
  14571. declare module "babylonjs/Particles/subEmitter" {
  14572. import { Scene } from "babylonjs/scene";
  14573. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14574. /**
  14575. * Type of sub emitter
  14576. */
  14577. export enum SubEmitterType {
  14578. /**
  14579. * Attached to the particle over it's lifetime
  14580. */
  14581. ATTACHED = 0,
  14582. /**
  14583. * Created when the particle dies
  14584. */
  14585. END = 1
  14586. }
  14587. /**
  14588. * Sub emitter class used to emit particles from an existing particle
  14589. */
  14590. export class SubEmitter {
  14591. /**
  14592. * the particle system to be used by the sub emitter
  14593. */
  14594. particleSystem: ParticleSystem;
  14595. /**
  14596. * Type of the submitter (Default: END)
  14597. */
  14598. type: SubEmitterType;
  14599. /**
  14600. * 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)
  14601. * Note: This only is supported when using an emitter of type Mesh
  14602. */
  14603. inheritDirection: boolean;
  14604. /**
  14605. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14606. */
  14607. inheritedVelocityAmount: number;
  14608. /**
  14609. * Creates a sub emitter
  14610. * @param particleSystem the particle system to be used by the sub emitter
  14611. */
  14612. constructor(
  14613. /**
  14614. * the particle system to be used by the sub emitter
  14615. */
  14616. particleSystem: ParticleSystem);
  14617. /**
  14618. * Clones the sub emitter
  14619. * @returns the cloned sub emitter
  14620. */
  14621. clone(): SubEmitter;
  14622. /**
  14623. * Serialize current object to a JSON object
  14624. * @returns the serialized object
  14625. */
  14626. serialize(): any;
  14627. /** @hidden */
  14628. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14629. /**
  14630. * Creates a new SubEmitter from a serialized JSON version
  14631. * @param serializationObject defines the JSON object to read from
  14632. * @param scene defines the hosting scene
  14633. * @param rootUrl defines the rootUrl for data loading
  14634. * @returns a new SubEmitter
  14635. */
  14636. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14637. /** Release associated resources */
  14638. dispose(): void;
  14639. }
  14640. }
  14641. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14642. /** @hidden */
  14643. export var clipPlaneFragmentDeclaration: {
  14644. name: string;
  14645. shader: string;
  14646. };
  14647. }
  14648. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14649. /** @hidden */
  14650. export var imageProcessingDeclaration: {
  14651. name: string;
  14652. shader: string;
  14653. };
  14654. }
  14655. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14656. /** @hidden */
  14657. export var imageProcessingFunctions: {
  14658. name: string;
  14659. shader: string;
  14660. };
  14661. }
  14662. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14663. /** @hidden */
  14664. export var clipPlaneFragment: {
  14665. name: string;
  14666. shader: string;
  14667. };
  14668. }
  14669. declare module "babylonjs/Shaders/particles.fragment" {
  14670. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14671. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14672. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14673. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14674. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14675. /** @hidden */
  14676. export var particlesPixelShader: {
  14677. name: string;
  14678. shader: string;
  14679. };
  14680. }
  14681. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14682. /** @hidden */
  14683. export var clipPlaneVertexDeclaration: {
  14684. name: string;
  14685. shader: string;
  14686. };
  14687. }
  14688. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14689. /** @hidden */
  14690. export var clipPlaneVertex: {
  14691. name: string;
  14692. shader: string;
  14693. };
  14694. }
  14695. declare module "babylonjs/Shaders/particles.vertex" {
  14696. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14697. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14698. /** @hidden */
  14699. export var particlesVertexShader: {
  14700. name: string;
  14701. shader: string;
  14702. };
  14703. }
  14704. declare module "babylonjs/Particles/particleSystem" {
  14705. import { Nullable } from "babylonjs/types";
  14706. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14707. import { Observable } from "babylonjs/Misc/observable";
  14708. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14709. import { Effect } from "babylonjs/Materials/effect";
  14710. import { Scene, IDisposable } from "babylonjs/scene";
  14711. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14712. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14713. import { Particle } from "babylonjs/Particles/particle";
  14714. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14715. import "babylonjs/Shaders/particles.fragment";
  14716. import "babylonjs/Shaders/particles.vertex";
  14717. /**
  14718. * This represents a particle system in Babylon.
  14719. * 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.
  14720. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14721. * @example https://doc.babylonjs.com/babylon101/particles
  14722. */
  14723. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14724. /**
  14725. * Billboard mode will only apply to Y axis
  14726. */
  14727. static readonly BILLBOARDMODE_Y: number;
  14728. /**
  14729. * Billboard mode will apply to all axes
  14730. */
  14731. static readonly BILLBOARDMODE_ALL: number;
  14732. /**
  14733. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14734. */
  14735. static readonly BILLBOARDMODE_STRETCHED: number;
  14736. /**
  14737. * This function can be defined to provide custom update for active particles.
  14738. * This function will be called instead of regular update (age, position, color, etc.).
  14739. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14740. */
  14741. updateFunction: (particles: Particle[]) => void;
  14742. private _emitterWorldMatrix;
  14743. /**
  14744. * This function can be defined to specify initial direction for every new particle.
  14745. * It by default use the emitterType defined function
  14746. */
  14747. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14748. /**
  14749. * This function can be defined to specify initial position for every new particle.
  14750. * It by default use the emitterType defined function
  14751. */
  14752. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14753. /**
  14754. * @hidden
  14755. */
  14756. _inheritedVelocityOffset: Vector3;
  14757. /**
  14758. * An event triggered when the system is disposed
  14759. */
  14760. onDisposeObservable: Observable<ParticleSystem>;
  14761. private _onDisposeObserver;
  14762. /**
  14763. * Sets a callback that will be triggered when the system is disposed
  14764. */
  14765. onDispose: () => void;
  14766. private _particles;
  14767. private _epsilon;
  14768. private _capacity;
  14769. private _stockParticles;
  14770. private _newPartsExcess;
  14771. private _vertexData;
  14772. private _vertexBuffer;
  14773. private _vertexBuffers;
  14774. private _spriteBuffer;
  14775. private _indexBuffer;
  14776. private _effect;
  14777. private _customEffect;
  14778. private _cachedDefines;
  14779. private _scaledColorStep;
  14780. private _colorDiff;
  14781. private _scaledDirection;
  14782. private _scaledGravity;
  14783. private _currentRenderId;
  14784. private _alive;
  14785. private _useInstancing;
  14786. private _started;
  14787. private _stopped;
  14788. private _actualFrame;
  14789. private _scaledUpdateSpeed;
  14790. private _vertexBufferSize;
  14791. /** @hidden */
  14792. _currentEmitRateGradient: Nullable<FactorGradient>;
  14793. /** @hidden */
  14794. _currentEmitRate1: number;
  14795. /** @hidden */
  14796. _currentEmitRate2: number;
  14797. /** @hidden */
  14798. _currentStartSizeGradient: Nullable<FactorGradient>;
  14799. /** @hidden */
  14800. _currentStartSize1: number;
  14801. /** @hidden */
  14802. _currentStartSize2: number;
  14803. private readonly _rawTextureWidth;
  14804. private _rampGradientsTexture;
  14805. private _useRampGradients;
  14806. /** Gets or sets a boolean indicating that ramp gradients must be used
  14807. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14808. */
  14809. useRampGradients: boolean;
  14810. /**
  14811. * 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.
  14812. * 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: [])
  14813. */
  14814. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14815. private _subEmitters;
  14816. /**
  14817. * @hidden
  14818. * If the particle systems emitter should be disposed when the particle system is disposed
  14819. */
  14820. _disposeEmitterOnDispose: boolean;
  14821. /**
  14822. * The current active Sub-systems, this property is used by the root particle system only.
  14823. */
  14824. activeSubSystems: Array<ParticleSystem>;
  14825. private _rootParticleSystem;
  14826. /**
  14827. * Gets the current list of active particles
  14828. */
  14829. readonly particles: Particle[];
  14830. /**
  14831. * Returns the string "ParticleSystem"
  14832. * @returns a string containing the class name
  14833. */
  14834. getClassName(): string;
  14835. /**
  14836. * Instantiates a particle system.
  14837. * 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.
  14838. * @param name The name of the particle system
  14839. * @param capacity The max number of particles alive at the same time
  14840. * @param scene The scene the particle system belongs to
  14841. * @param customEffect a custom effect used to change the way particles are rendered by default
  14842. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14843. * @param epsilon Offset used to render the particles
  14844. */
  14845. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14846. private _addFactorGradient;
  14847. private _removeFactorGradient;
  14848. /**
  14849. * Adds a new life time gradient
  14850. * @param gradient defines the gradient to use (between 0 and 1)
  14851. * @param factor defines the life time factor to affect to the specified gradient
  14852. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14853. * @returns the current particle system
  14854. */
  14855. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14856. /**
  14857. * Remove a specific life time gradient
  14858. * @param gradient defines the gradient to remove
  14859. * @returns the current particle system
  14860. */
  14861. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14862. /**
  14863. * Adds a new size gradient
  14864. * @param gradient defines the gradient to use (between 0 and 1)
  14865. * @param factor defines the size factor to affect to the specified gradient
  14866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14867. * @returns the current particle system
  14868. */
  14869. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14870. /**
  14871. * Remove a specific size gradient
  14872. * @param gradient defines the gradient to remove
  14873. * @returns the current particle system
  14874. */
  14875. removeSizeGradient(gradient: number): IParticleSystem;
  14876. /**
  14877. * Adds a new color remap gradient
  14878. * @param gradient defines the gradient to use (between 0 and 1)
  14879. * @param min defines the color remap minimal range
  14880. * @param max defines the color remap maximal range
  14881. * @returns the current particle system
  14882. */
  14883. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14884. /**
  14885. * Remove a specific color remap gradient
  14886. * @param gradient defines the gradient to remove
  14887. * @returns the current particle system
  14888. */
  14889. removeColorRemapGradient(gradient: number): IParticleSystem;
  14890. /**
  14891. * Adds a new alpha remap gradient
  14892. * @param gradient defines the gradient to use (between 0 and 1)
  14893. * @param min defines the alpha remap minimal range
  14894. * @param max defines the alpha remap maximal range
  14895. * @returns the current particle system
  14896. */
  14897. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14898. /**
  14899. * Remove a specific alpha remap gradient
  14900. * @param gradient defines the gradient to remove
  14901. * @returns the current particle system
  14902. */
  14903. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14904. /**
  14905. * Adds a new angular speed gradient
  14906. * @param gradient defines the gradient to use (between 0 and 1)
  14907. * @param factor defines the angular speed to affect to the specified gradient
  14908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14909. * @returns the current particle system
  14910. */
  14911. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14912. /**
  14913. * Remove a specific angular speed gradient
  14914. * @param gradient defines the gradient to remove
  14915. * @returns the current particle system
  14916. */
  14917. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14918. /**
  14919. * Adds a new velocity gradient
  14920. * @param gradient defines the gradient to use (between 0 and 1)
  14921. * @param factor defines the velocity to affect to the specified gradient
  14922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14923. * @returns the current particle system
  14924. */
  14925. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14926. /**
  14927. * Remove a specific velocity gradient
  14928. * @param gradient defines the gradient to remove
  14929. * @returns the current particle system
  14930. */
  14931. removeVelocityGradient(gradient: number): IParticleSystem;
  14932. /**
  14933. * Adds a new limit velocity gradient
  14934. * @param gradient defines the gradient to use (between 0 and 1)
  14935. * @param factor defines the limit velocity value to affect to the specified gradient
  14936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14937. * @returns the current particle system
  14938. */
  14939. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14940. /**
  14941. * Remove a specific limit velocity gradient
  14942. * @param gradient defines the gradient to remove
  14943. * @returns the current particle system
  14944. */
  14945. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14946. /**
  14947. * Adds a new drag gradient
  14948. * @param gradient defines the gradient to use (between 0 and 1)
  14949. * @param factor defines the drag value to affect to the specified gradient
  14950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14951. * @returns the current particle system
  14952. */
  14953. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14954. /**
  14955. * Remove a specific drag gradient
  14956. * @param gradient defines the gradient to remove
  14957. * @returns the current particle system
  14958. */
  14959. removeDragGradient(gradient: number): IParticleSystem;
  14960. /**
  14961. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14962. * @param gradient defines the gradient to use (between 0 and 1)
  14963. * @param factor defines the emit rate value to affect to the specified gradient
  14964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14965. * @returns the current particle system
  14966. */
  14967. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14968. /**
  14969. * Remove a specific emit rate gradient
  14970. * @param gradient defines the gradient to remove
  14971. * @returns the current particle system
  14972. */
  14973. removeEmitRateGradient(gradient: number): IParticleSystem;
  14974. /**
  14975. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14976. * @param gradient defines the gradient to use (between 0 and 1)
  14977. * @param factor defines the start size value to affect to the specified gradient
  14978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14979. * @returns the current particle system
  14980. */
  14981. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14982. /**
  14983. * Remove a specific start size gradient
  14984. * @param gradient defines the gradient to remove
  14985. * @returns the current particle system
  14986. */
  14987. removeStartSizeGradient(gradient: number): IParticleSystem;
  14988. private _createRampGradientTexture;
  14989. /**
  14990. * Gets the current list of ramp gradients.
  14991. * You must use addRampGradient and removeRampGradient to udpate this list
  14992. * @returns the list of ramp gradients
  14993. */
  14994. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14995. /**
  14996. * Adds a new ramp gradient used to remap particle colors
  14997. * @param gradient defines the gradient to use (between 0 and 1)
  14998. * @param color defines the color to affect to the specified gradient
  14999. * @returns the current particle system
  15000. */
  15001. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15002. /**
  15003. * Remove a specific ramp gradient
  15004. * @param gradient defines the gradient to remove
  15005. * @returns the current particle system
  15006. */
  15007. removeRampGradient(gradient: number): ParticleSystem;
  15008. /**
  15009. * Adds a new color gradient
  15010. * @param gradient defines the gradient to use (between 0 and 1)
  15011. * @param color1 defines the color to affect to the specified gradient
  15012. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15013. * @returns this particle system
  15014. */
  15015. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15016. /**
  15017. * Remove a specific color gradient
  15018. * @param gradient defines the gradient to remove
  15019. * @returns this particle system
  15020. */
  15021. removeColorGradient(gradient: number): IParticleSystem;
  15022. private _fetchR;
  15023. protected _reset(): void;
  15024. private _resetEffect;
  15025. private _createVertexBuffers;
  15026. private _createIndexBuffer;
  15027. /**
  15028. * Gets the maximum number of particles active at the same time.
  15029. * @returns The max number of active particles.
  15030. */
  15031. getCapacity(): number;
  15032. /**
  15033. * Gets whether there are still active particles in the system.
  15034. * @returns True if it is alive, otherwise false.
  15035. */
  15036. isAlive(): boolean;
  15037. /**
  15038. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15039. * @returns True if it has been started, otherwise false.
  15040. */
  15041. isStarted(): boolean;
  15042. private _prepareSubEmitterInternalArray;
  15043. /**
  15044. * Starts the particle system and begins to emit
  15045. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15046. */
  15047. start(delay?: number): void;
  15048. /**
  15049. * Stops the particle system.
  15050. * @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.
  15051. */
  15052. stop(stopSubEmitters?: boolean): void;
  15053. /**
  15054. * Remove all active particles
  15055. */
  15056. reset(): void;
  15057. /**
  15058. * @hidden (for internal use only)
  15059. */
  15060. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15061. /**
  15062. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15063. * Its lifetime will start back at 0.
  15064. */
  15065. recycleParticle: (particle: Particle) => void;
  15066. private _stopSubEmitters;
  15067. private _createParticle;
  15068. private _removeFromRoot;
  15069. private _emitFromParticle;
  15070. private _update;
  15071. /** @hidden */
  15072. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15073. /** @hidden */
  15074. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15075. /** @hidden */
  15076. private _getEffect;
  15077. /**
  15078. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15079. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15080. */
  15081. animate(preWarmOnly?: boolean): void;
  15082. private _appendParticleVertices;
  15083. /**
  15084. * Rebuilds the particle system.
  15085. */
  15086. rebuild(): void;
  15087. /**
  15088. * Is this system ready to be used/rendered
  15089. * @return true if the system is ready
  15090. */
  15091. isReady(): boolean;
  15092. private _render;
  15093. /**
  15094. * Renders the particle system in its current state.
  15095. * @returns the current number of particles
  15096. */
  15097. render(): number;
  15098. /**
  15099. * Disposes the particle system and free the associated resources
  15100. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15101. */
  15102. dispose(disposeTexture?: boolean): void;
  15103. /**
  15104. * Clones the particle system.
  15105. * @param name The name of the cloned object
  15106. * @param newEmitter The new emitter to use
  15107. * @returns the cloned particle system
  15108. */
  15109. clone(name: string, newEmitter: any): ParticleSystem;
  15110. /**
  15111. * Serializes the particle system to a JSON object.
  15112. * @returns the JSON object
  15113. */
  15114. serialize(): any;
  15115. /** @hidden */
  15116. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15117. /** @hidden */
  15118. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15119. /**
  15120. * Parses a JSON object to create a particle system.
  15121. * @param parsedParticleSystem The JSON object to parse
  15122. * @param scene The scene to create the particle system in
  15123. * @param rootUrl The root url to use to load external dependencies like texture
  15124. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15125. * @returns the Parsed particle system
  15126. */
  15127. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15128. }
  15129. }
  15130. declare module "babylonjs/Particles/particle" {
  15131. import { Nullable } from "babylonjs/types";
  15132. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15133. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15134. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15135. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15136. /**
  15137. * A particle represents one of the element emitted by a particle system.
  15138. * This is mainly define by its coordinates, direction, velocity and age.
  15139. */
  15140. export class Particle {
  15141. /**
  15142. * The particle system the particle belongs to.
  15143. */
  15144. particleSystem: ParticleSystem;
  15145. private static _Count;
  15146. /**
  15147. * Unique ID of the particle
  15148. */
  15149. id: number;
  15150. /**
  15151. * The world position of the particle in the scene.
  15152. */
  15153. position: Vector3;
  15154. /**
  15155. * The world direction of the particle in the scene.
  15156. */
  15157. direction: Vector3;
  15158. /**
  15159. * The color of the particle.
  15160. */
  15161. color: Color4;
  15162. /**
  15163. * The color change of the particle per step.
  15164. */
  15165. colorStep: Color4;
  15166. /**
  15167. * Defines how long will the life of the particle be.
  15168. */
  15169. lifeTime: number;
  15170. /**
  15171. * The current age of the particle.
  15172. */
  15173. age: number;
  15174. /**
  15175. * The current size of the particle.
  15176. */
  15177. size: number;
  15178. /**
  15179. * The current scale of the particle.
  15180. */
  15181. scale: Vector2;
  15182. /**
  15183. * The current angle of the particle.
  15184. */
  15185. angle: number;
  15186. /**
  15187. * Defines how fast is the angle changing.
  15188. */
  15189. angularSpeed: number;
  15190. /**
  15191. * Defines the cell index used by the particle to be rendered from a sprite.
  15192. */
  15193. cellIndex: number;
  15194. /**
  15195. * The information required to support color remapping
  15196. */
  15197. remapData: Vector4;
  15198. /** @hidden */
  15199. _randomCellOffset?: number;
  15200. /** @hidden */
  15201. _initialDirection: Nullable<Vector3>;
  15202. /** @hidden */
  15203. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15204. /** @hidden */
  15205. _initialStartSpriteCellID: number;
  15206. /** @hidden */
  15207. _initialEndSpriteCellID: number;
  15208. /** @hidden */
  15209. _currentColorGradient: Nullable<ColorGradient>;
  15210. /** @hidden */
  15211. _currentColor1: Color4;
  15212. /** @hidden */
  15213. _currentColor2: Color4;
  15214. /** @hidden */
  15215. _currentSizeGradient: Nullable<FactorGradient>;
  15216. /** @hidden */
  15217. _currentSize1: number;
  15218. /** @hidden */
  15219. _currentSize2: number;
  15220. /** @hidden */
  15221. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15222. /** @hidden */
  15223. _currentAngularSpeed1: number;
  15224. /** @hidden */
  15225. _currentAngularSpeed2: number;
  15226. /** @hidden */
  15227. _currentVelocityGradient: Nullable<FactorGradient>;
  15228. /** @hidden */
  15229. _currentVelocity1: number;
  15230. /** @hidden */
  15231. _currentVelocity2: number;
  15232. /** @hidden */
  15233. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15234. /** @hidden */
  15235. _currentLimitVelocity1: number;
  15236. /** @hidden */
  15237. _currentLimitVelocity2: number;
  15238. /** @hidden */
  15239. _currentDragGradient: Nullable<FactorGradient>;
  15240. /** @hidden */
  15241. _currentDrag1: number;
  15242. /** @hidden */
  15243. _currentDrag2: number;
  15244. /** @hidden */
  15245. _randomNoiseCoordinates1: Vector3;
  15246. /** @hidden */
  15247. _randomNoiseCoordinates2: Vector3;
  15248. /**
  15249. * Creates a new instance Particle
  15250. * @param particleSystem the particle system the particle belongs to
  15251. */
  15252. constructor(
  15253. /**
  15254. * The particle system the particle belongs to.
  15255. */
  15256. particleSystem: ParticleSystem);
  15257. private updateCellInfoFromSystem;
  15258. /**
  15259. * Defines how the sprite cell index is updated for the particle
  15260. */
  15261. updateCellIndex(): void;
  15262. /** @hidden */
  15263. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15264. /** @hidden */
  15265. _inheritParticleInfoToSubEmitters(): void;
  15266. /** @hidden */
  15267. _reset(): void;
  15268. /**
  15269. * Copy the properties of particle to another one.
  15270. * @param other the particle to copy the information to.
  15271. */
  15272. copyTo(other: Particle): void;
  15273. }
  15274. }
  15275. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15276. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15277. import { Effect } from "babylonjs/Materials/effect";
  15278. import { Particle } from "babylonjs/Particles/particle";
  15279. /**
  15280. * Particle emitter represents a volume emitting particles.
  15281. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15282. */
  15283. export interface IParticleEmitterType {
  15284. /**
  15285. * Called by the particle System when the direction is computed for the created particle.
  15286. * @param worldMatrix is the world matrix of the particle system
  15287. * @param directionToUpdate is the direction vector to update with the result
  15288. * @param particle is the particle we are computed the direction for
  15289. */
  15290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15291. /**
  15292. * Called by the particle System when the position is computed for the created particle.
  15293. * @param worldMatrix is the world matrix of the particle system
  15294. * @param positionToUpdate is the position vector to update with the result
  15295. * @param particle is the particle we are computed the position for
  15296. */
  15297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15298. /**
  15299. * Clones the current emitter and returns a copy of it
  15300. * @returns the new emitter
  15301. */
  15302. clone(): IParticleEmitterType;
  15303. /**
  15304. * Called by the GPUParticleSystem to setup the update shader
  15305. * @param effect defines the update shader
  15306. */
  15307. applyToShader(effect: Effect): void;
  15308. /**
  15309. * Returns a string to use to update the GPU particles update shader
  15310. * @returns the effect defines string
  15311. */
  15312. getEffectDefines(): string;
  15313. /**
  15314. * Returns a string representing the class name
  15315. * @returns a string containing the class name
  15316. */
  15317. getClassName(): string;
  15318. /**
  15319. * Serializes the particle system to a JSON object.
  15320. * @returns the JSON object
  15321. */
  15322. serialize(): any;
  15323. /**
  15324. * Parse properties from a JSON object
  15325. * @param serializationObject defines the JSON object
  15326. */
  15327. parse(serializationObject: any): void;
  15328. }
  15329. }
  15330. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15331. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15332. import { Effect } from "babylonjs/Materials/effect";
  15333. import { Particle } from "babylonjs/Particles/particle";
  15334. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15335. /**
  15336. * Particle emitter emitting particles from the inside of a box.
  15337. * It emits the particles randomly between 2 given directions.
  15338. */
  15339. export class BoxParticleEmitter implements IParticleEmitterType {
  15340. /**
  15341. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15342. */
  15343. direction1: Vector3;
  15344. /**
  15345. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15346. */
  15347. direction2: Vector3;
  15348. /**
  15349. * 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.
  15350. */
  15351. minEmitBox: Vector3;
  15352. /**
  15353. * 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.
  15354. */
  15355. maxEmitBox: Vector3;
  15356. /**
  15357. * Creates a new instance BoxParticleEmitter
  15358. */
  15359. constructor();
  15360. /**
  15361. * Called by the particle System when the direction is computed for the created particle.
  15362. * @param worldMatrix is the world matrix of the particle system
  15363. * @param directionToUpdate is the direction vector to update with the result
  15364. * @param particle is the particle we are computed the direction for
  15365. */
  15366. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15367. /**
  15368. * Called by the particle System when the position is computed for the created particle.
  15369. * @param worldMatrix is the world matrix of the particle system
  15370. * @param positionToUpdate is the position vector to update with the result
  15371. * @param particle is the particle we are computed the position for
  15372. */
  15373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15374. /**
  15375. * Clones the current emitter and returns a copy of it
  15376. * @returns the new emitter
  15377. */
  15378. clone(): BoxParticleEmitter;
  15379. /**
  15380. * Called by the GPUParticleSystem to setup the update shader
  15381. * @param effect defines the update shader
  15382. */
  15383. applyToShader(effect: Effect): void;
  15384. /**
  15385. * Returns a string to use to update the GPU particles update shader
  15386. * @returns a string containng the defines string
  15387. */
  15388. getEffectDefines(): string;
  15389. /**
  15390. * Returns the string "BoxParticleEmitter"
  15391. * @returns a string containing the class name
  15392. */
  15393. getClassName(): string;
  15394. /**
  15395. * Serializes the particle system to a JSON object.
  15396. * @returns the JSON object
  15397. */
  15398. serialize(): any;
  15399. /**
  15400. * Parse properties from a JSON object
  15401. * @param serializationObject defines the JSON object
  15402. */
  15403. parse(serializationObject: any): void;
  15404. }
  15405. }
  15406. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15407. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15408. import { Effect } from "babylonjs/Materials/effect";
  15409. import { Particle } from "babylonjs/Particles/particle";
  15410. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15411. /**
  15412. * Particle emitter emitting particles from the inside of a cone.
  15413. * It emits the particles alongside the cone volume from the base to the particle.
  15414. * The emission direction might be randomized.
  15415. */
  15416. export class ConeParticleEmitter implements IParticleEmitterType {
  15417. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15418. directionRandomizer: number;
  15419. private _radius;
  15420. private _angle;
  15421. private _height;
  15422. /**
  15423. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15424. */
  15425. radiusRange: number;
  15426. /**
  15427. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15428. */
  15429. heightRange: number;
  15430. /**
  15431. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15432. */
  15433. emitFromSpawnPointOnly: boolean;
  15434. /**
  15435. * Gets or sets the radius of the emission cone
  15436. */
  15437. radius: number;
  15438. /**
  15439. * Gets or sets the angle of the emission cone
  15440. */
  15441. angle: number;
  15442. private _buildHeight;
  15443. /**
  15444. * Creates a new instance ConeParticleEmitter
  15445. * @param radius the radius of the emission cone (1 by default)
  15446. * @param angle the cone base angle (PI by default)
  15447. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15448. */
  15449. constructor(radius?: number, angle?: number,
  15450. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15451. directionRandomizer?: number);
  15452. /**
  15453. * Called by the particle System when the direction is computed for the created particle.
  15454. * @param worldMatrix is the world matrix of the particle system
  15455. * @param directionToUpdate is the direction vector to update with the result
  15456. * @param particle is the particle we are computed the direction for
  15457. */
  15458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15459. /**
  15460. * Called by the particle System when the position is computed for the created particle.
  15461. * @param worldMatrix is the world matrix of the particle system
  15462. * @param positionToUpdate is the position vector to update with the result
  15463. * @param particle is the particle we are computed the position for
  15464. */
  15465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15466. /**
  15467. * Clones the current emitter and returns a copy of it
  15468. * @returns the new emitter
  15469. */
  15470. clone(): ConeParticleEmitter;
  15471. /**
  15472. * Called by the GPUParticleSystem to setup the update shader
  15473. * @param effect defines the update shader
  15474. */
  15475. applyToShader(effect: Effect): void;
  15476. /**
  15477. * Returns a string to use to update the GPU particles update shader
  15478. * @returns a string containng the defines string
  15479. */
  15480. getEffectDefines(): string;
  15481. /**
  15482. * Returns the string "ConeParticleEmitter"
  15483. * @returns a string containing the class name
  15484. */
  15485. getClassName(): string;
  15486. /**
  15487. * Serializes the particle system to a JSON object.
  15488. * @returns the JSON object
  15489. */
  15490. serialize(): any;
  15491. /**
  15492. * Parse properties from a JSON object
  15493. * @param serializationObject defines the JSON object
  15494. */
  15495. parse(serializationObject: any): void;
  15496. }
  15497. }
  15498. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15499. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15500. import { Effect } from "babylonjs/Materials/effect";
  15501. import { Particle } from "babylonjs/Particles/particle";
  15502. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15503. /**
  15504. * Particle emitter emitting particles from the inside of a cylinder.
  15505. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15506. */
  15507. export class CylinderParticleEmitter implements IParticleEmitterType {
  15508. /**
  15509. * The radius of the emission cylinder.
  15510. */
  15511. radius: number;
  15512. /**
  15513. * The height of the emission cylinder.
  15514. */
  15515. height: number;
  15516. /**
  15517. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15518. */
  15519. radiusRange: number;
  15520. /**
  15521. * How much to randomize the particle direction [0-1].
  15522. */
  15523. directionRandomizer: number;
  15524. /**
  15525. * Creates a new instance CylinderParticleEmitter
  15526. * @param radius the radius of the emission cylinder (1 by default)
  15527. * @param height the height of the emission cylinder (1 by default)
  15528. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15529. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15530. */
  15531. constructor(
  15532. /**
  15533. * The radius of the emission cylinder.
  15534. */
  15535. radius?: number,
  15536. /**
  15537. * The height of the emission cylinder.
  15538. */
  15539. height?: number,
  15540. /**
  15541. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15542. */
  15543. radiusRange?: number,
  15544. /**
  15545. * How much to randomize the particle direction [0-1].
  15546. */
  15547. directionRandomizer?: number);
  15548. /**
  15549. * Called by the particle System when the direction is computed for the created particle.
  15550. * @param worldMatrix is the world matrix of the particle system
  15551. * @param directionToUpdate is the direction vector to update with the result
  15552. * @param particle is the particle we are computed the direction for
  15553. */
  15554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15555. /**
  15556. * Called by the particle System when the position is computed for the created particle.
  15557. * @param worldMatrix is the world matrix of the particle system
  15558. * @param positionToUpdate is the position vector to update with the result
  15559. * @param particle is the particle we are computed the position for
  15560. */
  15561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15562. /**
  15563. * Clones the current emitter and returns a copy of it
  15564. * @returns the new emitter
  15565. */
  15566. clone(): CylinderParticleEmitter;
  15567. /**
  15568. * Called by the GPUParticleSystem to setup the update shader
  15569. * @param effect defines the update shader
  15570. */
  15571. applyToShader(effect: Effect): void;
  15572. /**
  15573. * Returns a string to use to update the GPU particles update shader
  15574. * @returns a string containng the defines string
  15575. */
  15576. getEffectDefines(): string;
  15577. /**
  15578. * Returns the string "CylinderParticleEmitter"
  15579. * @returns a string containing the class name
  15580. */
  15581. getClassName(): string;
  15582. /**
  15583. * Serializes the particle system to a JSON object.
  15584. * @returns the JSON object
  15585. */
  15586. serialize(): any;
  15587. /**
  15588. * Parse properties from a JSON object
  15589. * @param serializationObject defines the JSON object
  15590. */
  15591. parse(serializationObject: any): void;
  15592. }
  15593. /**
  15594. * Particle emitter emitting particles from the inside of a cylinder.
  15595. * It emits the particles randomly between two vectors.
  15596. */
  15597. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15598. /**
  15599. * The min limit of the emission direction.
  15600. */
  15601. direction1: Vector3;
  15602. /**
  15603. * The max limit of the emission direction.
  15604. */
  15605. direction2: Vector3;
  15606. /**
  15607. * Creates a new instance CylinderDirectedParticleEmitter
  15608. * @param radius the radius of the emission cylinder (1 by default)
  15609. * @param height the height of the emission cylinder (1 by default)
  15610. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15611. * @param direction1 the min limit of the emission direction (up vector by default)
  15612. * @param direction2 the max limit of the emission direction (up vector by default)
  15613. */
  15614. constructor(radius?: number, height?: number, radiusRange?: number,
  15615. /**
  15616. * The min limit of the emission direction.
  15617. */
  15618. direction1?: Vector3,
  15619. /**
  15620. * The max limit of the emission direction.
  15621. */
  15622. direction2?: Vector3);
  15623. /**
  15624. * Called by the particle System when the direction is computed for the created particle.
  15625. * @param worldMatrix is the world matrix of the particle system
  15626. * @param directionToUpdate is the direction vector to update with the result
  15627. * @param particle is the particle we are computed the direction for
  15628. */
  15629. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15630. /**
  15631. * Clones the current emitter and returns a copy of it
  15632. * @returns the new emitter
  15633. */
  15634. clone(): CylinderDirectedParticleEmitter;
  15635. /**
  15636. * Called by the GPUParticleSystem to setup the update shader
  15637. * @param effect defines the update shader
  15638. */
  15639. applyToShader(effect: Effect): void;
  15640. /**
  15641. * Returns a string to use to update the GPU particles update shader
  15642. * @returns a string containng the defines string
  15643. */
  15644. getEffectDefines(): string;
  15645. /**
  15646. * Returns the string "CylinderDirectedParticleEmitter"
  15647. * @returns a string containing the class name
  15648. */
  15649. getClassName(): string;
  15650. /**
  15651. * Serializes the particle system to a JSON object.
  15652. * @returns the JSON object
  15653. */
  15654. serialize(): any;
  15655. /**
  15656. * Parse properties from a JSON object
  15657. * @param serializationObject defines the JSON object
  15658. */
  15659. parse(serializationObject: any): void;
  15660. }
  15661. }
  15662. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15663. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15664. import { Effect } from "babylonjs/Materials/effect";
  15665. import { Particle } from "babylonjs/Particles/particle";
  15666. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15667. /**
  15668. * Particle emitter emitting particles from the inside of a hemisphere.
  15669. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15670. */
  15671. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15672. /**
  15673. * The radius of the emission hemisphere.
  15674. */
  15675. radius: number;
  15676. /**
  15677. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15678. */
  15679. radiusRange: number;
  15680. /**
  15681. * How much to randomize the particle direction [0-1].
  15682. */
  15683. directionRandomizer: number;
  15684. /**
  15685. * Creates a new instance HemisphericParticleEmitter
  15686. * @param radius the radius of the emission hemisphere (1 by default)
  15687. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15688. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15689. */
  15690. constructor(
  15691. /**
  15692. * The radius of the emission hemisphere.
  15693. */
  15694. radius?: number,
  15695. /**
  15696. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15697. */
  15698. radiusRange?: number,
  15699. /**
  15700. * How much to randomize the particle direction [0-1].
  15701. */
  15702. directionRandomizer?: number);
  15703. /**
  15704. * Called by the particle System when the direction is computed for the created particle.
  15705. * @param worldMatrix is the world matrix of the particle system
  15706. * @param directionToUpdate is the direction vector to update with the result
  15707. * @param particle is the particle we are computed the direction for
  15708. */
  15709. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15710. /**
  15711. * Called by the particle System when the position is computed for the created particle.
  15712. * @param worldMatrix is the world matrix of the particle system
  15713. * @param positionToUpdate is the position vector to update with the result
  15714. * @param particle is the particle we are computed the position for
  15715. */
  15716. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15717. /**
  15718. * Clones the current emitter and returns a copy of it
  15719. * @returns the new emitter
  15720. */
  15721. clone(): HemisphericParticleEmitter;
  15722. /**
  15723. * Called by the GPUParticleSystem to setup the update shader
  15724. * @param effect defines the update shader
  15725. */
  15726. applyToShader(effect: Effect): void;
  15727. /**
  15728. * Returns a string to use to update the GPU particles update shader
  15729. * @returns a string containng the defines string
  15730. */
  15731. getEffectDefines(): string;
  15732. /**
  15733. * Returns the string "HemisphericParticleEmitter"
  15734. * @returns a string containing the class name
  15735. */
  15736. getClassName(): string;
  15737. /**
  15738. * Serializes the particle system to a JSON object.
  15739. * @returns the JSON object
  15740. */
  15741. serialize(): any;
  15742. /**
  15743. * Parse properties from a JSON object
  15744. * @param serializationObject defines the JSON object
  15745. */
  15746. parse(serializationObject: any): void;
  15747. }
  15748. }
  15749. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15750. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15751. import { Effect } from "babylonjs/Materials/effect";
  15752. import { Particle } from "babylonjs/Particles/particle";
  15753. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15754. /**
  15755. * Particle emitter emitting particles from a point.
  15756. * It emits the particles randomly between 2 given directions.
  15757. */
  15758. export class PointParticleEmitter implements IParticleEmitterType {
  15759. /**
  15760. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15761. */
  15762. direction1: Vector3;
  15763. /**
  15764. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15765. */
  15766. direction2: Vector3;
  15767. /**
  15768. * Creates a new instance PointParticleEmitter
  15769. */
  15770. constructor();
  15771. /**
  15772. * Called by the particle System when the direction is computed for the created particle.
  15773. * @param worldMatrix is the world matrix of the particle system
  15774. * @param directionToUpdate is the direction vector to update with the result
  15775. * @param particle is the particle we are computed the direction for
  15776. */
  15777. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15778. /**
  15779. * Called by the particle System when the position is computed for the created particle.
  15780. * @param worldMatrix is the world matrix of the particle system
  15781. * @param positionToUpdate is the position vector to update with the result
  15782. * @param particle is the particle we are computed the position for
  15783. */
  15784. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15785. /**
  15786. * Clones the current emitter and returns a copy of it
  15787. * @returns the new emitter
  15788. */
  15789. clone(): PointParticleEmitter;
  15790. /**
  15791. * Called by the GPUParticleSystem to setup the update shader
  15792. * @param effect defines the update shader
  15793. */
  15794. applyToShader(effect: Effect): void;
  15795. /**
  15796. * Returns a string to use to update the GPU particles update shader
  15797. * @returns a string containng the defines string
  15798. */
  15799. getEffectDefines(): string;
  15800. /**
  15801. * Returns the string "PointParticleEmitter"
  15802. * @returns a string containing the class name
  15803. */
  15804. getClassName(): string;
  15805. /**
  15806. * Serializes the particle system to a JSON object.
  15807. * @returns the JSON object
  15808. */
  15809. serialize(): any;
  15810. /**
  15811. * Parse properties from a JSON object
  15812. * @param serializationObject defines the JSON object
  15813. */
  15814. parse(serializationObject: any): void;
  15815. }
  15816. }
  15817. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15818. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15819. import { Effect } from "babylonjs/Materials/effect";
  15820. import { Particle } from "babylonjs/Particles/particle";
  15821. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15822. /**
  15823. * Particle emitter emitting particles from the inside of a sphere.
  15824. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15825. */
  15826. export class SphereParticleEmitter implements IParticleEmitterType {
  15827. /**
  15828. * The radius of the emission sphere.
  15829. */
  15830. radius: number;
  15831. /**
  15832. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15833. */
  15834. radiusRange: number;
  15835. /**
  15836. * How much to randomize the particle direction [0-1].
  15837. */
  15838. directionRandomizer: number;
  15839. /**
  15840. * Creates a new instance SphereParticleEmitter
  15841. * @param radius the radius of the emission sphere (1 by default)
  15842. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15843. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15844. */
  15845. constructor(
  15846. /**
  15847. * The radius of the emission sphere.
  15848. */
  15849. radius?: number,
  15850. /**
  15851. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15852. */
  15853. radiusRange?: number,
  15854. /**
  15855. * How much to randomize the particle direction [0-1].
  15856. */
  15857. directionRandomizer?: number);
  15858. /**
  15859. * Called by the particle System when the direction is computed for the created particle.
  15860. * @param worldMatrix is the world matrix of the particle system
  15861. * @param directionToUpdate is the direction vector to update with the result
  15862. * @param particle is the particle we are computed the direction for
  15863. */
  15864. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15865. /**
  15866. * Called by the particle System when the position is computed for the created particle.
  15867. * @param worldMatrix is the world matrix of the particle system
  15868. * @param positionToUpdate is the position vector to update with the result
  15869. * @param particle is the particle we are computed the position for
  15870. */
  15871. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15872. /**
  15873. * Clones the current emitter and returns a copy of it
  15874. * @returns the new emitter
  15875. */
  15876. clone(): SphereParticleEmitter;
  15877. /**
  15878. * Called by the GPUParticleSystem to setup the update shader
  15879. * @param effect defines the update shader
  15880. */
  15881. applyToShader(effect: Effect): void;
  15882. /**
  15883. * Returns a string to use to update the GPU particles update shader
  15884. * @returns a string containng the defines string
  15885. */
  15886. getEffectDefines(): string;
  15887. /**
  15888. * Returns the string "SphereParticleEmitter"
  15889. * @returns a string containing the class name
  15890. */
  15891. getClassName(): string;
  15892. /**
  15893. * Serializes the particle system to a JSON object.
  15894. * @returns the JSON object
  15895. */
  15896. serialize(): any;
  15897. /**
  15898. * Parse properties from a JSON object
  15899. * @param serializationObject defines the JSON object
  15900. */
  15901. parse(serializationObject: any): void;
  15902. }
  15903. /**
  15904. * Particle emitter emitting particles from the inside of a sphere.
  15905. * It emits the particles randomly between two vectors.
  15906. */
  15907. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15908. /**
  15909. * The min limit of the emission direction.
  15910. */
  15911. direction1: Vector3;
  15912. /**
  15913. * The max limit of the emission direction.
  15914. */
  15915. direction2: Vector3;
  15916. /**
  15917. * Creates a new instance SphereDirectedParticleEmitter
  15918. * @param radius the radius of the emission sphere (1 by default)
  15919. * @param direction1 the min limit of the emission direction (up vector by default)
  15920. * @param direction2 the max limit of the emission direction (up vector by default)
  15921. */
  15922. constructor(radius?: number,
  15923. /**
  15924. * The min limit of the emission direction.
  15925. */
  15926. direction1?: Vector3,
  15927. /**
  15928. * The max limit of the emission direction.
  15929. */
  15930. direction2?: Vector3);
  15931. /**
  15932. * Called by the particle System when the direction is computed for the created particle.
  15933. * @param worldMatrix is the world matrix of the particle system
  15934. * @param directionToUpdate is the direction vector to update with the result
  15935. * @param particle is the particle we are computed the direction for
  15936. */
  15937. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15938. /**
  15939. * Clones the current emitter and returns a copy of it
  15940. * @returns the new emitter
  15941. */
  15942. clone(): SphereDirectedParticleEmitter;
  15943. /**
  15944. * Called by the GPUParticleSystem to setup the update shader
  15945. * @param effect defines the update shader
  15946. */
  15947. applyToShader(effect: Effect): void;
  15948. /**
  15949. * Returns a string to use to update the GPU particles update shader
  15950. * @returns a string containng the defines string
  15951. */
  15952. getEffectDefines(): string;
  15953. /**
  15954. * Returns the string "SphereDirectedParticleEmitter"
  15955. * @returns a string containing the class name
  15956. */
  15957. getClassName(): string;
  15958. /**
  15959. * Serializes the particle system to a JSON object.
  15960. * @returns the JSON object
  15961. */
  15962. serialize(): any;
  15963. /**
  15964. * Parse properties from a JSON object
  15965. * @param serializationObject defines the JSON object
  15966. */
  15967. parse(serializationObject: any): void;
  15968. }
  15969. }
  15970. declare module "babylonjs/Particles/EmitterTypes/index" {
  15971. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15972. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15973. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15974. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15975. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15976. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15977. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15978. }
  15979. declare module "babylonjs/Particles/IParticleSystem" {
  15980. import { Nullable } from "babylonjs/types";
  15981. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15983. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15984. import { Texture } from "babylonjs/Materials/Textures/texture";
  15985. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15986. import { Scene } from "babylonjs/scene";
  15987. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15988. import { Animation } from "babylonjs/Animations/animation";
  15989. /**
  15990. * Interface representing a particle system in Babylon.js.
  15991. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15992. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15993. */
  15994. export interface IParticleSystem {
  15995. /**
  15996. * List of animations used by the particle system.
  15997. */
  15998. animations: Animation[];
  15999. /**
  16000. * The id of the Particle system.
  16001. */
  16002. id: string;
  16003. /**
  16004. * The name of the Particle system.
  16005. */
  16006. name: string;
  16007. /**
  16008. * The emitter represents the Mesh or position we are attaching the particle system to.
  16009. */
  16010. emitter: Nullable<AbstractMesh | Vector3>;
  16011. /**
  16012. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16013. */
  16014. isBillboardBased: boolean;
  16015. /**
  16016. * The rendering group used by the Particle system to chose when to render.
  16017. */
  16018. renderingGroupId: number;
  16019. /**
  16020. * The layer mask we are rendering the particles through.
  16021. */
  16022. layerMask: number;
  16023. /**
  16024. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16025. */
  16026. updateSpeed: number;
  16027. /**
  16028. * The amount of time the particle system is running (depends of the overall update speed).
  16029. */
  16030. targetStopDuration: number;
  16031. /**
  16032. * The texture used to render each particle. (this can be a spritesheet)
  16033. */
  16034. particleTexture: Nullable<Texture>;
  16035. /**
  16036. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16037. */
  16038. blendMode: number;
  16039. /**
  16040. * Minimum life time of emitting particles.
  16041. */
  16042. minLifeTime: number;
  16043. /**
  16044. * Maximum life time of emitting particles.
  16045. */
  16046. maxLifeTime: number;
  16047. /**
  16048. * Minimum Size of emitting particles.
  16049. */
  16050. minSize: number;
  16051. /**
  16052. * Maximum Size of emitting particles.
  16053. */
  16054. maxSize: number;
  16055. /**
  16056. * Minimum scale of emitting particles on X axis.
  16057. */
  16058. minScaleX: number;
  16059. /**
  16060. * Maximum scale of emitting particles on X axis.
  16061. */
  16062. maxScaleX: number;
  16063. /**
  16064. * Minimum scale of emitting particles on Y axis.
  16065. */
  16066. minScaleY: number;
  16067. /**
  16068. * Maximum scale of emitting particles on Y axis.
  16069. */
  16070. maxScaleY: number;
  16071. /**
  16072. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16073. */
  16074. color1: Color4;
  16075. /**
  16076. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16077. */
  16078. color2: Color4;
  16079. /**
  16080. * Color the particle will have at the end of its lifetime.
  16081. */
  16082. colorDead: Color4;
  16083. /**
  16084. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16085. */
  16086. emitRate: number;
  16087. /**
  16088. * You can use gravity if you want to give an orientation to your particles.
  16089. */
  16090. gravity: Vector3;
  16091. /**
  16092. * Minimum power of emitting particles.
  16093. */
  16094. minEmitPower: number;
  16095. /**
  16096. * Maximum power of emitting particles.
  16097. */
  16098. maxEmitPower: number;
  16099. /**
  16100. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16101. */
  16102. minAngularSpeed: number;
  16103. /**
  16104. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16105. */
  16106. maxAngularSpeed: number;
  16107. /**
  16108. * Gets or sets the minimal initial rotation in radians.
  16109. */
  16110. minInitialRotation: number;
  16111. /**
  16112. * Gets or sets the maximal initial rotation in radians.
  16113. */
  16114. maxInitialRotation: number;
  16115. /**
  16116. * The particle emitter type defines the emitter used by the particle system.
  16117. * It can be for example box, sphere, or cone...
  16118. */
  16119. particleEmitterType: Nullable<IParticleEmitterType>;
  16120. /**
  16121. * Defines the delay in milliseconds before starting the system (0 by default)
  16122. */
  16123. startDelay: number;
  16124. /**
  16125. * 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
  16126. */
  16127. preWarmCycles: number;
  16128. /**
  16129. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16130. */
  16131. preWarmStepOffset: number;
  16132. /**
  16133. * 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)
  16134. */
  16135. spriteCellChangeSpeed: number;
  16136. /**
  16137. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16138. */
  16139. startSpriteCellID: number;
  16140. /**
  16141. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16142. */
  16143. endSpriteCellID: number;
  16144. /**
  16145. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16146. */
  16147. spriteCellWidth: number;
  16148. /**
  16149. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16150. */
  16151. spriteCellHeight: number;
  16152. /**
  16153. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16154. */
  16155. spriteRandomStartCell: boolean;
  16156. /**
  16157. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16158. */
  16159. isAnimationSheetEnabled: boolean;
  16160. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16161. translationPivot: Vector2;
  16162. /**
  16163. * Gets or sets a texture used to add random noise to particle positions
  16164. */
  16165. noiseTexture: Nullable<BaseTexture>;
  16166. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16167. noiseStrength: Vector3;
  16168. /**
  16169. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16170. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16171. */
  16172. billboardMode: number;
  16173. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16174. limitVelocityDamping: number;
  16175. /**
  16176. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16177. */
  16178. beginAnimationOnStart: boolean;
  16179. /**
  16180. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16181. */
  16182. beginAnimationFrom: number;
  16183. /**
  16184. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16185. */
  16186. beginAnimationTo: number;
  16187. /**
  16188. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16189. */
  16190. beginAnimationLoop: boolean;
  16191. /**
  16192. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16193. */
  16194. disposeOnStop: boolean;
  16195. /**
  16196. * Gets the maximum number of particles active at the same time.
  16197. * @returns The max number of active particles.
  16198. */
  16199. getCapacity(): number;
  16200. /**
  16201. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16202. * @returns True if it has been started, otherwise false.
  16203. */
  16204. isStarted(): boolean;
  16205. /**
  16206. * Animates the particle system for this frame.
  16207. */
  16208. animate(): void;
  16209. /**
  16210. * Renders the particle system in its current state.
  16211. * @returns the current number of particles
  16212. */
  16213. render(): number;
  16214. /**
  16215. * Dispose the particle system and frees its associated resources.
  16216. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16217. */
  16218. dispose(disposeTexture?: boolean): void;
  16219. /**
  16220. * Clones the particle system.
  16221. * @param name The name of the cloned object
  16222. * @param newEmitter The new emitter to use
  16223. * @returns the cloned particle system
  16224. */
  16225. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16226. /**
  16227. * Serializes the particle system to a JSON object.
  16228. * @returns the JSON object
  16229. */
  16230. serialize(): any;
  16231. /**
  16232. * Rebuild the particle system
  16233. */
  16234. rebuild(): void;
  16235. /**
  16236. * Starts the particle system and begins to emit
  16237. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16238. */
  16239. start(delay?: number): void;
  16240. /**
  16241. * Stops the particle system.
  16242. */
  16243. stop(): void;
  16244. /**
  16245. * Remove all active particles
  16246. */
  16247. reset(): void;
  16248. /**
  16249. * Is this system ready to be used/rendered
  16250. * @return true if the system is ready
  16251. */
  16252. isReady(): boolean;
  16253. /**
  16254. * Adds a new color gradient
  16255. * @param gradient defines the gradient to use (between 0 and 1)
  16256. * @param color1 defines the color to affect to the specified gradient
  16257. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16258. * @returns the current particle system
  16259. */
  16260. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16261. /**
  16262. * Remove a specific color gradient
  16263. * @param gradient defines the gradient to remove
  16264. * @returns the current particle system
  16265. */
  16266. removeColorGradient(gradient: number): IParticleSystem;
  16267. /**
  16268. * Adds a new size gradient
  16269. * @param gradient defines the gradient to use (between 0 and 1)
  16270. * @param factor defines the size factor to affect to the specified gradient
  16271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16272. * @returns the current particle system
  16273. */
  16274. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16275. /**
  16276. * Remove a specific size gradient
  16277. * @param gradient defines the gradient to remove
  16278. * @returns the current particle system
  16279. */
  16280. removeSizeGradient(gradient: number): IParticleSystem;
  16281. /**
  16282. * Gets the current list of color gradients.
  16283. * You must use addColorGradient and removeColorGradient to udpate this list
  16284. * @returns the list of color gradients
  16285. */
  16286. getColorGradients(): Nullable<Array<ColorGradient>>;
  16287. /**
  16288. * Gets the current list of size gradients.
  16289. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16290. * @returns the list of size gradients
  16291. */
  16292. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16293. /**
  16294. * Gets the current list of angular speed gradients.
  16295. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16296. * @returns the list of angular speed gradients
  16297. */
  16298. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16299. /**
  16300. * Adds a new angular speed gradient
  16301. * @param gradient defines the gradient to use (between 0 and 1)
  16302. * @param factor defines the angular speed to affect to the specified gradient
  16303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16304. * @returns the current particle system
  16305. */
  16306. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16307. /**
  16308. * Remove a specific angular speed gradient
  16309. * @param gradient defines the gradient to remove
  16310. * @returns the current particle system
  16311. */
  16312. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16313. /**
  16314. * Gets the current list of velocity gradients.
  16315. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16316. * @returns the list of velocity gradients
  16317. */
  16318. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16319. /**
  16320. * Adds a new velocity gradient
  16321. * @param gradient defines the gradient to use (between 0 and 1)
  16322. * @param factor defines the velocity to affect to the specified gradient
  16323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16324. * @returns the current particle system
  16325. */
  16326. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16327. /**
  16328. * Remove a specific velocity gradient
  16329. * @param gradient defines the gradient to remove
  16330. * @returns the current particle system
  16331. */
  16332. removeVelocityGradient(gradient: number): IParticleSystem;
  16333. /**
  16334. * Gets the current list of limit velocity gradients.
  16335. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16336. * @returns the list of limit velocity gradients
  16337. */
  16338. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16339. /**
  16340. * Adds a new limit velocity gradient
  16341. * @param gradient defines the gradient to use (between 0 and 1)
  16342. * @param factor defines the limit velocity to affect to the specified gradient
  16343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16344. * @returns the current particle system
  16345. */
  16346. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16347. /**
  16348. * Remove a specific limit velocity gradient
  16349. * @param gradient defines the gradient to remove
  16350. * @returns the current particle system
  16351. */
  16352. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16353. /**
  16354. * Adds a new drag gradient
  16355. * @param gradient defines the gradient to use (between 0 and 1)
  16356. * @param factor defines the drag to affect to the specified gradient
  16357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16358. * @returns the current particle system
  16359. */
  16360. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16361. /**
  16362. * Remove a specific drag gradient
  16363. * @param gradient defines the gradient to remove
  16364. * @returns the current particle system
  16365. */
  16366. removeDragGradient(gradient: number): IParticleSystem;
  16367. /**
  16368. * Gets the current list of drag gradients.
  16369. * You must use addDragGradient and removeDragGradient to udpate this list
  16370. * @returns the list of drag gradients
  16371. */
  16372. getDragGradients(): Nullable<Array<FactorGradient>>;
  16373. /**
  16374. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16375. * @param gradient defines the gradient to use (between 0 and 1)
  16376. * @param factor defines the emit rate to affect to the specified gradient
  16377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16378. * @returns the current particle system
  16379. */
  16380. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16381. /**
  16382. * Remove a specific emit rate gradient
  16383. * @param gradient defines the gradient to remove
  16384. * @returns the current particle system
  16385. */
  16386. removeEmitRateGradient(gradient: number): IParticleSystem;
  16387. /**
  16388. * Gets the current list of emit rate gradients.
  16389. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16390. * @returns the list of emit rate gradients
  16391. */
  16392. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16393. /**
  16394. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16395. * @param gradient defines the gradient to use (between 0 and 1)
  16396. * @param factor defines the start size to affect to the specified gradient
  16397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16398. * @returns the current particle system
  16399. */
  16400. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16401. /**
  16402. * Remove a specific start size gradient
  16403. * @param gradient defines the gradient to remove
  16404. * @returns the current particle system
  16405. */
  16406. removeStartSizeGradient(gradient: number): IParticleSystem;
  16407. /**
  16408. * Gets the current list of start size gradients.
  16409. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16410. * @returns the list of start size gradients
  16411. */
  16412. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16413. /**
  16414. * Adds a new life time gradient
  16415. * @param gradient defines the gradient to use (between 0 and 1)
  16416. * @param factor defines the life time factor to affect to the specified gradient
  16417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16418. * @returns the current particle system
  16419. */
  16420. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16421. /**
  16422. * Remove a specific life time gradient
  16423. * @param gradient defines the gradient to remove
  16424. * @returns the current particle system
  16425. */
  16426. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16427. /**
  16428. * Gets the current list of life time gradients.
  16429. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16430. * @returns the list of life time gradients
  16431. */
  16432. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16433. /**
  16434. * Gets the current list of color gradients.
  16435. * You must use addColorGradient and removeColorGradient to udpate this list
  16436. * @returns the list of color gradients
  16437. */
  16438. getColorGradients(): Nullable<Array<ColorGradient>>;
  16439. /**
  16440. * Adds a new ramp gradient used to remap particle colors
  16441. * @param gradient defines the gradient to use (between 0 and 1)
  16442. * @param color defines the color to affect to the specified gradient
  16443. * @returns the current particle system
  16444. */
  16445. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16446. /**
  16447. * Gets the current list of ramp gradients.
  16448. * You must use addRampGradient and removeRampGradient to udpate this list
  16449. * @returns the list of ramp gradients
  16450. */
  16451. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16452. /** Gets or sets a boolean indicating that ramp gradients must be used
  16453. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16454. */
  16455. useRampGradients: boolean;
  16456. /**
  16457. * Adds a new color remap gradient
  16458. * @param gradient defines the gradient to use (between 0 and 1)
  16459. * @param min defines the color remap minimal range
  16460. * @param max defines the color remap maximal range
  16461. * @returns the current particle system
  16462. */
  16463. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16464. /**
  16465. * Gets the current list of color remap gradients.
  16466. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16467. * @returns the list of color remap gradients
  16468. */
  16469. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16470. /**
  16471. * Adds a new alpha remap gradient
  16472. * @param gradient defines the gradient to use (between 0 and 1)
  16473. * @param min defines the alpha remap minimal range
  16474. * @param max defines the alpha remap maximal range
  16475. * @returns the current particle system
  16476. */
  16477. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16478. /**
  16479. * Gets the current list of alpha remap gradients.
  16480. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16481. * @returns the list of alpha remap gradients
  16482. */
  16483. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16484. /**
  16485. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16488. * @returns the emitter
  16489. */
  16490. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16491. /**
  16492. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16493. * @param radius The radius of the hemisphere to emit from
  16494. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16495. * @returns the emitter
  16496. */
  16497. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16498. /**
  16499. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16500. * @param radius The radius of the sphere to emit from
  16501. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16502. * @returns the emitter
  16503. */
  16504. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16505. /**
  16506. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16507. * @param radius The radius of the sphere to emit from
  16508. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16509. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16510. * @returns the emitter
  16511. */
  16512. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16513. /**
  16514. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16515. * @param radius The radius of the emission cylinder
  16516. * @param height The height of the emission cylinder
  16517. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16518. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16519. * @returns the emitter
  16520. */
  16521. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16522. /**
  16523. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16524. * @param radius The radius of the cylinder to emit from
  16525. * @param height The height of the emission cylinder
  16526. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16527. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16528. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16529. * @returns the emitter
  16530. */
  16531. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16532. /**
  16533. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16534. * @param radius The radius of the cone to emit from
  16535. * @param angle The base angle of the cone
  16536. * @returns the emitter
  16537. */
  16538. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16539. /**
  16540. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16541. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16542. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16543. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16544. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16545. * @returns the emitter
  16546. */
  16547. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16548. /**
  16549. * Get hosting scene
  16550. * @returns the scene
  16551. */
  16552. getScene(): Scene;
  16553. }
  16554. }
  16555. declare module "babylonjs/Meshes/instancedMesh" {
  16556. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16557. import { Vector3 } from "babylonjs/Maths/math";
  16558. import { Camera } from "babylonjs/Cameras/camera";
  16559. import { Node } from "babylonjs/node";
  16560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16561. import { Mesh } from "babylonjs/Meshes/mesh";
  16562. import { Material } from "babylonjs/Materials/material";
  16563. import { Skeleton } from "babylonjs/Bones/skeleton";
  16564. /**
  16565. * Creates an instance based on a source mesh.
  16566. */
  16567. export class InstancedMesh extends AbstractMesh {
  16568. private _sourceMesh;
  16569. private _currentLOD;
  16570. /** @hidden */
  16571. _indexInSourceMeshInstanceArray: number;
  16572. constructor(name: string, source: Mesh);
  16573. /**
  16574. * Returns the string "InstancedMesh".
  16575. */
  16576. getClassName(): string;
  16577. /**
  16578. * If the source mesh receives shadows
  16579. */
  16580. readonly receiveShadows: boolean;
  16581. /**
  16582. * The material of the source mesh
  16583. */
  16584. readonly material: Nullable<Material>;
  16585. /**
  16586. * Visibility of the source mesh
  16587. */
  16588. readonly visibility: number;
  16589. /**
  16590. * Skeleton of the source mesh
  16591. */
  16592. readonly skeleton: Nullable<Skeleton>;
  16593. /**
  16594. * Rendering ground id of the source mesh
  16595. */
  16596. renderingGroupId: number;
  16597. /**
  16598. * Returns the total number of vertices (integer).
  16599. */
  16600. getTotalVertices(): number;
  16601. /**
  16602. * Returns a positive integer : the total number of indices in this mesh geometry.
  16603. * @returns the numner of indices or zero if the mesh has no geometry.
  16604. */
  16605. getTotalIndices(): number;
  16606. /**
  16607. * The source mesh of the instance
  16608. */
  16609. readonly sourceMesh: Mesh;
  16610. /**
  16611. * Is this node ready to be used/rendered
  16612. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16613. * @return {boolean} is it ready
  16614. */
  16615. isReady(completeCheck?: boolean): boolean;
  16616. /**
  16617. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16618. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16619. * @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.
  16620. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16621. */
  16622. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16623. /**
  16624. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16625. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16626. * The `data` are either a numeric array either a Float32Array.
  16627. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16628. * 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).
  16629. * Note that a new underlying VertexBuffer object is created each call.
  16630. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16631. *
  16632. * Possible `kind` values :
  16633. * - VertexBuffer.PositionKind
  16634. * - VertexBuffer.UVKind
  16635. * - VertexBuffer.UV2Kind
  16636. * - VertexBuffer.UV3Kind
  16637. * - VertexBuffer.UV4Kind
  16638. * - VertexBuffer.UV5Kind
  16639. * - VertexBuffer.UV6Kind
  16640. * - VertexBuffer.ColorKind
  16641. * - VertexBuffer.MatricesIndicesKind
  16642. * - VertexBuffer.MatricesIndicesExtraKind
  16643. * - VertexBuffer.MatricesWeightsKind
  16644. * - VertexBuffer.MatricesWeightsExtraKind
  16645. *
  16646. * Returns the Mesh.
  16647. */
  16648. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16649. /**
  16650. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16651. * If the mesh has no geometry, it is simply returned as it is.
  16652. * The `data` are either a numeric array either a Float32Array.
  16653. * No new underlying VertexBuffer object is created.
  16654. * 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.
  16655. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16656. *
  16657. * Possible `kind` values :
  16658. * - VertexBuffer.PositionKind
  16659. * - VertexBuffer.UVKind
  16660. * - VertexBuffer.UV2Kind
  16661. * - VertexBuffer.UV3Kind
  16662. * - VertexBuffer.UV4Kind
  16663. * - VertexBuffer.UV5Kind
  16664. * - VertexBuffer.UV6Kind
  16665. * - VertexBuffer.ColorKind
  16666. * - VertexBuffer.MatricesIndicesKind
  16667. * - VertexBuffer.MatricesIndicesExtraKind
  16668. * - VertexBuffer.MatricesWeightsKind
  16669. * - VertexBuffer.MatricesWeightsExtraKind
  16670. *
  16671. * Returns the Mesh.
  16672. */
  16673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16674. /**
  16675. * Sets the mesh indices.
  16676. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16677. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16678. * This method creates a new index buffer each call.
  16679. * Returns the Mesh.
  16680. */
  16681. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16682. /**
  16683. * Boolean : True if the mesh owns the requested kind of data.
  16684. */
  16685. isVerticesDataPresent(kind: string): boolean;
  16686. /**
  16687. * Returns an array of indices (IndicesArray).
  16688. */
  16689. getIndices(): Nullable<IndicesArray>;
  16690. readonly _positions: Nullable<Vector3[]>;
  16691. /**
  16692. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16693. * This means the mesh underlying bounding box and sphere are recomputed.
  16694. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16695. * @returns the current mesh
  16696. */
  16697. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16698. /** @hidden */
  16699. _preActivate(): InstancedMesh;
  16700. /** @hidden */
  16701. _activate(renderId: number): InstancedMesh;
  16702. /**
  16703. * Returns the current associated LOD AbstractMesh.
  16704. */
  16705. getLOD(camera: Camera): AbstractMesh;
  16706. /** @hidden */
  16707. _syncSubMeshes(): InstancedMesh;
  16708. /** @hidden */
  16709. _generatePointsArray(): boolean;
  16710. /**
  16711. * Creates a new InstancedMesh from the current mesh.
  16712. * - name (string) : the cloned mesh name
  16713. * - newParent (optional Node) : the optional Node to parent the clone to.
  16714. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16715. *
  16716. * Returns the clone.
  16717. */
  16718. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16719. /**
  16720. * Disposes the InstancedMesh.
  16721. * Returns nothing.
  16722. */
  16723. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16724. }
  16725. }
  16726. declare module "babylonjs/Materials/shaderMaterial" {
  16727. import { Scene } from "babylonjs/scene";
  16728. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16730. import { Mesh } from "babylonjs/Meshes/mesh";
  16731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16732. import { Texture } from "babylonjs/Materials/Textures/texture";
  16733. import { Material } from "babylonjs/Materials/material";
  16734. /**
  16735. * Defines the options associated with the creation of a shader material.
  16736. */
  16737. export interface IShaderMaterialOptions {
  16738. /**
  16739. * Does the material work in alpha blend mode
  16740. */
  16741. needAlphaBlending: boolean;
  16742. /**
  16743. * Does the material work in alpha test mode
  16744. */
  16745. needAlphaTesting: boolean;
  16746. /**
  16747. * The list of attribute names used in the shader
  16748. */
  16749. attributes: string[];
  16750. /**
  16751. * The list of unifrom names used in the shader
  16752. */
  16753. uniforms: string[];
  16754. /**
  16755. * The list of UBO names used in the shader
  16756. */
  16757. uniformBuffers: string[];
  16758. /**
  16759. * The list of sampler names used in the shader
  16760. */
  16761. samplers: string[];
  16762. /**
  16763. * The list of defines used in the shader
  16764. */
  16765. defines: string[];
  16766. }
  16767. /**
  16768. * 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.
  16769. *
  16770. * This returned material effects how the mesh will look based on the code in the shaders.
  16771. *
  16772. * @see http://doc.babylonjs.com/how_to/shader_material
  16773. */
  16774. export class ShaderMaterial extends Material {
  16775. private _shaderPath;
  16776. private _options;
  16777. private _textures;
  16778. private _textureArrays;
  16779. private _floats;
  16780. private _ints;
  16781. private _floatsArrays;
  16782. private _colors3;
  16783. private _colors3Arrays;
  16784. private _colors4;
  16785. private _vectors2;
  16786. private _vectors3;
  16787. private _vectors4;
  16788. private _matrices;
  16789. private _matrices3x3;
  16790. private _matrices2x2;
  16791. private _vectors2Arrays;
  16792. private _vectors3Arrays;
  16793. private _cachedWorldViewMatrix;
  16794. private _renderId;
  16795. /**
  16796. * Instantiate a new shader material.
  16797. * 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.
  16798. * This returned material effects how the mesh will look based on the code in the shaders.
  16799. * @see http://doc.babylonjs.com/how_to/shader_material
  16800. * @param name Define the name of the material in the scene
  16801. * @param scene Define the scene the material belongs to
  16802. * @param shaderPath Defines the route to the shader code in one of three ways:
  16803. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16804. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16805. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16806. * @param options Define the options used to create the shader
  16807. */
  16808. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16809. /**
  16810. * Gets the current class name of the material e.g. "ShaderMaterial"
  16811. * Mainly use in serialization.
  16812. * @returns the class name
  16813. */
  16814. getClassName(): string;
  16815. /**
  16816. * Specifies if the material will require alpha blending
  16817. * @returns a boolean specifying if alpha blending is needed
  16818. */
  16819. needAlphaBlending(): boolean;
  16820. /**
  16821. * Specifies if this material should be rendered in alpha test mode
  16822. * @returns a boolean specifying if an alpha test is needed.
  16823. */
  16824. needAlphaTesting(): boolean;
  16825. private _checkUniform;
  16826. /**
  16827. * Set a texture in the shader.
  16828. * @param name Define the name of the uniform samplers as defined in the shader
  16829. * @param texture Define the texture to bind to this sampler
  16830. * @return the material itself allowing "fluent" like uniform updates
  16831. */
  16832. setTexture(name: string, texture: Texture): ShaderMaterial;
  16833. /**
  16834. * Set a texture array in the shader.
  16835. * @param name Define the name of the uniform sampler array as defined in the shader
  16836. * @param textures Define the list of textures to bind to this sampler
  16837. * @return the material itself allowing "fluent" like uniform updates
  16838. */
  16839. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16840. /**
  16841. * Set a float in the shader.
  16842. * @param name Define the name of the uniform as defined in the shader
  16843. * @param value Define the value to give to the uniform
  16844. * @return the material itself allowing "fluent" like uniform updates
  16845. */
  16846. setFloat(name: string, value: number): ShaderMaterial;
  16847. /**
  16848. * Set a int in the shader.
  16849. * @param name Define the name of the uniform as defined in the shader
  16850. * @param value Define the value to give to the uniform
  16851. * @return the material itself allowing "fluent" like uniform updates
  16852. */
  16853. setInt(name: string, value: number): ShaderMaterial;
  16854. /**
  16855. * Set an array of floats in the shader.
  16856. * @param name Define the name of the uniform as defined in the shader
  16857. * @param value Define the value to give to the uniform
  16858. * @return the material itself allowing "fluent" like uniform updates
  16859. */
  16860. setFloats(name: string, value: number[]): ShaderMaterial;
  16861. /**
  16862. * Set a vec3 in the shader from a Color3.
  16863. * @param name Define the name of the uniform as defined in the shader
  16864. * @param value Define the value to give to the uniform
  16865. * @return the material itself allowing "fluent" like uniform updates
  16866. */
  16867. setColor3(name: string, value: Color3): ShaderMaterial;
  16868. /**
  16869. * Set a vec3 array in the shader from a Color3 array.
  16870. * @param name Define the name of the uniform as defined in the shader
  16871. * @param value Define the value to give to the uniform
  16872. * @return the material itself allowing "fluent" like uniform updates
  16873. */
  16874. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16875. /**
  16876. * Set a vec4 in the shader from a Color4.
  16877. * @param name Define the name of the uniform as defined in the shader
  16878. * @param value Define the value to give to the uniform
  16879. * @return the material itself allowing "fluent" like uniform updates
  16880. */
  16881. setColor4(name: string, value: Color4): ShaderMaterial;
  16882. /**
  16883. * Set a vec2 in the shader from a Vector2.
  16884. * @param name Define the name of the uniform as defined in the shader
  16885. * @param value Define the value to give to the uniform
  16886. * @return the material itself allowing "fluent" like uniform updates
  16887. */
  16888. setVector2(name: string, value: Vector2): ShaderMaterial;
  16889. /**
  16890. * Set a vec3 in the shader from a Vector3.
  16891. * @param name Define the name of the uniform as defined in the shader
  16892. * @param value Define the value to give to the uniform
  16893. * @return the material itself allowing "fluent" like uniform updates
  16894. */
  16895. setVector3(name: string, value: Vector3): ShaderMaterial;
  16896. /**
  16897. * Set a vec4 in the shader from a Vector4.
  16898. * @param name Define the name of the uniform as defined in the shader
  16899. * @param value Define the value to give to the uniform
  16900. * @return the material itself allowing "fluent" like uniform updates
  16901. */
  16902. setVector4(name: string, value: Vector4): ShaderMaterial;
  16903. /**
  16904. * Set a mat4 in the shader from a Matrix.
  16905. * @param name Define the name of the uniform as defined in the shader
  16906. * @param value Define the value to give to the uniform
  16907. * @return the material itself allowing "fluent" like uniform updates
  16908. */
  16909. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16910. /**
  16911. * Set a mat3 in the shader from a Float32Array.
  16912. * @param name Define the name of the uniform as defined in the shader
  16913. * @param value Define the value to give to the uniform
  16914. * @return the material itself allowing "fluent" like uniform updates
  16915. */
  16916. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16917. /**
  16918. * Set a mat2 in the shader from a Float32Array.
  16919. * @param name Define the name of the uniform as defined in the shader
  16920. * @param value Define the value to give to the uniform
  16921. * @return the material itself allowing "fluent" like uniform updates
  16922. */
  16923. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16924. /**
  16925. * Set a vec2 array in the shader from a number array.
  16926. * @param name Define the name of the uniform as defined in the shader
  16927. * @param value Define the value to give to the uniform
  16928. * @return the material itself allowing "fluent" like uniform updates
  16929. */
  16930. setArray2(name: string, value: number[]): ShaderMaterial;
  16931. /**
  16932. * Set a vec3 array in the shader from a number array.
  16933. * @param name Define the name of the uniform as defined in the shader
  16934. * @param value Define the value to give to the uniform
  16935. * @return the material itself allowing "fluent" like uniform updates
  16936. */
  16937. setArray3(name: string, value: number[]): ShaderMaterial;
  16938. private _checkCache;
  16939. /**
  16940. * Checks if the material is ready to render the requested mesh
  16941. * @param mesh Define the mesh to render
  16942. * @param useInstances Define whether or not the material is used with instances
  16943. * @returns true if ready, otherwise false
  16944. */
  16945. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16946. /**
  16947. * Binds the world matrix to the material
  16948. * @param world defines the world transformation matrix
  16949. */
  16950. bindOnlyWorldMatrix(world: Matrix): void;
  16951. /**
  16952. * Binds the material to the mesh
  16953. * @param world defines the world transformation matrix
  16954. * @param mesh defines the mesh to bind the material to
  16955. */
  16956. bind(world: Matrix, mesh?: Mesh): void;
  16957. /**
  16958. * Gets the active textures from the material
  16959. * @returns an array of textures
  16960. */
  16961. getActiveTextures(): BaseTexture[];
  16962. /**
  16963. * Specifies if the material uses a texture
  16964. * @param texture defines the texture to check against the material
  16965. * @returns a boolean specifying if the material uses the texture
  16966. */
  16967. hasTexture(texture: BaseTexture): boolean;
  16968. /**
  16969. * Makes a duplicate of the material, and gives it a new name
  16970. * @param name defines the new name for the duplicated material
  16971. * @returns the cloned material
  16972. */
  16973. clone(name: string): ShaderMaterial;
  16974. /**
  16975. * Disposes the material
  16976. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16977. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16978. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16979. */
  16980. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16981. /**
  16982. * Serializes this material in a JSON representation
  16983. * @returns the serialized material object
  16984. */
  16985. serialize(): any;
  16986. /**
  16987. * Creates a shader material from parsed shader material data
  16988. * @param source defines the JSON represnetation of the material
  16989. * @param scene defines the hosting scene
  16990. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16991. * @returns a new material
  16992. */
  16993. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16994. }
  16995. }
  16996. declare module "babylonjs/Shaders/color.fragment" {
  16997. /** @hidden */
  16998. export var colorPixelShader: {
  16999. name: string;
  17000. shader: string;
  17001. };
  17002. }
  17003. declare module "babylonjs/Shaders/color.vertex" {
  17004. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17005. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17006. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17007. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17008. /** @hidden */
  17009. export var colorVertexShader: {
  17010. name: string;
  17011. shader: string;
  17012. };
  17013. }
  17014. declare module "babylonjs/Meshes/linesMesh" {
  17015. import { Nullable } from "babylonjs/types";
  17016. import { Scene } from "babylonjs/scene";
  17017. import { Color3 } from "babylonjs/Maths/math";
  17018. import { Node } from "babylonjs/node";
  17019. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17020. import { Mesh } from "babylonjs/Meshes/mesh";
  17021. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17022. import { Effect } from "babylonjs/Materials/effect";
  17023. import { Material } from "babylonjs/Materials/material";
  17024. import "babylonjs/Shaders/color.fragment";
  17025. import "babylonjs/Shaders/color.vertex";
  17026. /**
  17027. * Line mesh
  17028. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17029. */
  17030. export class LinesMesh extends Mesh {
  17031. /**
  17032. * If vertex color should be applied to the mesh
  17033. */
  17034. useVertexColor?: boolean | undefined;
  17035. /**
  17036. * If vertex alpha should be applied to the mesh
  17037. */
  17038. useVertexAlpha?: boolean | undefined;
  17039. /**
  17040. * Color of the line (Default: White)
  17041. */
  17042. color: Color3;
  17043. /**
  17044. * Alpha of the line (Default: 1)
  17045. */
  17046. alpha: number;
  17047. /**
  17048. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17049. * This margin is expressed in world space coordinates, so its value may vary.
  17050. * Default value is 0.1
  17051. */
  17052. intersectionThreshold: number;
  17053. private _colorShader;
  17054. /**
  17055. * Creates a new LinesMesh
  17056. * @param name defines the name
  17057. * @param scene defines the hosting scene
  17058. * @param parent defines the parent mesh if any
  17059. * @param source defines the optional source LinesMesh used to clone data from
  17060. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17061. * When false, achieved by calling a clone(), also passing False.
  17062. * This will make creation of children, recursive.
  17063. * @param useVertexColor defines if this LinesMesh supports vertex color
  17064. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17065. */
  17066. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17067. /**
  17068. * If vertex color should be applied to the mesh
  17069. */
  17070. useVertexColor?: boolean | undefined,
  17071. /**
  17072. * If vertex alpha should be applied to the mesh
  17073. */
  17074. useVertexAlpha?: boolean | undefined);
  17075. /**
  17076. * Returns the string "LineMesh"
  17077. */
  17078. getClassName(): string;
  17079. /**
  17080. * @hidden
  17081. */
  17082. /**
  17083. * @hidden
  17084. */
  17085. material: Material;
  17086. /**
  17087. * @hidden
  17088. */
  17089. readonly checkCollisions: boolean;
  17090. /** @hidden */
  17091. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17092. /** @hidden */
  17093. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17094. /**
  17095. * Disposes of the line mesh
  17096. * @param doNotRecurse If children should be disposed
  17097. */
  17098. dispose(doNotRecurse?: boolean): void;
  17099. /**
  17100. * Returns a new LineMesh object cloned from the current one.
  17101. */
  17102. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17103. /**
  17104. * Creates a new InstancedLinesMesh object from the mesh model.
  17105. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17106. * @param name defines the name of the new instance
  17107. * @returns a new InstancedLinesMesh
  17108. */
  17109. createInstance(name: string): InstancedLinesMesh;
  17110. }
  17111. /**
  17112. * Creates an instance based on a source LinesMesh
  17113. */
  17114. export class InstancedLinesMesh extends InstancedMesh {
  17115. /**
  17116. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17117. * This margin is expressed in world space coordinates, so its value may vary.
  17118. * Initilized with the intersectionThreshold value of the source LinesMesh
  17119. */
  17120. intersectionThreshold: number;
  17121. constructor(name: string, source: LinesMesh);
  17122. /**
  17123. * Returns the string "InstancedLinesMesh".
  17124. */
  17125. getClassName(): string;
  17126. }
  17127. }
  17128. declare module "babylonjs/Shaders/line.fragment" {
  17129. /** @hidden */
  17130. export var linePixelShader: {
  17131. name: string;
  17132. shader: string;
  17133. };
  17134. }
  17135. declare module "babylonjs/Shaders/line.vertex" {
  17136. /** @hidden */
  17137. export var lineVertexShader: {
  17138. name: string;
  17139. shader: string;
  17140. };
  17141. }
  17142. declare module "babylonjs/Rendering/edgesRenderer" {
  17143. import { Nullable } from "babylonjs/types";
  17144. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17146. import { Vector3 } from "babylonjs/Maths/math";
  17147. import { IDisposable } from "babylonjs/scene";
  17148. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17149. import "babylonjs/Shaders/line.fragment";
  17150. import "babylonjs/Shaders/line.vertex";
  17151. module "babylonjs/Meshes/abstractMesh" {
  17152. interface AbstractMesh {
  17153. /**
  17154. * Disables the mesh edge rendering mode
  17155. * @returns the currentAbstractMesh
  17156. */
  17157. disableEdgesRendering(): AbstractMesh;
  17158. /**
  17159. * Enables the edge rendering mode on the mesh.
  17160. * This mode makes the mesh edges visible
  17161. * @param epsilon defines the maximal distance between two angles to detect a face
  17162. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17163. * @returns the currentAbstractMesh
  17164. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17165. */
  17166. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17167. /**
  17168. * Gets the edgesRenderer associated with the mesh
  17169. */
  17170. edgesRenderer: Nullable<EdgesRenderer>;
  17171. }
  17172. }
  17173. module "babylonjs/Meshes/linesMesh" {
  17174. interface LinesMesh {
  17175. /**
  17176. * Enables the edge rendering mode on the mesh.
  17177. * This mode makes the mesh edges visible
  17178. * @param epsilon defines the maximal distance between two angles to detect a face
  17179. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17180. * @returns the currentAbstractMesh
  17181. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17182. */
  17183. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17184. }
  17185. }
  17186. module "babylonjs/Meshes/linesMesh" {
  17187. interface InstancedLinesMesh {
  17188. /**
  17189. * Enables the edge rendering mode on the mesh.
  17190. * This mode makes the mesh edges visible
  17191. * @param epsilon defines the maximal distance between two angles to detect a face
  17192. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17193. * @returns the current InstancedLinesMesh
  17194. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17195. */
  17196. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17197. }
  17198. }
  17199. /**
  17200. * Defines the minimum contract an Edges renderer should follow.
  17201. */
  17202. export interface IEdgesRenderer extends IDisposable {
  17203. /**
  17204. * Gets or sets a boolean indicating if the edgesRenderer is active
  17205. */
  17206. isEnabled: boolean;
  17207. /**
  17208. * Renders the edges of the attached mesh,
  17209. */
  17210. render(): void;
  17211. /**
  17212. * Checks wether or not the edges renderer is ready to render.
  17213. * @return true if ready, otherwise false.
  17214. */
  17215. isReady(): boolean;
  17216. }
  17217. /**
  17218. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17219. */
  17220. export class EdgesRenderer implements IEdgesRenderer {
  17221. /**
  17222. * Define the size of the edges with an orthographic camera
  17223. */
  17224. edgesWidthScalerForOrthographic: number;
  17225. /**
  17226. * Define the size of the edges with a perspective camera
  17227. */
  17228. edgesWidthScalerForPerspective: number;
  17229. protected _source: AbstractMesh;
  17230. protected _linesPositions: number[];
  17231. protected _linesNormals: number[];
  17232. protected _linesIndices: number[];
  17233. protected _epsilon: number;
  17234. protected _indicesCount: number;
  17235. protected _lineShader: ShaderMaterial;
  17236. protected _ib: WebGLBuffer;
  17237. protected _buffers: {
  17238. [key: string]: Nullable<VertexBuffer>;
  17239. };
  17240. protected _checkVerticesInsteadOfIndices: boolean;
  17241. private _meshRebuildObserver;
  17242. private _meshDisposeObserver;
  17243. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17244. isEnabled: boolean;
  17245. /**
  17246. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17247. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17248. * @param source Mesh used to create edges
  17249. * @param epsilon sum of angles in adjacency to check for edge
  17250. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17251. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17252. */
  17253. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17254. protected _prepareRessources(): void;
  17255. /** @hidden */
  17256. _rebuild(): void;
  17257. /**
  17258. * Releases the required resources for the edges renderer
  17259. */
  17260. dispose(): void;
  17261. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17262. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17263. /**
  17264. * Checks if the pair of p0 and p1 is en edge
  17265. * @param faceIndex
  17266. * @param edge
  17267. * @param faceNormals
  17268. * @param p0
  17269. * @param p1
  17270. * @private
  17271. */
  17272. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17273. /**
  17274. * push line into the position, normal and index buffer
  17275. * @protected
  17276. */
  17277. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17278. /**
  17279. * Generates lines edges from adjacencjes
  17280. * @private
  17281. */
  17282. _generateEdgesLines(): void;
  17283. /**
  17284. * Checks wether or not the edges renderer is ready to render.
  17285. * @return true if ready, otherwise false.
  17286. */
  17287. isReady(): boolean;
  17288. /**
  17289. * Renders the edges of the attached mesh,
  17290. */
  17291. render(): void;
  17292. }
  17293. /**
  17294. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17295. */
  17296. export class LineEdgesRenderer extends EdgesRenderer {
  17297. /**
  17298. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17299. * @param source LineMesh used to generate edges
  17300. * @param epsilon not important (specified angle for edge detection)
  17301. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17302. */
  17303. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17304. /**
  17305. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17306. */
  17307. _generateEdgesLines(): void;
  17308. }
  17309. }
  17310. declare module "babylonjs/Rendering/renderingGroup" {
  17311. import { SmartArray } from "babylonjs/Misc/smartArray";
  17312. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17314. import { Nullable } from "babylonjs/types";
  17315. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17316. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17317. import { Material } from "babylonjs/Materials/material";
  17318. import { Scene } from "babylonjs/scene";
  17319. /**
  17320. * This represents the object necessary to create a rendering group.
  17321. * This is exclusively used and created by the rendering manager.
  17322. * To modify the behavior, you use the available helpers in your scene or meshes.
  17323. * @hidden
  17324. */
  17325. export class RenderingGroup {
  17326. index: number;
  17327. private _scene;
  17328. private _opaqueSubMeshes;
  17329. private _transparentSubMeshes;
  17330. private _alphaTestSubMeshes;
  17331. private _depthOnlySubMeshes;
  17332. private _particleSystems;
  17333. private _spriteManagers;
  17334. private _opaqueSortCompareFn;
  17335. private _alphaTestSortCompareFn;
  17336. private _transparentSortCompareFn;
  17337. private _renderOpaque;
  17338. private _renderAlphaTest;
  17339. private _renderTransparent;
  17340. private _edgesRenderers;
  17341. onBeforeTransparentRendering: () => void;
  17342. /**
  17343. * Set the opaque sort comparison function.
  17344. * If null the sub meshes will be render in the order they were created
  17345. */
  17346. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17347. /**
  17348. * Set the alpha test sort comparison function.
  17349. * If null the sub meshes will be render in the order they were created
  17350. */
  17351. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17352. /**
  17353. * Set the transparent sort comparison function.
  17354. * If null the sub meshes will be render in the order they were created
  17355. */
  17356. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17357. /**
  17358. * Creates a new rendering group.
  17359. * @param index The rendering group index
  17360. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17361. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17362. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17363. */
  17364. 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>);
  17365. /**
  17366. * Render all the sub meshes contained in the group.
  17367. * @param customRenderFunction Used to override the default render behaviour of the group.
  17368. * @returns true if rendered some submeshes.
  17369. */
  17370. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17371. /**
  17372. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17373. * @param subMeshes The submeshes to render
  17374. */
  17375. private renderOpaqueSorted;
  17376. /**
  17377. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17378. * @param subMeshes The submeshes to render
  17379. */
  17380. private renderAlphaTestSorted;
  17381. /**
  17382. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17383. * @param subMeshes The submeshes to render
  17384. */
  17385. private renderTransparentSorted;
  17386. /**
  17387. * Renders the submeshes in a specified order.
  17388. * @param subMeshes The submeshes to sort before render
  17389. * @param sortCompareFn The comparison function use to sort
  17390. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17391. * @param transparent Specifies to activate blending if true
  17392. */
  17393. private static renderSorted;
  17394. /**
  17395. * Renders the submeshes in the order they were dispatched (no sort applied).
  17396. * @param subMeshes The submeshes to render
  17397. */
  17398. private static renderUnsorted;
  17399. /**
  17400. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17401. * are rendered back to front if in the same alpha index.
  17402. *
  17403. * @param a The first submesh
  17404. * @param b The second submesh
  17405. * @returns The result of the comparison
  17406. */
  17407. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17408. /**
  17409. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17410. * are rendered back to front.
  17411. *
  17412. * @param a The first submesh
  17413. * @param b The second submesh
  17414. * @returns The result of the comparison
  17415. */
  17416. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17417. /**
  17418. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17419. * are rendered front to back (prevent overdraw).
  17420. *
  17421. * @param a The first submesh
  17422. * @param b The second submesh
  17423. * @returns The result of the comparison
  17424. */
  17425. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17426. /**
  17427. * Resets the different lists of submeshes to prepare a new frame.
  17428. */
  17429. prepare(): void;
  17430. dispose(): void;
  17431. /**
  17432. * Inserts the submesh in its correct queue depending on its material.
  17433. * @param subMesh The submesh to dispatch
  17434. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17435. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17436. */
  17437. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17438. dispatchSprites(spriteManager: ISpriteManager): void;
  17439. dispatchParticles(particleSystem: IParticleSystem): void;
  17440. private _renderParticles;
  17441. private _renderSprites;
  17442. }
  17443. }
  17444. declare module "babylonjs/Rendering/renderingManager" {
  17445. import { Nullable } from "babylonjs/types";
  17446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17448. import { SmartArray } from "babylonjs/Misc/smartArray";
  17449. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17450. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17451. import { Material } from "babylonjs/Materials/material";
  17452. import { Scene } from "babylonjs/scene";
  17453. import { Camera } from "babylonjs/Cameras/camera";
  17454. /**
  17455. * Interface describing the different options available in the rendering manager
  17456. * regarding Auto Clear between groups.
  17457. */
  17458. export interface IRenderingManagerAutoClearSetup {
  17459. /**
  17460. * Defines whether or not autoclear is enable.
  17461. */
  17462. autoClear: boolean;
  17463. /**
  17464. * Defines whether or not to autoclear the depth buffer.
  17465. */
  17466. depth: boolean;
  17467. /**
  17468. * Defines whether or not to autoclear the stencil buffer.
  17469. */
  17470. stencil: boolean;
  17471. }
  17472. /**
  17473. * This class is used by the onRenderingGroupObservable
  17474. */
  17475. export class RenderingGroupInfo {
  17476. /**
  17477. * The Scene that being rendered
  17478. */
  17479. scene: Scene;
  17480. /**
  17481. * The camera currently used for the rendering pass
  17482. */
  17483. camera: Nullable<Camera>;
  17484. /**
  17485. * The ID of the renderingGroup being processed
  17486. */
  17487. renderingGroupId: number;
  17488. }
  17489. /**
  17490. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17491. * It is enable to manage the different groups as well as the different necessary sort functions.
  17492. * This should not be used directly aside of the few static configurations
  17493. */
  17494. export class RenderingManager {
  17495. /**
  17496. * The max id used for rendering groups (not included)
  17497. */
  17498. static MAX_RENDERINGGROUPS: number;
  17499. /**
  17500. * The min id used for rendering groups (included)
  17501. */
  17502. static MIN_RENDERINGGROUPS: number;
  17503. /**
  17504. * Used to globally prevent autoclearing scenes.
  17505. */
  17506. static AUTOCLEAR: boolean;
  17507. /**
  17508. * @hidden
  17509. */
  17510. _useSceneAutoClearSetup: boolean;
  17511. private _scene;
  17512. private _renderingGroups;
  17513. private _depthStencilBufferAlreadyCleaned;
  17514. private _autoClearDepthStencil;
  17515. private _customOpaqueSortCompareFn;
  17516. private _customAlphaTestSortCompareFn;
  17517. private _customTransparentSortCompareFn;
  17518. private _renderingGroupInfo;
  17519. /**
  17520. * Instantiates a new rendering group for a particular scene
  17521. * @param scene Defines the scene the groups belongs to
  17522. */
  17523. constructor(scene: Scene);
  17524. private _clearDepthStencilBuffer;
  17525. /**
  17526. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17527. * @hidden
  17528. */
  17529. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17530. /**
  17531. * Resets the different information of the group to prepare a new frame
  17532. * @hidden
  17533. */
  17534. reset(): void;
  17535. /**
  17536. * Dispose and release the group and its associated resources.
  17537. * @hidden
  17538. */
  17539. dispose(): void;
  17540. /**
  17541. * Clear the info related to rendering groups preventing retention points during dispose.
  17542. */
  17543. freeRenderingGroups(): void;
  17544. private _prepareRenderingGroup;
  17545. /**
  17546. * Add a sprite manager to the rendering manager in order to render it this frame.
  17547. * @param spriteManager Define the sprite manager to render
  17548. */
  17549. dispatchSprites(spriteManager: ISpriteManager): void;
  17550. /**
  17551. * Add a particle system to the rendering manager in order to render it this frame.
  17552. * @param particleSystem Define the particle system to render
  17553. */
  17554. dispatchParticles(particleSystem: IParticleSystem): void;
  17555. /**
  17556. * Add a submesh to the manager in order to render it this frame
  17557. * @param subMesh The submesh to dispatch
  17558. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17559. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17560. */
  17561. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17562. /**
  17563. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17564. * This allowed control for front to back rendering or reversly depending of the special needs.
  17565. *
  17566. * @param renderingGroupId The rendering group id corresponding to its index
  17567. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17568. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17569. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17570. */
  17571. 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;
  17572. /**
  17573. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17574. *
  17575. * @param renderingGroupId The rendering group id corresponding to its index
  17576. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17577. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17578. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17579. */
  17580. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17581. /**
  17582. * Gets the current auto clear configuration for one rendering group of the rendering
  17583. * manager.
  17584. * @param index the rendering group index to get the information for
  17585. * @returns The auto clear setup for the requested rendering group
  17586. */
  17587. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17588. }
  17589. }
  17590. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17591. import { Observable } from "babylonjs/Misc/observable";
  17592. import { SmartArray } from "babylonjs/Misc/smartArray";
  17593. import { Nullable } from "babylonjs/types";
  17594. import { Camera } from "babylonjs/Cameras/camera";
  17595. import { Scene } from "babylonjs/scene";
  17596. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17597. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17599. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17600. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17601. import { Texture } from "babylonjs/Materials/Textures/texture";
  17602. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17603. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17604. import { Engine } from "babylonjs/Engines/engine";
  17605. /**
  17606. * This Helps creating a texture that will be created from a camera in your scene.
  17607. * It is basically a dynamic texture that could be used to create special effects for instance.
  17608. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17609. */
  17610. export class RenderTargetTexture extends Texture {
  17611. isCube: boolean;
  17612. /**
  17613. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17614. */
  17615. static readonly REFRESHRATE_RENDER_ONCE: number;
  17616. /**
  17617. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17618. */
  17619. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17620. /**
  17621. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17622. * the central point of your effect and can save a lot of performances.
  17623. */
  17624. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17625. /**
  17626. * Use this predicate to dynamically define the list of mesh you want to render.
  17627. * If set, the renderList property will be overwritten.
  17628. */
  17629. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17630. private _renderList;
  17631. /**
  17632. * Use this list to define the list of mesh you want to render.
  17633. */
  17634. renderList: Nullable<Array<AbstractMesh>>;
  17635. private _hookArray;
  17636. /**
  17637. * Define if particles should be rendered in your texture.
  17638. */
  17639. renderParticles: boolean;
  17640. /**
  17641. * Define if sprites should be rendered in your texture.
  17642. */
  17643. renderSprites: boolean;
  17644. /**
  17645. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17646. */
  17647. coordinatesMode: number;
  17648. /**
  17649. * Define the camera used to render the texture.
  17650. */
  17651. activeCamera: Nullable<Camera>;
  17652. /**
  17653. * Override the render function of the texture with your own one.
  17654. */
  17655. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17656. /**
  17657. * Define if camera post processes should be use while rendering the texture.
  17658. */
  17659. useCameraPostProcesses: boolean;
  17660. /**
  17661. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17662. */
  17663. ignoreCameraViewport: boolean;
  17664. private _postProcessManager;
  17665. private _postProcesses;
  17666. private _resizeObserver;
  17667. /**
  17668. * An event triggered when the texture is unbind.
  17669. */
  17670. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17671. /**
  17672. * An event triggered when the texture is unbind.
  17673. */
  17674. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17675. private _onAfterUnbindObserver;
  17676. /**
  17677. * Set a after unbind callback in the texture.
  17678. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17679. */
  17680. onAfterUnbind: () => void;
  17681. /**
  17682. * An event triggered before rendering the texture
  17683. */
  17684. onBeforeRenderObservable: Observable<number>;
  17685. private _onBeforeRenderObserver;
  17686. /**
  17687. * Set a before render callback in the texture.
  17688. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17689. */
  17690. onBeforeRender: (faceIndex: number) => void;
  17691. /**
  17692. * An event triggered after rendering the texture
  17693. */
  17694. onAfterRenderObservable: Observable<number>;
  17695. private _onAfterRenderObserver;
  17696. /**
  17697. * Set a after render callback in the texture.
  17698. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17699. */
  17700. onAfterRender: (faceIndex: number) => void;
  17701. /**
  17702. * An event triggered after the texture clear
  17703. */
  17704. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17705. private _onClearObserver;
  17706. /**
  17707. * Set a clear callback in the texture.
  17708. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17709. */
  17710. onClear: (Engine: Engine) => void;
  17711. /**
  17712. * Define the clear color of the Render Target if it should be different from the scene.
  17713. */
  17714. clearColor: Color4;
  17715. protected _size: number | {
  17716. width: number;
  17717. height: number;
  17718. };
  17719. protected _initialSizeParameter: number | {
  17720. width: number;
  17721. height: number;
  17722. } | {
  17723. ratio: number;
  17724. };
  17725. protected _sizeRatio: Nullable<number>;
  17726. /** @hidden */
  17727. _generateMipMaps: boolean;
  17728. protected _renderingManager: RenderingManager;
  17729. /** @hidden */
  17730. _waitingRenderList: string[];
  17731. protected _doNotChangeAspectRatio: boolean;
  17732. protected _currentRefreshId: number;
  17733. protected _refreshRate: number;
  17734. protected _textureMatrix: Matrix;
  17735. protected _samples: number;
  17736. protected _renderTargetOptions: RenderTargetCreationOptions;
  17737. /**
  17738. * Gets render target creation options that were used.
  17739. */
  17740. readonly renderTargetOptions: RenderTargetCreationOptions;
  17741. protected _engine: Engine;
  17742. protected _onRatioRescale(): void;
  17743. /**
  17744. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17745. * It must define where the camera used to render the texture is set
  17746. */
  17747. boundingBoxPosition: Vector3;
  17748. private _boundingBoxSize;
  17749. /**
  17750. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17751. * When defined, the cubemap will switch to local mode
  17752. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17753. * @example https://www.babylonjs-playground.com/#RNASML
  17754. */
  17755. boundingBoxSize: Vector3;
  17756. /**
  17757. * In case the RTT has been created with a depth texture, get the associated
  17758. * depth texture.
  17759. * Otherwise, return null.
  17760. */
  17761. depthStencilTexture: Nullable<InternalTexture>;
  17762. /**
  17763. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17764. * or used a shadow, depth texture...
  17765. * @param name The friendly name of the texture
  17766. * @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)
  17767. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17768. * @param generateMipMaps True if mip maps need to be generated after render.
  17769. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17770. * @param type The type of the buffer in the RTT (int, half float, float...)
  17771. * @param isCube True if a cube texture needs to be created
  17772. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17773. * @param generateDepthBuffer True to generate a depth buffer
  17774. * @param generateStencilBuffer True to generate a stencil buffer
  17775. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17776. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17777. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17778. */
  17779. constructor(name: string, size: number | {
  17780. width: number;
  17781. height: number;
  17782. } | {
  17783. ratio: number;
  17784. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17785. /**
  17786. * Creates a depth stencil texture.
  17787. * This is only available in WebGL 2 or with the depth texture extension available.
  17788. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17789. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17790. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17791. */
  17792. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17793. private _processSizeParameter;
  17794. /**
  17795. * Define the number of samples to use in case of MSAA.
  17796. * It defaults to one meaning no MSAA has been enabled.
  17797. */
  17798. samples: number;
  17799. /**
  17800. * Resets the refresh counter of the texture and start bak from scratch.
  17801. * Could be useful to regenerate the texture if it is setup to render only once.
  17802. */
  17803. resetRefreshCounter(): void;
  17804. /**
  17805. * Define the refresh rate of the texture or the rendering frequency.
  17806. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17807. */
  17808. refreshRate: number;
  17809. /**
  17810. * Adds a post process to the render target rendering passes.
  17811. * @param postProcess define the post process to add
  17812. */
  17813. addPostProcess(postProcess: PostProcess): void;
  17814. /**
  17815. * Clear all the post processes attached to the render target
  17816. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17817. */
  17818. clearPostProcesses(dispose?: boolean): void;
  17819. /**
  17820. * Remove one of the post process from the list of attached post processes to the texture
  17821. * @param postProcess define the post process to remove from the list
  17822. */
  17823. removePostProcess(postProcess: PostProcess): void;
  17824. /** @hidden */
  17825. _shouldRender(): boolean;
  17826. /**
  17827. * Gets the actual render size of the texture.
  17828. * @returns the width of the render size
  17829. */
  17830. getRenderSize(): number;
  17831. /**
  17832. * Gets the actual render width of the texture.
  17833. * @returns the width of the render size
  17834. */
  17835. getRenderWidth(): number;
  17836. /**
  17837. * Gets the actual render height of the texture.
  17838. * @returns the height of the render size
  17839. */
  17840. getRenderHeight(): number;
  17841. /**
  17842. * Get if the texture can be rescaled or not.
  17843. */
  17844. readonly canRescale: boolean;
  17845. /**
  17846. * Resize the texture using a ratio.
  17847. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17848. */
  17849. scale(ratio: number): void;
  17850. /**
  17851. * Get the texture reflection matrix used to rotate/transform the reflection.
  17852. * @returns the reflection matrix
  17853. */
  17854. getReflectionTextureMatrix(): Matrix;
  17855. /**
  17856. * Resize the texture to a new desired size.
  17857. * Be carrefull as it will recreate all the data in the new texture.
  17858. * @param size Define the new size. It can be:
  17859. * - a number for squared texture,
  17860. * - an object containing { width: number, height: number }
  17861. * - or an object containing a ratio { ratio: number }
  17862. */
  17863. resize(size: number | {
  17864. width: number;
  17865. height: number;
  17866. } | {
  17867. ratio: number;
  17868. }): void;
  17869. /**
  17870. * Renders all the objects from the render list into the texture.
  17871. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17872. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17873. */
  17874. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17875. private _bestReflectionRenderTargetDimension;
  17876. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17877. private renderToTarget;
  17878. /**
  17879. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17880. * This allowed control for front to back rendering or reversly depending of the special needs.
  17881. *
  17882. * @param renderingGroupId The rendering group id corresponding to its index
  17883. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17884. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17885. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17886. */
  17887. 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;
  17888. /**
  17889. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17890. *
  17891. * @param renderingGroupId The rendering group id corresponding to its index
  17892. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17893. */
  17894. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17895. /**
  17896. * Clones the texture.
  17897. * @returns the cloned texture
  17898. */
  17899. clone(): RenderTargetTexture;
  17900. /**
  17901. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17902. * @returns The JSON representation of the texture
  17903. */
  17904. serialize(): any;
  17905. /**
  17906. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17907. */
  17908. disposeFramebufferObjects(): void;
  17909. /**
  17910. * Dispose the texture and release its associated resources.
  17911. */
  17912. dispose(): void;
  17913. /** @hidden */
  17914. _rebuild(): void;
  17915. /**
  17916. * Clear the info related to rendering groups preventing retention point in material dispose.
  17917. */
  17918. freeRenderingGroups(): void;
  17919. }
  17920. }
  17921. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17922. import { Scene } from "babylonjs/scene";
  17923. import { Plane } from "babylonjs/Maths/math";
  17924. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17925. /**
  17926. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17927. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17928. * You can then easily use it as a reflectionTexture on a flat surface.
  17929. * In case the surface is not a plane, please consider relying on reflection probes.
  17930. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17931. */
  17932. export class MirrorTexture extends RenderTargetTexture {
  17933. private scene;
  17934. /**
  17935. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17936. * 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.
  17937. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17938. */
  17939. mirrorPlane: Plane;
  17940. /**
  17941. * Define the blur ratio used to blur the reflection if needed.
  17942. */
  17943. blurRatio: number;
  17944. /**
  17945. * Define the adaptive blur kernel used to blur the reflection if needed.
  17946. * This will autocompute the closest best match for the `blurKernel`
  17947. */
  17948. adaptiveBlurKernel: number;
  17949. /**
  17950. * Define the blur kernel used to blur the reflection if needed.
  17951. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17952. */
  17953. blurKernel: number;
  17954. /**
  17955. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17956. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17957. */
  17958. blurKernelX: number;
  17959. /**
  17960. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17961. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17962. */
  17963. blurKernelY: number;
  17964. private _autoComputeBlurKernel;
  17965. protected _onRatioRescale(): void;
  17966. private _updateGammaSpace;
  17967. private _imageProcessingConfigChangeObserver;
  17968. private _transformMatrix;
  17969. private _mirrorMatrix;
  17970. private _savedViewMatrix;
  17971. private _blurX;
  17972. private _blurY;
  17973. private _adaptiveBlurKernel;
  17974. private _blurKernelX;
  17975. private _blurKernelY;
  17976. private _blurRatio;
  17977. /**
  17978. * Instantiates a Mirror Texture.
  17979. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17980. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17981. * You can then easily use it as a reflectionTexture on a flat surface.
  17982. * In case the surface is not a plane, please consider relying on reflection probes.
  17983. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17984. * @param name
  17985. * @param size
  17986. * @param scene
  17987. * @param generateMipMaps
  17988. * @param type
  17989. * @param samplingMode
  17990. * @param generateDepthBuffer
  17991. */
  17992. constructor(name: string, size: number | {
  17993. width: number;
  17994. height: number;
  17995. } | {
  17996. ratio: number;
  17997. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17998. private _preparePostProcesses;
  17999. /**
  18000. * Clone the mirror texture.
  18001. * @returns the cloned texture
  18002. */
  18003. clone(): MirrorTexture;
  18004. /**
  18005. * Serialize the texture to a JSON representation you could use in Parse later on
  18006. * @returns the serialized JSON representation
  18007. */
  18008. serialize(): any;
  18009. /**
  18010. * Dispose the texture and release its associated resources.
  18011. */
  18012. dispose(): void;
  18013. }
  18014. }
  18015. declare module "babylonjs/Materials/Textures/texture" {
  18016. import { Observable } from "babylonjs/Misc/observable";
  18017. import { Nullable } from "babylonjs/types";
  18018. import { Scene } from "babylonjs/scene";
  18019. import { Matrix } from "babylonjs/Maths/math";
  18020. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18021. /**
  18022. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18023. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18024. */
  18025. export class Texture extends BaseTexture {
  18026. /** @hidden */
  18027. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18028. /** @hidden */
  18029. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18030. /** @hidden */
  18031. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18032. /** nearest is mag = nearest and min = nearest and mip = linear */
  18033. static readonly NEAREST_SAMPLINGMODE: number;
  18034. /** nearest is mag = nearest and min = nearest and mip = linear */
  18035. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18036. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18037. static readonly BILINEAR_SAMPLINGMODE: number;
  18038. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18039. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18040. /** Trilinear is mag = linear and min = linear and mip = linear */
  18041. static readonly TRILINEAR_SAMPLINGMODE: number;
  18042. /** Trilinear is mag = linear and min = linear and mip = linear */
  18043. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18044. /** mag = nearest and min = nearest and mip = nearest */
  18045. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18046. /** mag = nearest and min = linear and mip = nearest */
  18047. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18048. /** mag = nearest and min = linear and mip = linear */
  18049. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18050. /** mag = nearest and min = linear and mip = none */
  18051. static readonly NEAREST_LINEAR: number;
  18052. /** mag = nearest and min = nearest and mip = none */
  18053. static readonly NEAREST_NEAREST: number;
  18054. /** mag = linear and min = nearest and mip = nearest */
  18055. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18056. /** mag = linear and min = nearest and mip = linear */
  18057. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18058. /** mag = linear and min = linear and mip = none */
  18059. static readonly LINEAR_LINEAR: number;
  18060. /** mag = linear and min = nearest and mip = none */
  18061. static readonly LINEAR_NEAREST: number;
  18062. /** Explicit coordinates mode */
  18063. static readonly EXPLICIT_MODE: number;
  18064. /** Spherical coordinates mode */
  18065. static readonly SPHERICAL_MODE: number;
  18066. /** Planar coordinates mode */
  18067. static readonly PLANAR_MODE: number;
  18068. /** Cubic coordinates mode */
  18069. static readonly CUBIC_MODE: number;
  18070. /** Projection coordinates mode */
  18071. static readonly PROJECTION_MODE: number;
  18072. /** Inverse Cubic coordinates mode */
  18073. static readonly SKYBOX_MODE: number;
  18074. /** Inverse Cubic coordinates mode */
  18075. static readonly INVCUBIC_MODE: number;
  18076. /** Equirectangular coordinates mode */
  18077. static readonly EQUIRECTANGULAR_MODE: number;
  18078. /** Equirectangular Fixed coordinates mode */
  18079. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18080. /** Equirectangular Fixed Mirrored coordinates mode */
  18081. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18082. /** Texture is not repeating outside of 0..1 UVs */
  18083. static readonly CLAMP_ADDRESSMODE: number;
  18084. /** Texture is repeating outside of 0..1 UVs */
  18085. static readonly WRAP_ADDRESSMODE: number;
  18086. /** Texture is repeating and mirrored */
  18087. static readonly MIRROR_ADDRESSMODE: number;
  18088. /**
  18089. * 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
  18090. */
  18091. static UseSerializedUrlIfAny: boolean;
  18092. /**
  18093. * Define the url of the texture.
  18094. */
  18095. url: Nullable<string>;
  18096. /**
  18097. * Define an offset on the texture to offset the u coordinates of the UVs
  18098. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18099. */
  18100. uOffset: number;
  18101. /**
  18102. * Define an offset on the texture to offset the v coordinates of the UVs
  18103. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18104. */
  18105. vOffset: number;
  18106. /**
  18107. * Define an offset on the texture to scale the u coordinates of the UVs
  18108. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18109. */
  18110. uScale: number;
  18111. /**
  18112. * Define an offset on the texture to scale the v coordinates of the UVs
  18113. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18114. */
  18115. vScale: number;
  18116. /**
  18117. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18118. * @see http://doc.babylonjs.com/how_to/more_materials
  18119. */
  18120. uAng: number;
  18121. /**
  18122. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18123. * @see http://doc.babylonjs.com/how_to/more_materials
  18124. */
  18125. vAng: number;
  18126. /**
  18127. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18128. * @see http://doc.babylonjs.com/how_to/more_materials
  18129. */
  18130. wAng: number;
  18131. /**
  18132. * Defines the center of rotation (U)
  18133. */
  18134. uRotationCenter: number;
  18135. /**
  18136. * Defines the center of rotation (V)
  18137. */
  18138. vRotationCenter: number;
  18139. /**
  18140. * Defines the center of rotation (W)
  18141. */
  18142. wRotationCenter: number;
  18143. /**
  18144. * Are mip maps generated for this texture or not.
  18145. */
  18146. readonly noMipmap: boolean;
  18147. private _noMipmap;
  18148. /** @hidden */
  18149. _invertY: boolean;
  18150. private _rowGenerationMatrix;
  18151. private _cachedTextureMatrix;
  18152. private _projectionModeMatrix;
  18153. private _t0;
  18154. private _t1;
  18155. private _t2;
  18156. private _cachedUOffset;
  18157. private _cachedVOffset;
  18158. private _cachedUScale;
  18159. private _cachedVScale;
  18160. private _cachedUAng;
  18161. private _cachedVAng;
  18162. private _cachedWAng;
  18163. private _cachedProjectionMatrixId;
  18164. private _cachedCoordinatesMode;
  18165. /** @hidden */
  18166. protected _initialSamplingMode: number;
  18167. /** @hidden */
  18168. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18169. private _deleteBuffer;
  18170. protected _format: Nullable<number>;
  18171. private _delayedOnLoad;
  18172. private _delayedOnError;
  18173. /**
  18174. * Observable triggered once the texture has been loaded.
  18175. */
  18176. onLoadObservable: Observable<Texture>;
  18177. protected _isBlocking: boolean;
  18178. /**
  18179. * Is the texture preventing material to render while loading.
  18180. * If false, a default texture will be used instead of the loading one during the preparation step.
  18181. */
  18182. isBlocking: boolean;
  18183. /**
  18184. * Get the current sampling mode associated with the texture.
  18185. */
  18186. readonly samplingMode: number;
  18187. /**
  18188. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18189. */
  18190. readonly invertY: boolean;
  18191. /**
  18192. * Instantiates a new texture.
  18193. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18194. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18195. * @param url define the url of the picture to load as a texture
  18196. * @param scene define the scene the texture will belong to
  18197. * @param noMipmap define if the texture will require mip maps or not
  18198. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18199. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18200. * @param onLoad define a callback triggered when the texture has been loaded
  18201. * @param onError define a callback triggered when an error occurred during the loading session
  18202. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18203. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18204. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18205. */
  18206. 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);
  18207. /**
  18208. * Update the url (and optional buffer) of this texture if url was null during construction.
  18209. * @param url the url of the texture
  18210. * @param buffer the buffer of the texture (defaults to null)
  18211. * @param onLoad callback called when the texture is loaded (defaults to null)
  18212. */
  18213. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18214. /**
  18215. * Finish the loading sequence of a texture flagged as delayed load.
  18216. * @hidden
  18217. */
  18218. delayLoad(): void;
  18219. private _prepareRowForTextureGeneration;
  18220. /**
  18221. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18222. * @returns the transform matrix of the texture.
  18223. */
  18224. getTextureMatrix(): Matrix;
  18225. /**
  18226. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18227. * @returns The reflection texture transform
  18228. */
  18229. getReflectionTextureMatrix(): Matrix;
  18230. /**
  18231. * Clones the texture.
  18232. * @returns the cloned texture
  18233. */
  18234. clone(): Texture;
  18235. /**
  18236. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18237. * @returns The JSON representation of the texture
  18238. */
  18239. serialize(): any;
  18240. /**
  18241. * Get the current class name of the texture useful for serialization or dynamic coding.
  18242. * @returns "Texture"
  18243. */
  18244. getClassName(): string;
  18245. /**
  18246. * Dispose the texture and release its associated resources.
  18247. */
  18248. dispose(): void;
  18249. /**
  18250. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18251. * @param parsedTexture Define the JSON representation of the texture
  18252. * @param scene Define the scene the parsed texture should be instantiated in
  18253. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18254. * @returns The parsed texture if successful
  18255. */
  18256. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18257. /**
  18258. * Creates a texture from its base 64 representation.
  18259. * @param data Define the base64 payload without the data: prefix
  18260. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18261. * @param scene Define the scene the texture should belong to
  18262. * @param noMipmap Forces the texture to not create mip map information if true
  18263. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18264. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18265. * @param onLoad define a callback triggered when the texture has been loaded
  18266. * @param onError define a callback triggered when an error occurred during the loading session
  18267. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18268. * @returns the created texture
  18269. */
  18270. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18271. /**
  18272. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18273. * @param data Define the base64 payload without the data: prefix
  18274. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18275. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18276. * @param scene Define the scene the texture should belong to
  18277. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18278. * @param noMipmap Forces the texture to not create mip map information if true
  18279. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18280. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18281. * @param onLoad define a callback triggered when the texture has been loaded
  18282. * @param onError define a callback triggered when an error occurred during the loading session
  18283. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18284. * @returns the created texture
  18285. */
  18286. 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;
  18287. }
  18288. }
  18289. declare module "babylonjs/Materials/Textures/rawTexture" {
  18290. import { Scene } from "babylonjs/scene";
  18291. import { Texture } from "babylonjs/Materials/Textures/texture";
  18292. /**
  18293. * Raw texture can help creating a texture directly from an array of data.
  18294. * This can be super useful if you either get the data from an uncompressed source or
  18295. * if you wish to create your texture pixel by pixel.
  18296. */
  18297. export class RawTexture extends Texture {
  18298. /**
  18299. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18300. */
  18301. format: number;
  18302. private _engine;
  18303. /**
  18304. * Instantiates a new RawTexture.
  18305. * Raw texture can help creating a texture directly from an array of data.
  18306. * This can be super useful if you either get the data from an uncompressed source or
  18307. * if you wish to create your texture pixel by pixel.
  18308. * @param data define the array of data to use to create the texture
  18309. * @param width define the width of the texture
  18310. * @param height define the height of the texture
  18311. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18312. * @param scene define the scene the texture belongs to
  18313. * @param generateMipMaps define whether mip maps should be generated or not
  18314. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18315. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18316. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18317. */
  18318. constructor(data: ArrayBufferView, width: number, height: number,
  18319. /**
  18320. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18321. */
  18322. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18323. /**
  18324. * Updates the texture underlying data.
  18325. * @param data Define the new data of the texture
  18326. */
  18327. update(data: ArrayBufferView): void;
  18328. /**
  18329. * Creates a luminance texture from some data.
  18330. * @param data Define the texture data
  18331. * @param width Define the width of the texture
  18332. * @param height Define the height of the texture
  18333. * @param scene Define the scene the texture belongs to
  18334. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18335. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18336. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18337. * @returns the luminance texture
  18338. */
  18339. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18340. /**
  18341. * Creates a luminance alpha texture from some data.
  18342. * @param data Define the texture data
  18343. * @param width Define the width of the texture
  18344. * @param height Define the height of the texture
  18345. * @param scene Define the scene the texture belongs to
  18346. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18347. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18348. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18349. * @returns the luminance alpha texture
  18350. */
  18351. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18352. /**
  18353. * Creates an alpha texture from some data.
  18354. * @param data Define the texture data
  18355. * @param width Define the width of the texture
  18356. * @param height Define the height of the texture
  18357. * @param scene Define the scene the texture belongs to
  18358. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18359. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18360. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18361. * @returns the alpha texture
  18362. */
  18363. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18364. /**
  18365. * Creates a RGB texture from some data.
  18366. * @param data Define the texture data
  18367. * @param width Define the width of the texture
  18368. * @param height Define the height of the texture
  18369. * @param scene Define the scene the texture belongs to
  18370. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18371. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18372. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18373. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18374. * @returns the RGB alpha texture
  18375. */
  18376. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18377. /**
  18378. * Creates a RGBA texture from some data.
  18379. * @param data Define the texture data
  18380. * @param width Define the width of the texture
  18381. * @param height Define the height of the texture
  18382. * @param scene Define the scene the texture belongs to
  18383. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18384. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18385. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18386. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18387. * @returns the RGBA texture
  18388. */
  18389. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18390. /**
  18391. * Creates a R texture from some data.
  18392. * @param data Define the texture data
  18393. * @param width Define the width of the texture
  18394. * @param height Define the height of the texture
  18395. * @param scene Define the scene the texture belongs to
  18396. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18397. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18398. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18399. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18400. * @returns the R texture
  18401. */
  18402. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18403. }
  18404. }
  18405. declare module "babylonjs/Animations/runtimeAnimation" {
  18406. import { Animation } from "babylonjs/Animations/animation";
  18407. import { Animatable } from "babylonjs/Animations/animatable";
  18408. import { Scene } from "babylonjs/scene";
  18409. /**
  18410. * Defines a runtime animation
  18411. */
  18412. export class RuntimeAnimation {
  18413. private _events;
  18414. /**
  18415. * The current frame of the runtime animation
  18416. */
  18417. private _currentFrame;
  18418. /**
  18419. * The animation used by the runtime animation
  18420. */
  18421. private _animation;
  18422. /**
  18423. * The target of the runtime animation
  18424. */
  18425. private _target;
  18426. /**
  18427. * The initiating animatable
  18428. */
  18429. private _host;
  18430. /**
  18431. * The original value of the runtime animation
  18432. */
  18433. private _originalValue;
  18434. /**
  18435. * The original blend value of the runtime animation
  18436. */
  18437. private _originalBlendValue;
  18438. /**
  18439. * The offsets cache of the runtime animation
  18440. */
  18441. private _offsetsCache;
  18442. /**
  18443. * The high limits cache of the runtime animation
  18444. */
  18445. private _highLimitsCache;
  18446. /**
  18447. * Specifies if the runtime animation has been stopped
  18448. */
  18449. private _stopped;
  18450. /**
  18451. * The blending factor of the runtime animation
  18452. */
  18453. private _blendingFactor;
  18454. /**
  18455. * The BabylonJS scene
  18456. */
  18457. private _scene;
  18458. /**
  18459. * The current value of the runtime animation
  18460. */
  18461. private _currentValue;
  18462. /** @hidden */
  18463. _workValue: any;
  18464. /**
  18465. * The active target of the runtime animation
  18466. */
  18467. private _activeTarget;
  18468. /**
  18469. * The target path of the runtime animation
  18470. */
  18471. private _targetPath;
  18472. /**
  18473. * The weight of the runtime animation
  18474. */
  18475. private _weight;
  18476. /**
  18477. * The ratio offset of the runtime animation
  18478. */
  18479. private _ratioOffset;
  18480. /**
  18481. * The previous delay of the runtime animation
  18482. */
  18483. private _previousDelay;
  18484. /**
  18485. * The previous ratio of the runtime animation
  18486. */
  18487. private _previousRatio;
  18488. /**
  18489. * Gets the current frame of the runtime animation
  18490. */
  18491. readonly currentFrame: number;
  18492. /**
  18493. * Gets the weight of the runtime animation
  18494. */
  18495. readonly weight: number;
  18496. /**
  18497. * Gets the current value of the runtime animation
  18498. */
  18499. readonly currentValue: any;
  18500. /**
  18501. * Gets the target path of the runtime animation
  18502. */
  18503. readonly targetPath: string;
  18504. /**
  18505. * Gets the actual target of the runtime animation
  18506. */
  18507. readonly target: any;
  18508. /**
  18509. * Create a new RuntimeAnimation object
  18510. * @param target defines the target of the animation
  18511. * @param animation defines the source animation object
  18512. * @param scene defines the hosting scene
  18513. * @param host defines the initiating Animatable
  18514. */
  18515. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18516. /**
  18517. * Gets the animation from the runtime animation
  18518. */
  18519. readonly animation: Animation;
  18520. /**
  18521. * Resets the runtime animation to the beginning
  18522. * @param restoreOriginal defines whether to restore the target property to the original value
  18523. */
  18524. reset(restoreOriginal?: boolean): void;
  18525. /**
  18526. * Specifies if the runtime animation is stopped
  18527. * @returns Boolean specifying if the runtime animation is stopped
  18528. */
  18529. isStopped(): boolean;
  18530. /**
  18531. * Disposes of the runtime animation
  18532. */
  18533. dispose(): void;
  18534. /**
  18535. * Interpolates the animation from the current frame
  18536. * @param currentFrame The frame to interpolate the animation to
  18537. * @param repeatCount The number of times that the animation should loop
  18538. * @param loopMode The type of looping mode to use
  18539. * @param offsetValue Animation offset value
  18540. * @param highLimitValue The high limit value
  18541. * @returns The interpolated value
  18542. */
  18543. private _interpolate;
  18544. /**
  18545. * Apply the interpolated value to the target
  18546. * @param currentValue defines the value computed by the animation
  18547. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18548. */
  18549. setValue(currentValue: any, weight?: number): void;
  18550. private _setValue;
  18551. /**
  18552. * Gets the loop pmode of the runtime animation
  18553. * @returns Loop Mode
  18554. */
  18555. private _getCorrectLoopMode;
  18556. /**
  18557. * Move the current animation to a given frame
  18558. * @param frame defines the frame to move to
  18559. */
  18560. goToFrame(frame: number): void;
  18561. /**
  18562. * @hidden Internal use only
  18563. */
  18564. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18565. /**
  18566. * Execute the current animation
  18567. * @param delay defines the delay to add to the current frame
  18568. * @param from defines the lower bound of the animation range
  18569. * @param to defines the upper bound of the animation range
  18570. * @param loop defines if the current animation must loop
  18571. * @param speedRatio defines the current speed ratio
  18572. * @param weight defines the weight of the animation (default is -1 so no weight)
  18573. * @param onLoop optional callback called when animation loops
  18574. * @returns a boolean indicating if the animation is running
  18575. */
  18576. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18577. }
  18578. }
  18579. declare module "babylonjs/Animations/animatable" {
  18580. import { Animation } from "babylonjs/Animations/animation";
  18581. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18582. import { Nullable } from "babylonjs/types";
  18583. import { Observable } from "babylonjs/Misc/observable";
  18584. import { Scene } from "babylonjs/scene";
  18585. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18586. import { Node } from "babylonjs/node";
  18587. /**
  18588. * Class used to store an actual running animation
  18589. */
  18590. export class Animatable {
  18591. /** defines the target object */
  18592. target: any;
  18593. /** defines the starting frame number (default is 0) */
  18594. fromFrame: number;
  18595. /** defines the ending frame number (default is 100) */
  18596. toFrame: number;
  18597. /** defines if the animation must loop (default is false) */
  18598. loopAnimation: boolean;
  18599. /** defines a callback to call when animation ends if it is not looping */
  18600. onAnimationEnd?: (() => void) | null | undefined;
  18601. /** defines a callback to call when animation loops */
  18602. onAnimationLoop?: (() => void) | null | undefined;
  18603. private _localDelayOffset;
  18604. private _pausedDelay;
  18605. private _runtimeAnimations;
  18606. private _paused;
  18607. private _scene;
  18608. private _speedRatio;
  18609. private _weight;
  18610. private _syncRoot;
  18611. /**
  18612. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18613. * This will only apply for non looping animation (default is true)
  18614. */
  18615. disposeOnEnd: boolean;
  18616. /**
  18617. * Gets a boolean indicating if the animation has started
  18618. */
  18619. animationStarted: boolean;
  18620. /**
  18621. * Observer raised when the animation ends
  18622. */
  18623. onAnimationEndObservable: Observable<Animatable>;
  18624. /**
  18625. * Observer raised when the animation loops
  18626. */
  18627. onAnimationLoopObservable: Observable<Animatable>;
  18628. /**
  18629. * Gets the root Animatable used to synchronize and normalize animations
  18630. */
  18631. readonly syncRoot: Animatable;
  18632. /**
  18633. * Gets the current frame of the first RuntimeAnimation
  18634. * Used to synchronize Animatables
  18635. */
  18636. readonly masterFrame: number;
  18637. /**
  18638. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18639. */
  18640. weight: number;
  18641. /**
  18642. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18643. */
  18644. speedRatio: number;
  18645. /**
  18646. * Creates a new Animatable
  18647. * @param scene defines the hosting scene
  18648. * @param target defines the target object
  18649. * @param fromFrame defines the starting frame number (default is 0)
  18650. * @param toFrame defines the ending frame number (default is 100)
  18651. * @param loopAnimation defines if the animation must loop (default is false)
  18652. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18653. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18654. * @param animations defines a group of animation to add to the new Animatable
  18655. * @param onAnimationLoop defines a callback to call when animation loops
  18656. */
  18657. constructor(scene: Scene,
  18658. /** defines the target object */
  18659. target: any,
  18660. /** defines the starting frame number (default is 0) */
  18661. fromFrame?: number,
  18662. /** defines the ending frame number (default is 100) */
  18663. toFrame?: number,
  18664. /** defines if the animation must loop (default is false) */
  18665. loopAnimation?: boolean, speedRatio?: number,
  18666. /** defines a callback to call when animation ends if it is not looping */
  18667. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18668. /** defines a callback to call when animation loops */
  18669. onAnimationLoop?: (() => void) | null | undefined);
  18670. /**
  18671. * Synchronize and normalize current Animatable with a source Animatable
  18672. * This is useful when using animation weights and when animations are not of the same length
  18673. * @param root defines the root Animatable to synchronize with
  18674. * @returns the current Animatable
  18675. */
  18676. syncWith(root: Animatable): Animatable;
  18677. /**
  18678. * Gets the list of runtime animations
  18679. * @returns an array of RuntimeAnimation
  18680. */
  18681. getAnimations(): RuntimeAnimation[];
  18682. /**
  18683. * Adds more animations to the current animatable
  18684. * @param target defines the target of the animations
  18685. * @param animations defines the new animations to add
  18686. */
  18687. appendAnimations(target: any, animations: Animation[]): void;
  18688. /**
  18689. * Gets the source animation for a specific property
  18690. * @param property defines the propertyu to look for
  18691. * @returns null or the source animation for the given property
  18692. */
  18693. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18694. /**
  18695. * Gets the runtime animation for a specific property
  18696. * @param property defines the propertyu to look for
  18697. * @returns null or the runtime animation for the given property
  18698. */
  18699. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18700. /**
  18701. * Resets the animatable to its original state
  18702. */
  18703. reset(): void;
  18704. /**
  18705. * Allows the animatable to blend with current running animations
  18706. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18707. * @param blendingSpeed defines the blending speed to use
  18708. */
  18709. enableBlending(blendingSpeed: number): void;
  18710. /**
  18711. * Disable animation blending
  18712. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18713. */
  18714. disableBlending(): void;
  18715. /**
  18716. * Jump directly to a given frame
  18717. * @param frame defines the frame to jump to
  18718. */
  18719. goToFrame(frame: number): void;
  18720. /**
  18721. * Pause the animation
  18722. */
  18723. pause(): void;
  18724. /**
  18725. * Restart the animation
  18726. */
  18727. restart(): void;
  18728. private _raiseOnAnimationEnd;
  18729. /**
  18730. * Stop and delete the current animation
  18731. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18732. * @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)
  18733. */
  18734. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18735. /**
  18736. * Wait asynchronously for the animation to end
  18737. * @returns a promise which will be fullfilled when the animation ends
  18738. */
  18739. waitAsync(): Promise<Animatable>;
  18740. /** @hidden */
  18741. _animate(delay: number): boolean;
  18742. }
  18743. module "babylonjs/scene" {
  18744. interface Scene {
  18745. /** @hidden */
  18746. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18747. /** @hidden */
  18748. _processLateAnimationBindingsForMatrices(holder: {
  18749. totalWeight: number;
  18750. animations: RuntimeAnimation[];
  18751. originalValue: Matrix;
  18752. }): any;
  18753. /** @hidden */
  18754. _processLateAnimationBindingsForQuaternions(holder: {
  18755. totalWeight: number;
  18756. animations: RuntimeAnimation[];
  18757. originalValue: Quaternion;
  18758. }, refQuaternion: Quaternion): Quaternion;
  18759. /** @hidden */
  18760. _processLateAnimationBindings(): void;
  18761. /**
  18762. * Will start the animation sequence of a given target
  18763. * @param target defines the target
  18764. * @param from defines from which frame should animation start
  18765. * @param to defines until which frame should animation run.
  18766. * @param weight defines the weight to apply to the animation (1.0 by default)
  18767. * @param loop defines if the animation loops
  18768. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18769. * @param onAnimationEnd defines the function to be executed when the animation ends
  18770. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18771. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18772. * @param onAnimationLoop defines the callback to call when an animation loops
  18773. * @returns the animatable object created for this animation
  18774. */
  18775. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18776. /**
  18777. * Will start the animation sequence of a given target
  18778. * @param target defines the target
  18779. * @param from defines from which frame should animation start
  18780. * @param to defines until which frame should animation run.
  18781. * @param loop defines if the animation loops
  18782. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18783. * @param onAnimationEnd defines the function to be executed when the animation ends
  18784. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18785. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18786. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18787. * @param onAnimationLoop defines the callback to call when an animation loops
  18788. * @returns the animatable object created for this animation
  18789. */
  18790. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18791. /**
  18792. * Will start the animation sequence of a given target and its hierarchy
  18793. * @param target defines the target
  18794. * @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.
  18795. * @param from defines from which frame should animation start
  18796. * @param to defines until which frame should animation run.
  18797. * @param loop defines if the animation loops
  18798. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18799. * @param onAnimationEnd defines the function to be executed when the animation ends
  18800. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18801. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18802. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18803. * @param onAnimationLoop defines the callback to call when an animation loops
  18804. * @returns the list of created animatables
  18805. */
  18806. 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[];
  18807. /**
  18808. * Begin a new animation on a given node
  18809. * @param target defines the target where the animation will take place
  18810. * @param animations defines the list of animations to start
  18811. * @param from defines the initial value
  18812. * @param to defines the final value
  18813. * @param loop defines if you want animation to loop (off by default)
  18814. * @param speedRatio defines the speed ratio to apply to all animations
  18815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18816. * @param onAnimationLoop defines the callback to call when an animation loops
  18817. * @returns the list of created animatables
  18818. */
  18819. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18820. /**
  18821. * Begin a new animation on a given node and its hierarchy
  18822. * @param target defines the root node where the animation will take place
  18823. * @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.
  18824. * @param animations defines the list of animations to start
  18825. * @param from defines the initial value
  18826. * @param to defines the final value
  18827. * @param loop defines if you want animation to loop (off by default)
  18828. * @param speedRatio defines the speed ratio to apply to all animations
  18829. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18830. * @param onAnimationLoop defines the callback to call when an animation loops
  18831. * @returns the list of animatables created for all nodes
  18832. */
  18833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18834. /**
  18835. * Gets the animatable associated with a specific target
  18836. * @param target defines the target of the animatable
  18837. * @returns the required animatable if found
  18838. */
  18839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18840. /**
  18841. * Gets all animatables associated with a given target
  18842. * @param target defines the target to look animatables for
  18843. * @returns an array of Animatables
  18844. */
  18845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18846. /**
  18847. * Will stop the animation of the given target
  18848. * @param target - the target
  18849. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18850. * @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)
  18851. */
  18852. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18853. /**
  18854. * Stops and removes all animations that have been applied to the scene
  18855. */
  18856. stopAllAnimations(): void;
  18857. }
  18858. }
  18859. module "babylonjs/Bones/bone" {
  18860. interface Bone {
  18861. /**
  18862. * Copy an animation range from another bone
  18863. * @param source defines the source bone
  18864. * @param rangeName defines the range name to copy
  18865. * @param frameOffset defines the frame offset
  18866. * @param rescaleAsRequired defines if rescaling must be applied if required
  18867. * @param skelDimensionsRatio defines the scaling ratio
  18868. * @returns true if operation was successful
  18869. */
  18870. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18871. }
  18872. }
  18873. }
  18874. declare module "babylonjs/Bones/skeleton" {
  18875. import { Bone } from "babylonjs/Bones/bone";
  18876. import { IAnimatable } from "babylonjs/Misc/tools";
  18877. import { Observable } from "babylonjs/Misc/observable";
  18878. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18879. import { Scene } from "babylonjs/scene";
  18880. import { Nullable } from "babylonjs/types";
  18881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18882. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18883. import { Animatable } from "babylonjs/Animations/animatable";
  18884. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18885. import { Animation } from "babylonjs/Animations/animation";
  18886. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18887. /**
  18888. * Class used to handle skinning animations
  18889. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18890. */
  18891. export class Skeleton implements IAnimatable {
  18892. /** defines the skeleton name */
  18893. name: string;
  18894. /** defines the skeleton Id */
  18895. id: string;
  18896. /**
  18897. * Defines the list of child bones
  18898. */
  18899. bones: Bone[];
  18900. /**
  18901. * Defines an estimate of the dimension of the skeleton at rest
  18902. */
  18903. dimensionsAtRest: Vector3;
  18904. /**
  18905. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18906. */
  18907. needInitialSkinMatrix: boolean;
  18908. /**
  18909. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18910. */
  18911. overrideMesh: Nullable<AbstractMesh>;
  18912. /**
  18913. * Gets the list of animations attached to this skeleton
  18914. */
  18915. animations: Array<Animation>;
  18916. private _scene;
  18917. private _isDirty;
  18918. private _transformMatrices;
  18919. private _transformMatrixTexture;
  18920. private _meshesWithPoseMatrix;
  18921. private _animatables;
  18922. private _identity;
  18923. private _synchronizedWithMesh;
  18924. private _ranges;
  18925. private _lastAbsoluteTransformsUpdateId;
  18926. private _canUseTextureForBones;
  18927. /** @hidden */
  18928. _numBonesWithLinkedTransformNode: number;
  18929. /**
  18930. * Specifies if the skeleton should be serialized
  18931. */
  18932. doNotSerialize: boolean;
  18933. /**
  18934. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18935. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18936. */
  18937. useTextureToStoreBoneMatrices: boolean;
  18938. private _animationPropertiesOverride;
  18939. /**
  18940. * Gets or sets the animation properties override
  18941. */
  18942. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18943. /**
  18944. * An observable triggered before computing the skeleton's matrices
  18945. */
  18946. onBeforeComputeObservable: Observable<Skeleton>;
  18947. /**
  18948. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18949. */
  18950. readonly isUsingTextureForMatrices: boolean;
  18951. /**
  18952. * Creates a new skeleton
  18953. * @param name defines the skeleton name
  18954. * @param id defines the skeleton Id
  18955. * @param scene defines the hosting scene
  18956. */
  18957. constructor(
  18958. /** defines the skeleton name */
  18959. name: string,
  18960. /** defines the skeleton Id */
  18961. id: string, scene: Scene);
  18962. /**
  18963. * Gets the current object class name.
  18964. * @return the class name
  18965. */
  18966. getClassName(): string;
  18967. /**
  18968. * Returns an array containing the root bones
  18969. * @returns an array containing the root bones
  18970. */
  18971. getChildren(): Array<Bone>;
  18972. /**
  18973. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18974. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18975. * @returns a Float32Array containing matrices data
  18976. */
  18977. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18978. /**
  18979. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18980. * @returns a raw texture containing the data
  18981. */
  18982. getTransformMatrixTexture(): Nullable<RawTexture>;
  18983. /**
  18984. * Gets the current hosting scene
  18985. * @returns a scene object
  18986. */
  18987. getScene(): Scene;
  18988. /**
  18989. * Gets a string representing the current skeleton data
  18990. * @param fullDetails defines a boolean indicating if we want a verbose version
  18991. * @returns a string representing the current skeleton data
  18992. */
  18993. toString(fullDetails?: boolean): string;
  18994. /**
  18995. * Get bone's index searching by name
  18996. * @param name defines bone's name to search for
  18997. * @return the indice of the bone. Returns -1 if not found
  18998. */
  18999. getBoneIndexByName(name: string): number;
  19000. /**
  19001. * Creater a new animation range
  19002. * @param name defines the name of the range
  19003. * @param from defines the start key
  19004. * @param to defines the end key
  19005. */
  19006. createAnimationRange(name: string, from: number, to: number): void;
  19007. /**
  19008. * Delete a specific animation range
  19009. * @param name defines the name of the range
  19010. * @param deleteFrames defines if frames must be removed as well
  19011. */
  19012. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19013. /**
  19014. * Gets a specific animation range
  19015. * @param name defines the name of the range to look for
  19016. * @returns the requested animation range or null if not found
  19017. */
  19018. getAnimationRange(name: string): Nullable<AnimationRange>;
  19019. /**
  19020. * Gets the list of all animation ranges defined on this skeleton
  19021. * @returns an array
  19022. */
  19023. getAnimationRanges(): Nullable<AnimationRange>[];
  19024. /**
  19025. * Copy animation range from a source skeleton.
  19026. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19027. * @param source defines the source skeleton
  19028. * @param name defines the name of the range to copy
  19029. * @param rescaleAsRequired defines if rescaling must be applied if required
  19030. * @returns true if operation was successful
  19031. */
  19032. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19033. /**
  19034. * Forces the skeleton to go to rest pose
  19035. */
  19036. returnToRest(): void;
  19037. private _getHighestAnimationFrame;
  19038. /**
  19039. * Begin a specific animation range
  19040. * @param name defines the name of the range to start
  19041. * @param loop defines if looping must be turned on (false by default)
  19042. * @param speedRatio defines the speed ratio to apply (1 by default)
  19043. * @param onAnimationEnd defines a callback which will be called when animation will end
  19044. * @returns a new animatable
  19045. */
  19046. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19047. /** @hidden */
  19048. _markAsDirty(): void;
  19049. /** @hidden */
  19050. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19051. /** @hidden */
  19052. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19053. private _computeTransformMatrices;
  19054. /**
  19055. * Build all resources required to render a skeleton
  19056. */
  19057. prepare(): void;
  19058. /**
  19059. * Gets the list of animatables currently running for this skeleton
  19060. * @returns an array of animatables
  19061. */
  19062. getAnimatables(): IAnimatable[];
  19063. /**
  19064. * Clone the current skeleton
  19065. * @param name defines the name of the new skeleton
  19066. * @param id defines the id of the enw skeleton
  19067. * @returns the new skeleton
  19068. */
  19069. clone(name: string, id: string): Skeleton;
  19070. /**
  19071. * Enable animation blending for this skeleton
  19072. * @param blendingSpeed defines the blending speed to apply
  19073. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19074. */
  19075. enableBlending(blendingSpeed?: number): void;
  19076. /**
  19077. * Releases all resources associated with the current skeleton
  19078. */
  19079. dispose(): void;
  19080. /**
  19081. * Serialize the skeleton in a JSON object
  19082. * @returns a JSON object
  19083. */
  19084. serialize(): any;
  19085. /**
  19086. * Creates a new skeleton from serialized data
  19087. * @param parsedSkeleton defines the serialized data
  19088. * @param scene defines the hosting scene
  19089. * @returns a new skeleton
  19090. */
  19091. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19092. /**
  19093. * Compute all node absolute transforms
  19094. * @param forceUpdate defines if computation must be done even if cache is up to date
  19095. */
  19096. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19097. /**
  19098. * Gets the root pose matrix
  19099. * @returns a matrix
  19100. */
  19101. getPoseMatrix(): Nullable<Matrix>;
  19102. /**
  19103. * Sorts bones per internal index
  19104. */
  19105. sortBones(): void;
  19106. private _sortBones;
  19107. }
  19108. }
  19109. declare module "babylonjs/Morph/morphTarget" {
  19110. import { IAnimatable } from "babylonjs/Misc/tools";
  19111. import { Observable } from "babylonjs/Misc/observable";
  19112. import { Nullable, FloatArray } from "babylonjs/types";
  19113. import { Scene } from "babylonjs/scene";
  19114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19115. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19116. /**
  19117. * Defines a target to use with MorphTargetManager
  19118. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19119. */
  19120. export class MorphTarget implements IAnimatable {
  19121. /** defines the name of the target */
  19122. name: string;
  19123. /**
  19124. * Gets or sets the list of animations
  19125. */
  19126. animations: import("babylonjs/Animations/animation").Animation[];
  19127. private _scene;
  19128. private _positions;
  19129. private _normals;
  19130. private _tangents;
  19131. private _influence;
  19132. /**
  19133. * Observable raised when the influence changes
  19134. */
  19135. onInfluenceChanged: Observable<boolean>;
  19136. /** @hidden */
  19137. _onDataLayoutChanged: Observable<void>;
  19138. /**
  19139. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19140. */
  19141. influence: number;
  19142. /**
  19143. * Gets or sets the id of the morph Target
  19144. */
  19145. id: string;
  19146. private _animationPropertiesOverride;
  19147. /**
  19148. * Gets or sets the animation properties override
  19149. */
  19150. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19151. /**
  19152. * Creates a new MorphTarget
  19153. * @param name defines the name of the target
  19154. * @param influence defines the influence to use
  19155. * @param scene defines the scene the morphtarget belongs to
  19156. */
  19157. constructor(
  19158. /** defines the name of the target */
  19159. name: string, influence?: number, scene?: Nullable<Scene>);
  19160. /**
  19161. * Gets a boolean defining if the target contains position data
  19162. */
  19163. readonly hasPositions: boolean;
  19164. /**
  19165. * Gets a boolean defining if the target contains normal data
  19166. */
  19167. readonly hasNormals: boolean;
  19168. /**
  19169. * Gets a boolean defining if the target contains tangent data
  19170. */
  19171. readonly hasTangents: boolean;
  19172. /**
  19173. * Affects position data to this target
  19174. * @param data defines the position data to use
  19175. */
  19176. setPositions(data: Nullable<FloatArray>): void;
  19177. /**
  19178. * Gets the position data stored in this target
  19179. * @returns a FloatArray containing the position data (or null if not present)
  19180. */
  19181. getPositions(): Nullable<FloatArray>;
  19182. /**
  19183. * Affects normal data to this target
  19184. * @param data defines the normal data to use
  19185. */
  19186. setNormals(data: Nullable<FloatArray>): void;
  19187. /**
  19188. * Gets the normal data stored in this target
  19189. * @returns a FloatArray containing the normal data (or null if not present)
  19190. */
  19191. getNormals(): Nullable<FloatArray>;
  19192. /**
  19193. * Affects tangent data to this target
  19194. * @param data defines the tangent data to use
  19195. */
  19196. setTangents(data: Nullable<FloatArray>): void;
  19197. /**
  19198. * Gets the tangent data stored in this target
  19199. * @returns a FloatArray containing the tangent data (or null if not present)
  19200. */
  19201. getTangents(): Nullable<FloatArray>;
  19202. /**
  19203. * Serializes the current target into a Serialization object
  19204. * @returns the serialized object
  19205. */
  19206. serialize(): any;
  19207. /**
  19208. * Returns the string "MorphTarget"
  19209. * @returns "MorphTarget"
  19210. */
  19211. getClassName(): string;
  19212. /**
  19213. * Creates a new target from serialized data
  19214. * @param serializationObject defines the serialized data to use
  19215. * @returns a new MorphTarget
  19216. */
  19217. static Parse(serializationObject: any): MorphTarget;
  19218. /**
  19219. * Creates a MorphTarget from mesh data
  19220. * @param mesh defines the source mesh
  19221. * @param name defines the name to use for the new target
  19222. * @param influence defines the influence to attach to the target
  19223. * @returns a new MorphTarget
  19224. */
  19225. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19226. }
  19227. }
  19228. declare module "babylonjs/Morph/morphTargetManager" {
  19229. import { Nullable } from "babylonjs/types";
  19230. import { Scene } from "babylonjs/scene";
  19231. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19232. /**
  19233. * This class is used to deform meshes using morphing between different targets
  19234. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19235. */
  19236. export class MorphTargetManager {
  19237. private _targets;
  19238. private _targetInfluenceChangedObservers;
  19239. private _targetDataLayoutChangedObservers;
  19240. private _activeTargets;
  19241. private _scene;
  19242. private _influences;
  19243. private _supportsNormals;
  19244. private _supportsTangents;
  19245. private _vertexCount;
  19246. private _uniqueId;
  19247. private _tempInfluences;
  19248. /**
  19249. * Creates a new MorphTargetManager
  19250. * @param scene defines the current scene
  19251. */
  19252. constructor(scene?: Nullable<Scene>);
  19253. /**
  19254. * Gets the unique ID of this manager
  19255. */
  19256. readonly uniqueId: number;
  19257. /**
  19258. * Gets the number of vertices handled by this manager
  19259. */
  19260. readonly vertexCount: number;
  19261. /**
  19262. * Gets a boolean indicating if this manager supports morphing of normals
  19263. */
  19264. readonly supportsNormals: boolean;
  19265. /**
  19266. * Gets a boolean indicating if this manager supports morphing of tangents
  19267. */
  19268. readonly supportsTangents: boolean;
  19269. /**
  19270. * Gets the number of targets stored in this manager
  19271. */
  19272. readonly numTargets: number;
  19273. /**
  19274. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19275. */
  19276. readonly numInfluencers: number;
  19277. /**
  19278. * Gets the list of influences (one per target)
  19279. */
  19280. readonly influences: Float32Array;
  19281. /**
  19282. * Gets the active target at specified index. An active target is a target with an influence > 0
  19283. * @param index defines the index to check
  19284. * @returns the requested target
  19285. */
  19286. getActiveTarget(index: number): MorphTarget;
  19287. /**
  19288. * Gets the target at specified index
  19289. * @param index defines the index to check
  19290. * @returns the requested target
  19291. */
  19292. getTarget(index: number): MorphTarget;
  19293. /**
  19294. * Add a new target to this manager
  19295. * @param target defines the target to add
  19296. */
  19297. addTarget(target: MorphTarget): void;
  19298. /**
  19299. * Removes a target from the manager
  19300. * @param target defines the target to remove
  19301. */
  19302. removeTarget(target: MorphTarget): void;
  19303. /**
  19304. * Serializes the current manager into a Serialization object
  19305. * @returns the serialized object
  19306. */
  19307. serialize(): any;
  19308. private _syncActiveTargets;
  19309. /**
  19310. * Syncrhonize the targets with all the meshes using this morph target manager
  19311. */
  19312. synchronize(): void;
  19313. /**
  19314. * Creates a new MorphTargetManager from serialized data
  19315. * @param serializationObject defines the serialized data
  19316. * @param scene defines the hosting scene
  19317. * @returns the new MorphTargetManager
  19318. */
  19319. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19320. }
  19321. }
  19322. declare module "babylonjs/Meshes/groundMesh" {
  19323. import { Scene } from "babylonjs/scene";
  19324. import { Vector3 } from "babylonjs/Maths/math";
  19325. import { Mesh } from "babylonjs/Meshes/mesh";
  19326. /**
  19327. * Mesh representing the gorund
  19328. */
  19329. export class GroundMesh extends Mesh {
  19330. /** If octree should be generated */
  19331. generateOctree: boolean;
  19332. private _heightQuads;
  19333. /** @hidden */
  19334. _subdivisionsX: number;
  19335. /** @hidden */
  19336. _subdivisionsY: number;
  19337. /** @hidden */
  19338. _width: number;
  19339. /** @hidden */
  19340. _height: number;
  19341. /** @hidden */
  19342. _minX: number;
  19343. /** @hidden */
  19344. _maxX: number;
  19345. /** @hidden */
  19346. _minZ: number;
  19347. /** @hidden */
  19348. _maxZ: number;
  19349. constructor(name: string, scene: Scene);
  19350. /**
  19351. * "GroundMesh"
  19352. * @returns "GroundMesh"
  19353. */
  19354. getClassName(): string;
  19355. /**
  19356. * The minimum of x and y subdivisions
  19357. */
  19358. readonly subdivisions: number;
  19359. /**
  19360. * X subdivisions
  19361. */
  19362. readonly subdivisionsX: number;
  19363. /**
  19364. * Y subdivisions
  19365. */
  19366. readonly subdivisionsY: number;
  19367. /**
  19368. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19369. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19370. * @param chunksCount the number of subdivisions for x and y
  19371. * @param octreeBlocksSize (Default: 32)
  19372. */
  19373. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19374. /**
  19375. * Returns a height (y) value in the Worl system :
  19376. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19377. * @param x x coordinate
  19378. * @param z z coordinate
  19379. * @returns the ground y position if (x, z) are outside the ground surface.
  19380. */
  19381. getHeightAtCoordinates(x: number, z: number): number;
  19382. /**
  19383. * Returns a normalized vector (Vector3) orthogonal to the ground
  19384. * at the ground coordinates (x, z) expressed in the World system.
  19385. * @param x x coordinate
  19386. * @param z z coordinate
  19387. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19388. */
  19389. getNormalAtCoordinates(x: number, z: number): Vector3;
  19390. /**
  19391. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19392. * at the ground coordinates (x, z) expressed in the World system.
  19393. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19394. * @param x x coordinate
  19395. * @param z z coordinate
  19396. * @param ref vector to store the result
  19397. * @returns the GroundMesh.
  19398. */
  19399. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19400. /**
  19401. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19402. * if the ground has been updated.
  19403. * This can be used in the render loop.
  19404. * @returns the GroundMesh.
  19405. */
  19406. updateCoordinateHeights(): GroundMesh;
  19407. private _getFacetAt;
  19408. private _initHeightQuads;
  19409. private _computeHeightQuads;
  19410. /**
  19411. * Serializes this ground mesh
  19412. * @param serializationObject object to write serialization to
  19413. */
  19414. serialize(serializationObject: any): void;
  19415. /**
  19416. * Parses a serialized ground mesh
  19417. * @param parsedMesh the serialized mesh
  19418. * @param scene the scene to create the ground mesh in
  19419. * @returns the created ground mesh
  19420. */
  19421. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19422. }
  19423. }
  19424. declare module "babylonjs/Physics/physicsJoint" {
  19425. import { Vector3 } from "babylonjs/Maths/math";
  19426. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19427. /**
  19428. * Interface for Physics-Joint data
  19429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19430. */
  19431. export interface PhysicsJointData {
  19432. /**
  19433. * The main pivot of the joint
  19434. */
  19435. mainPivot?: Vector3;
  19436. /**
  19437. * The connected pivot of the joint
  19438. */
  19439. connectedPivot?: Vector3;
  19440. /**
  19441. * The main axis of the joint
  19442. */
  19443. mainAxis?: Vector3;
  19444. /**
  19445. * The connected axis of the joint
  19446. */
  19447. connectedAxis?: Vector3;
  19448. /**
  19449. * The collision of the joint
  19450. */
  19451. collision?: boolean;
  19452. /**
  19453. * Native Oimo/Cannon/Energy data
  19454. */
  19455. nativeParams?: any;
  19456. }
  19457. /**
  19458. * This is a holder class for the physics joint created by the physics plugin
  19459. * It holds a set of functions to control the underlying joint
  19460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19461. */
  19462. export class PhysicsJoint {
  19463. /**
  19464. * The type of the physics joint
  19465. */
  19466. type: number;
  19467. /**
  19468. * The data for the physics joint
  19469. */
  19470. jointData: PhysicsJointData;
  19471. private _physicsJoint;
  19472. protected _physicsPlugin: IPhysicsEnginePlugin;
  19473. /**
  19474. * Initializes the physics joint
  19475. * @param type The type of the physics joint
  19476. * @param jointData The data for the physics joint
  19477. */
  19478. constructor(
  19479. /**
  19480. * The type of the physics joint
  19481. */
  19482. type: number,
  19483. /**
  19484. * The data for the physics joint
  19485. */
  19486. jointData: PhysicsJointData);
  19487. /**
  19488. * Gets the physics joint
  19489. */
  19490. /**
  19491. * Sets the physics joint
  19492. */
  19493. physicsJoint: any;
  19494. /**
  19495. * Sets the physics plugin
  19496. */
  19497. physicsPlugin: IPhysicsEnginePlugin;
  19498. /**
  19499. * Execute a function that is physics-plugin specific.
  19500. * @param {Function} func the function that will be executed.
  19501. * It accepts two parameters: the physics world and the physics joint
  19502. */
  19503. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19504. /**
  19505. * Distance-Joint type
  19506. */
  19507. static DistanceJoint: number;
  19508. /**
  19509. * Hinge-Joint type
  19510. */
  19511. static HingeJoint: number;
  19512. /**
  19513. * Ball-and-Socket joint type
  19514. */
  19515. static BallAndSocketJoint: number;
  19516. /**
  19517. * Wheel-Joint type
  19518. */
  19519. static WheelJoint: number;
  19520. /**
  19521. * Slider-Joint type
  19522. */
  19523. static SliderJoint: number;
  19524. /**
  19525. * Prismatic-Joint type
  19526. */
  19527. static PrismaticJoint: number;
  19528. /**
  19529. * Universal-Joint type
  19530. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19531. */
  19532. static UniversalJoint: number;
  19533. /**
  19534. * Hinge-Joint 2 type
  19535. */
  19536. static Hinge2Joint: number;
  19537. /**
  19538. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19539. */
  19540. static PointToPointJoint: number;
  19541. /**
  19542. * Spring-Joint type
  19543. */
  19544. static SpringJoint: number;
  19545. /**
  19546. * Lock-Joint type
  19547. */
  19548. static LockJoint: number;
  19549. }
  19550. /**
  19551. * A class representing a physics distance joint
  19552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19553. */
  19554. export class DistanceJoint extends PhysicsJoint {
  19555. /**
  19556. *
  19557. * @param jointData The data for the Distance-Joint
  19558. */
  19559. constructor(jointData: DistanceJointData);
  19560. /**
  19561. * Update the predefined distance.
  19562. * @param maxDistance The maximum preferred distance
  19563. * @param minDistance The minimum preferred distance
  19564. */
  19565. updateDistance(maxDistance: number, minDistance?: number): void;
  19566. }
  19567. /**
  19568. * Represents a Motor-Enabled Joint
  19569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19570. */
  19571. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19572. /**
  19573. * Initializes the Motor-Enabled Joint
  19574. * @param type The type of the joint
  19575. * @param jointData The physica joint data for the joint
  19576. */
  19577. constructor(type: number, jointData: PhysicsJointData);
  19578. /**
  19579. * Set the motor values.
  19580. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19581. * @param force the force to apply
  19582. * @param maxForce max force for this motor.
  19583. */
  19584. setMotor(force?: number, maxForce?: number): void;
  19585. /**
  19586. * Set the motor's limits.
  19587. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19588. * @param upperLimit The upper limit of the motor
  19589. * @param lowerLimit The lower limit of the motor
  19590. */
  19591. setLimit(upperLimit: number, lowerLimit?: number): void;
  19592. }
  19593. /**
  19594. * This class represents a single physics Hinge-Joint
  19595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19596. */
  19597. export class HingeJoint extends MotorEnabledJoint {
  19598. /**
  19599. * Initializes the Hinge-Joint
  19600. * @param jointData The joint data for the Hinge-Joint
  19601. */
  19602. constructor(jointData: PhysicsJointData);
  19603. /**
  19604. * Set the motor values.
  19605. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19606. * @param {number} force the force to apply
  19607. * @param {number} maxForce max force for this motor.
  19608. */
  19609. setMotor(force?: number, maxForce?: number): void;
  19610. /**
  19611. * Set the motor's limits.
  19612. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19613. * @param upperLimit The upper limit of the motor
  19614. * @param lowerLimit The lower limit of the motor
  19615. */
  19616. setLimit(upperLimit: number, lowerLimit?: number): void;
  19617. }
  19618. /**
  19619. * This class represents a dual hinge physics joint (same as wheel joint)
  19620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19621. */
  19622. export class Hinge2Joint extends MotorEnabledJoint {
  19623. /**
  19624. * Initializes the Hinge2-Joint
  19625. * @param jointData The joint data for the Hinge2-Joint
  19626. */
  19627. constructor(jointData: PhysicsJointData);
  19628. /**
  19629. * Set the motor values.
  19630. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19631. * @param {number} targetSpeed the speed the motor is to reach
  19632. * @param {number} maxForce max force for this motor.
  19633. * @param {motorIndex} the motor's index, 0 or 1.
  19634. */
  19635. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19636. /**
  19637. * Set the motor limits.
  19638. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19639. * @param {number} upperLimit the upper limit
  19640. * @param {number} lowerLimit lower limit
  19641. * @param {motorIndex} the motor's index, 0 or 1.
  19642. */
  19643. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19644. }
  19645. /**
  19646. * Interface for a motor enabled joint
  19647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19648. */
  19649. export interface IMotorEnabledJoint {
  19650. /**
  19651. * Physics joint
  19652. */
  19653. physicsJoint: any;
  19654. /**
  19655. * Sets the motor of the motor-enabled joint
  19656. * @param force The force of the motor
  19657. * @param maxForce The maximum force of the motor
  19658. * @param motorIndex The index of the motor
  19659. */
  19660. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19661. /**
  19662. * Sets the limit of the motor
  19663. * @param upperLimit The upper limit of the motor
  19664. * @param lowerLimit The lower limit of the motor
  19665. * @param motorIndex The index of the motor
  19666. */
  19667. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19668. }
  19669. /**
  19670. * Joint data for a Distance-Joint
  19671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19672. */
  19673. export interface DistanceJointData extends PhysicsJointData {
  19674. /**
  19675. * Max distance the 2 joint objects can be apart
  19676. */
  19677. maxDistance: number;
  19678. }
  19679. /**
  19680. * Joint data from a spring joint
  19681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19682. */
  19683. export interface SpringJointData extends PhysicsJointData {
  19684. /**
  19685. * Length of the spring
  19686. */
  19687. length: number;
  19688. /**
  19689. * Stiffness of the spring
  19690. */
  19691. stiffness: number;
  19692. /**
  19693. * Damping of the spring
  19694. */
  19695. damping: number;
  19696. /** this callback will be called when applying the force to the impostors. */
  19697. forceApplicationCallback: () => void;
  19698. }
  19699. }
  19700. declare module "babylonjs/Physics/IPhysicsEngine" {
  19701. import { Nullable } from "babylonjs/types";
  19702. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19704. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19705. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19706. /**
  19707. * Interface used to describe a physics joint
  19708. */
  19709. export interface PhysicsImpostorJoint {
  19710. /** Defines the main impostor to which the joint is linked */
  19711. mainImpostor: PhysicsImpostor;
  19712. /** Defines the impostor that is connected to the main impostor using this joint */
  19713. connectedImpostor: PhysicsImpostor;
  19714. /** Defines the joint itself */
  19715. joint: PhysicsJoint;
  19716. }
  19717. /** @hidden */
  19718. export interface IPhysicsEnginePlugin {
  19719. world: any;
  19720. name: string;
  19721. setGravity(gravity: Vector3): void;
  19722. setTimeStep(timeStep: number): void;
  19723. getTimeStep(): number;
  19724. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19725. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19726. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19727. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19728. removePhysicsBody(impostor: PhysicsImpostor): void;
  19729. generateJoint(joint: PhysicsImpostorJoint): void;
  19730. removeJoint(joint: PhysicsImpostorJoint): void;
  19731. isSupported(): boolean;
  19732. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19733. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19734. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19735. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19736. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19737. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19738. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19739. getBodyMass(impostor: PhysicsImpostor): number;
  19740. getBodyFriction(impostor: PhysicsImpostor): number;
  19741. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19742. getBodyRestitution(impostor: PhysicsImpostor): number;
  19743. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19744. sleepBody(impostor: PhysicsImpostor): void;
  19745. wakeUpBody(impostor: PhysicsImpostor): void;
  19746. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19747. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19748. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19749. getRadius(impostor: PhysicsImpostor): number;
  19750. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19751. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19752. dispose(): void;
  19753. }
  19754. /**
  19755. * Interface used to define a physics engine
  19756. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19757. */
  19758. export interface IPhysicsEngine {
  19759. /**
  19760. * Gets the gravity vector used by the simulation
  19761. */
  19762. gravity: Vector3;
  19763. /**
  19764. * Sets the gravity vector used by the simulation
  19765. * @param gravity defines the gravity vector to use
  19766. */
  19767. setGravity(gravity: Vector3): void;
  19768. /**
  19769. * Set the time step of the physics engine.
  19770. * Default is 1/60.
  19771. * To slow it down, enter 1/600 for example.
  19772. * To speed it up, 1/30
  19773. * @param newTimeStep the new timestep to apply to this world.
  19774. */
  19775. setTimeStep(newTimeStep: number): void;
  19776. /**
  19777. * Get the time step of the physics engine.
  19778. * @returns the current time step
  19779. */
  19780. getTimeStep(): number;
  19781. /**
  19782. * Release all resources
  19783. */
  19784. dispose(): void;
  19785. /**
  19786. * Gets the name of the current physics plugin
  19787. * @returns the name of the plugin
  19788. */
  19789. getPhysicsPluginName(): string;
  19790. /**
  19791. * Adding a new impostor for the impostor tracking.
  19792. * This will be done by the impostor itself.
  19793. * @param impostor the impostor to add
  19794. */
  19795. addImpostor(impostor: PhysicsImpostor): void;
  19796. /**
  19797. * Remove an impostor from the engine.
  19798. * This impostor and its mesh will not longer be updated by the physics engine.
  19799. * @param impostor the impostor to remove
  19800. */
  19801. removeImpostor(impostor: PhysicsImpostor): void;
  19802. /**
  19803. * Add a joint to the physics engine
  19804. * @param mainImpostor defines the main impostor to which the joint is added.
  19805. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19806. * @param joint defines the joint that will connect both impostors.
  19807. */
  19808. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19809. /**
  19810. * Removes a joint from the simulation
  19811. * @param mainImpostor defines the impostor used with the joint
  19812. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19813. * @param joint defines the joint to remove
  19814. */
  19815. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19816. /**
  19817. * Gets the current plugin used to run the simulation
  19818. * @returns current plugin
  19819. */
  19820. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19821. /**
  19822. * Gets the list of physic impostors
  19823. * @returns an array of PhysicsImpostor
  19824. */
  19825. getImpostors(): Array<PhysicsImpostor>;
  19826. /**
  19827. * Gets the impostor for a physics enabled object
  19828. * @param object defines the object impersonated by the impostor
  19829. * @returns the PhysicsImpostor or null if not found
  19830. */
  19831. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19832. /**
  19833. * Gets the impostor for a physics body object
  19834. * @param body defines physics body used by the impostor
  19835. * @returns the PhysicsImpostor or null if not found
  19836. */
  19837. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19838. /**
  19839. * Called by the scene. No need to call it.
  19840. * @param delta defines the timespam between frames
  19841. */
  19842. _step(delta: number): void;
  19843. }
  19844. }
  19845. declare module "babylonjs/Physics/physicsImpostor" {
  19846. import { Nullable, IndicesArray } from "babylonjs/types";
  19847. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19848. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19850. import { Scene } from "babylonjs/scene";
  19851. import { Bone } from "babylonjs/Bones/bone";
  19852. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19853. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19854. /**
  19855. * The interface for the physics imposter parameters
  19856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19857. */
  19858. export interface PhysicsImpostorParameters {
  19859. /**
  19860. * The mass of the physics imposter
  19861. */
  19862. mass: number;
  19863. /**
  19864. * The friction of the physics imposter
  19865. */
  19866. friction?: number;
  19867. /**
  19868. * The coefficient of restitution of the physics imposter
  19869. */
  19870. restitution?: number;
  19871. /**
  19872. * The native options of the physics imposter
  19873. */
  19874. nativeOptions?: any;
  19875. /**
  19876. * Specifies if the parent should be ignored
  19877. */
  19878. ignoreParent?: boolean;
  19879. /**
  19880. * Specifies if bi-directional transformations should be disabled
  19881. */
  19882. disableBidirectionalTransformation?: boolean;
  19883. }
  19884. /**
  19885. * Interface for a physics-enabled object
  19886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19887. */
  19888. export interface IPhysicsEnabledObject {
  19889. /**
  19890. * The position of the physics-enabled object
  19891. */
  19892. position: Vector3;
  19893. /**
  19894. * The rotation of the physics-enabled object
  19895. */
  19896. rotationQuaternion: Nullable<Quaternion>;
  19897. /**
  19898. * The scale of the physics-enabled object
  19899. */
  19900. scaling: Vector3;
  19901. /**
  19902. * The rotation of the physics-enabled object
  19903. */
  19904. rotation?: Vector3;
  19905. /**
  19906. * The parent of the physics-enabled object
  19907. */
  19908. parent?: any;
  19909. /**
  19910. * The bounding info of the physics-enabled object
  19911. * @returns The bounding info of the physics-enabled object
  19912. */
  19913. getBoundingInfo(): BoundingInfo;
  19914. /**
  19915. * Computes the world matrix
  19916. * @param force Specifies if the world matrix should be computed by force
  19917. * @returns A world matrix
  19918. */
  19919. computeWorldMatrix(force: boolean): Matrix;
  19920. /**
  19921. * Gets the world matrix
  19922. * @returns A world matrix
  19923. */
  19924. getWorldMatrix?(): Matrix;
  19925. /**
  19926. * Gets the child meshes
  19927. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19928. * @returns An array of abstract meshes
  19929. */
  19930. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19931. /**
  19932. * Gets the vertex data
  19933. * @param kind The type of vertex data
  19934. * @returns A nullable array of numbers, or a float32 array
  19935. */
  19936. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19937. /**
  19938. * Gets the indices from the mesh
  19939. * @returns A nullable array of index arrays
  19940. */
  19941. getIndices?(): Nullable<IndicesArray>;
  19942. /**
  19943. * Gets the scene from the mesh
  19944. * @returns the indices array or null
  19945. */
  19946. getScene?(): Scene;
  19947. /**
  19948. * Gets the absolute position from the mesh
  19949. * @returns the absolute position
  19950. */
  19951. getAbsolutePosition(): Vector3;
  19952. /**
  19953. * Gets the absolute pivot point from the mesh
  19954. * @returns the absolute pivot point
  19955. */
  19956. getAbsolutePivotPoint(): Vector3;
  19957. /**
  19958. * Rotates the mesh
  19959. * @param axis The axis of rotation
  19960. * @param amount The amount of rotation
  19961. * @param space The space of the rotation
  19962. * @returns The rotation transform node
  19963. */
  19964. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19965. /**
  19966. * Translates the mesh
  19967. * @param axis The axis of translation
  19968. * @param distance The distance of translation
  19969. * @param space The space of the translation
  19970. * @returns The transform node
  19971. */
  19972. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19973. /**
  19974. * Sets the absolute position of the mesh
  19975. * @param absolutePosition The absolute position of the mesh
  19976. * @returns The transform node
  19977. */
  19978. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19979. /**
  19980. * Gets the class name of the mesh
  19981. * @returns The class name
  19982. */
  19983. getClassName(): string;
  19984. }
  19985. /**
  19986. * Represents a physics imposter
  19987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19988. */
  19989. export class PhysicsImpostor {
  19990. /**
  19991. * The physics-enabled object used as the physics imposter
  19992. */
  19993. object: IPhysicsEnabledObject;
  19994. /**
  19995. * The type of the physics imposter
  19996. */
  19997. type: number;
  19998. private _options;
  19999. private _scene?;
  20000. /**
  20001. * The default object size of the imposter
  20002. */
  20003. static DEFAULT_OBJECT_SIZE: Vector3;
  20004. /**
  20005. * The identity quaternion of the imposter
  20006. */
  20007. static IDENTITY_QUATERNION: Quaternion;
  20008. /** @hidden */
  20009. _pluginData: any;
  20010. private _physicsEngine;
  20011. private _physicsBody;
  20012. private _bodyUpdateRequired;
  20013. private _onBeforePhysicsStepCallbacks;
  20014. private _onAfterPhysicsStepCallbacks;
  20015. /** @hidden */
  20016. _onPhysicsCollideCallbacks: Array<{
  20017. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20018. otherImpostors: Array<PhysicsImpostor>;
  20019. }>;
  20020. private _deltaPosition;
  20021. private _deltaRotation;
  20022. private _deltaRotationConjugated;
  20023. private _parent;
  20024. private _isDisposed;
  20025. private static _tmpVecs;
  20026. private static _tmpQuat;
  20027. /**
  20028. * Specifies if the physics imposter is disposed
  20029. */
  20030. readonly isDisposed: boolean;
  20031. /**
  20032. * Gets the mass of the physics imposter
  20033. */
  20034. mass: number;
  20035. /**
  20036. * Gets the coefficient of friction
  20037. */
  20038. /**
  20039. * Sets the coefficient of friction
  20040. */
  20041. friction: number;
  20042. /**
  20043. * Gets the coefficient of restitution
  20044. */
  20045. /**
  20046. * Sets the coefficient of restitution
  20047. */
  20048. restitution: number;
  20049. /**
  20050. * The unique id of the physics imposter
  20051. * set by the physics engine when adding this impostor to the array
  20052. */
  20053. uniqueId: number;
  20054. private _joints;
  20055. /**
  20056. * Initializes the physics imposter
  20057. * @param object The physics-enabled object used as the physics imposter
  20058. * @param type The type of the physics imposter
  20059. * @param _options The options for the physics imposter
  20060. * @param _scene The Babylon scene
  20061. */
  20062. constructor(
  20063. /**
  20064. * The physics-enabled object used as the physics imposter
  20065. */
  20066. object: IPhysicsEnabledObject,
  20067. /**
  20068. * The type of the physics imposter
  20069. */
  20070. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20071. /**
  20072. * This function will completly initialize this impostor.
  20073. * It will create a new body - but only if this mesh has no parent.
  20074. * If it has, this impostor will not be used other than to define the impostor
  20075. * of the child mesh.
  20076. * @hidden
  20077. */
  20078. _init(): void;
  20079. private _getPhysicsParent;
  20080. /**
  20081. * Should a new body be generated.
  20082. * @returns boolean specifying if body initialization is required
  20083. */
  20084. isBodyInitRequired(): boolean;
  20085. /**
  20086. * Sets the updated scaling
  20087. * @param updated Specifies if the scaling is updated
  20088. */
  20089. setScalingUpdated(): void;
  20090. /**
  20091. * Force a regeneration of this or the parent's impostor's body.
  20092. * Use under cautious - This will remove all joints already implemented.
  20093. */
  20094. forceUpdate(): void;
  20095. /**
  20096. * Gets the body that holds this impostor. Either its own, or its parent.
  20097. */
  20098. /**
  20099. * Set the physics body. Used mainly by the physics engine/plugin
  20100. */
  20101. physicsBody: any;
  20102. /**
  20103. * Get the parent of the physics imposter
  20104. * @returns Physics imposter or null
  20105. */
  20106. /**
  20107. * Sets the parent of the physics imposter
  20108. */
  20109. parent: Nullable<PhysicsImpostor>;
  20110. /**
  20111. * Resets the update flags
  20112. */
  20113. resetUpdateFlags(): void;
  20114. /**
  20115. * Gets the object extend size
  20116. * @returns the object extend size
  20117. */
  20118. getObjectExtendSize(): Vector3;
  20119. /**
  20120. * Gets the object center
  20121. * @returns The object center
  20122. */
  20123. getObjectCenter(): Vector3;
  20124. /**
  20125. * Get a specific parametes from the options parameter
  20126. * @param paramName The object parameter name
  20127. * @returns The object parameter
  20128. */
  20129. getParam(paramName: string): any;
  20130. /**
  20131. * Sets a specific parameter in the options given to the physics plugin
  20132. * @param paramName The parameter name
  20133. * @param value The value of the parameter
  20134. */
  20135. setParam(paramName: string, value: number): void;
  20136. /**
  20137. * Specifically change the body's mass option. Won't recreate the physics body object
  20138. * @param mass The mass of the physics imposter
  20139. */
  20140. setMass(mass: number): void;
  20141. /**
  20142. * Gets the linear velocity
  20143. * @returns linear velocity or null
  20144. */
  20145. getLinearVelocity(): Nullable<Vector3>;
  20146. /**
  20147. * Sets the linear velocity
  20148. * @param velocity linear velocity or null
  20149. */
  20150. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20151. /**
  20152. * Gets the angular velocity
  20153. * @returns angular velocity or null
  20154. */
  20155. getAngularVelocity(): Nullable<Vector3>;
  20156. /**
  20157. * Sets the angular velocity
  20158. * @param velocity The velocity or null
  20159. */
  20160. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20161. /**
  20162. * Execute a function with the physics plugin native code
  20163. * Provide a function the will have two variables - the world object and the physics body object
  20164. * @param func The function to execute with the physics plugin native code
  20165. */
  20166. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20167. /**
  20168. * Register a function that will be executed before the physics world is stepping forward
  20169. * @param func The function to execute before the physics world is stepped forward
  20170. */
  20171. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20172. /**
  20173. * Unregister a function that will be executed before the physics world is stepping forward
  20174. * @param func The function to execute before the physics world is stepped forward
  20175. */
  20176. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20177. /**
  20178. * Register a function that will be executed after the physics step
  20179. * @param func The function to execute after physics step
  20180. */
  20181. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20182. /**
  20183. * Unregisters a function that will be executed after the physics step
  20184. * @param func The function to execute after physics step
  20185. */
  20186. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20187. /**
  20188. * register a function that will be executed when this impostor collides against a different body
  20189. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20190. * @param func Callback that is executed on collision
  20191. */
  20192. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20193. /**
  20194. * Unregisters the physics imposter on contact
  20195. * @param collideAgainst The physics object to collide against
  20196. * @param func Callback to execute on collision
  20197. */
  20198. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20199. private _tmpQuat;
  20200. private _tmpQuat2;
  20201. /**
  20202. * Get the parent rotation
  20203. * @returns The parent rotation
  20204. */
  20205. getParentsRotation(): Quaternion;
  20206. /**
  20207. * this function is executed by the physics engine.
  20208. */
  20209. beforeStep: () => void;
  20210. /**
  20211. * this function is executed by the physics engine
  20212. */
  20213. afterStep: () => void;
  20214. /**
  20215. * Legacy collision detection event support
  20216. */
  20217. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20218. /**
  20219. * event and body object due to cannon's event-based architecture.
  20220. */
  20221. onCollide: (e: {
  20222. body: any;
  20223. }) => void;
  20224. /**
  20225. * Apply a force
  20226. * @param force The force to apply
  20227. * @param contactPoint The contact point for the force
  20228. * @returns The physics imposter
  20229. */
  20230. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20231. /**
  20232. * Apply an impulse
  20233. * @param force The impulse force
  20234. * @param contactPoint The contact point for the impulse force
  20235. * @returns The physics imposter
  20236. */
  20237. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20238. /**
  20239. * A help function to create a joint
  20240. * @param otherImpostor A physics imposter used to create a joint
  20241. * @param jointType The type of joint
  20242. * @param jointData The data for the joint
  20243. * @returns The physics imposter
  20244. */
  20245. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20246. /**
  20247. * Add a joint to this impostor with a different impostor
  20248. * @param otherImpostor A physics imposter used to add a joint
  20249. * @param joint The joint to add
  20250. * @returns The physics imposter
  20251. */
  20252. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20253. /**
  20254. * Will keep this body still, in a sleep mode.
  20255. * @returns the physics imposter
  20256. */
  20257. sleep(): PhysicsImpostor;
  20258. /**
  20259. * Wake the body up.
  20260. * @returns The physics imposter
  20261. */
  20262. wakeUp(): PhysicsImpostor;
  20263. /**
  20264. * Clones the physics imposter
  20265. * @param newObject The physics imposter clones to this physics-enabled object
  20266. * @returns A nullable physics imposter
  20267. */
  20268. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20269. /**
  20270. * Disposes the physics imposter
  20271. */
  20272. dispose(): void;
  20273. /**
  20274. * Sets the delta position
  20275. * @param position The delta position amount
  20276. */
  20277. setDeltaPosition(position: Vector3): void;
  20278. /**
  20279. * Sets the delta rotation
  20280. * @param rotation The delta rotation amount
  20281. */
  20282. setDeltaRotation(rotation: Quaternion): void;
  20283. /**
  20284. * Gets the box size of the physics imposter and stores the result in the input parameter
  20285. * @param result Stores the box size
  20286. * @returns The physics imposter
  20287. */
  20288. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20289. /**
  20290. * Gets the radius of the physics imposter
  20291. * @returns Radius of the physics imposter
  20292. */
  20293. getRadius(): number;
  20294. /**
  20295. * Sync a bone with this impostor
  20296. * @param bone The bone to sync to the impostor.
  20297. * @param boneMesh The mesh that the bone is influencing.
  20298. * @param jointPivot The pivot of the joint / bone in local space.
  20299. * @param distToJoint Optional distance from the impostor to the joint.
  20300. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20301. */
  20302. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20303. /**
  20304. * Sync impostor to a bone
  20305. * @param bone The bone that the impostor will be synced to.
  20306. * @param boneMesh The mesh that the bone is influencing.
  20307. * @param jointPivot The pivot of the joint / bone in local space.
  20308. * @param distToJoint Optional distance from the impostor to the joint.
  20309. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20310. * @param boneAxis Optional vector3 axis the bone is aligned with
  20311. */
  20312. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20313. /**
  20314. * No-Imposter type
  20315. */
  20316. static NoImpostor: number;
  20317. /**
  20318. * Sphere-Imposter type
  20319. */
  20320. static SphereImpostor: number;
  20321. /**
  20322. * Box-Imposter type
  20323. */
  20324. static BoxImpostor: number;
  20325. /**
  20326. * Plane-Imposter type
  20327. */
  20328. static PlaneImpostor: number;
  20329. /**
  20330. * Mesh-imposter type
  20331. */
  20332. static MeshImpostor: number;
  20333. /**
  20334. * Cylinder-Imposter type
  20335. */
  20336. static CylinderImpostor: number;
  20337. /**
  20338. * Particle-Imposter type
  20339. */
  20340. static ParticleImpostor: number;
  20341. /**
  20342. * Heightmap-Imposter type
  20343. */
  20344. static HeightmapImpostor: number;
  20345. }
  20346. }
  20347. declare module "babylonjs/Meshes/mesh" {
  20348. import { Observable } from "babylonjs/Misc/observable";
  20349. import { IAnimatable } from "babylonjs/Misc/tools";
  20350. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20351. import { Camera } from "babylonjs/Cameras/camera";
  20352. import { Scene } from "babylonjs/scene";
  20353. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20354. import { Engine } from "babylonjs/Engines/engine";
  20355. import { Node } from "babylonjs/node";
  20356. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20357. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20358. import { Buffer } from "babylonjs/Meshes/buffer";
  20359. import { Geometry } from "babylonjs/Meshes/geometry";
  20360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20361. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20362. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20363. import { Effect } from "babylonjs/Materials/effect";
  20364. import { Material } from "babylonjs/Materials/material";
  20365. import { Skeleton } from "babylonjs/Bones/skeleton";
  20366. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20367. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20368. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20369. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20370. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20371. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20372. /**
  20373. * Class used to represent a specific level of detail of a mesh
  20374. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20375. */
  20376. export class MeshLODLevel {
  20377. /** Defines the distance where this level should star being displayed */
  20378. distance: number;
  20379. /** Defines the mesh to use to render this level */
  20380. mesh: Nullable<Mesh>;
  20381. /**
  20382. * Creates a new LOD level
  20383. * @param distance defines the distance where this level should star being displayed
  20384. * @param mesh defines the mesh to use to render this level
  20385. */
  20386. constructor(
  20387. /** Defines the distance where this level should star being displayed */
  20388. distance: number,
  20389. /** Defines the mesh to use to render this level */
  20390. mesh: Nullable<Mesh>);
  20391. }
  20392. /**
  20393. * @hidden
  20394. **/
  20395. export class _CreationDataStorage {
  20396. closePath?: boolean;
  20397. closeArray?: boolean;
  20398. idx: number[];
  20399. dashSize: number;
  20400. gapSize: number;
  20401. path3D: Path3D;
  20402. pathArray: Vector3[][];
  20403. arc: number;
  20404. radius: number;
  20405. cap: number;
  20406. tessellation: number;
  20407. }
  20408. /**
  20409. * @hidden
  20410. **/
  20411. class _InstanceDataStorage {
  20412. visibleInstances: any;
  20413. renderIdForInstances: number[];
  20414. batchCache: _InstancesBatch;
  20415. instancesBufferSize: number;
  20416. instancesBuffer: Nullable<Buffer>;
  20417. instancesData: Float32Array;
  20418. overridenInstanceCount: number;
  20419. }
  20420. /**
  20421. * @hidden
  20422. **/
  20423. export class _InstancesBatch {
  20424. mustReturn: boolean;
  20425. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20426. renderSelf: boolean[];
  20427. }
  20428. /**
  20429. * Class used to represent renderable models
  20430. */
  20431. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20432. /**
  20433. * Mesh side orientation : usually the external or front surface
  20434. */
  20435. static readonly FRONTSIDE: number;
  20436. /**
  20437. * Mesh side orientation : usually the internal or back surface
  20438. */
  20439. static readonly BACKSIDE: number;
  20440. /**
  20441. * Mesh side orientation : both internal and external or front and back surfaces
  20442. */
  20443. static readonly DOUBLESIDE: number;
  20444. /**
  20445. * Mesh side orientation : by default, `FRONTSIDE`
  20446. */
  20447. static readonly DEFAULTSIDE: number;
  20448. /**
  20449. * Mesh cap setting : no cap
  20450. */
  20451. static readonly NO_CAP: number;
  20452. /**
  20453. * Mesh cap setting : one cap at the beginning of the mesh
  20454. */
  20455. static readonly CAP_START: number;
  20456. /**
  20457. * Mesh cap setting : one cap at the end of the mesh
  20458. */
  20459. static readonly CAP_END: number;
  20460. /**
  20461. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20462. */
  20463. static readonly CAP_ALL: number;
  20464. /**
  20465. * Gets the default side orientation.
  20466. * @param orientation the orientation to value to attempt to get
  20467. * @returns the default orientation
  20468. * @hidden
  20469. */
  20470. static _GetDefaultSideOrientation(orientation?: number): number;
  20471. private _onBeforeRenderObservable;
  20472. private _onBeforeBindObservable;
  20473. private _onAfterRenderObservable;
  20474. private _onBeforeDrawObservable;
  20475. /**
  20476. * An event triggered before rendering the mesh
  20477. */
  20478. readonly onBeforeRenderObservable: Observable<Mesh>;
  20479. /**
  20480. * An event triggered before binding the mesh
  20481. */
  20482. readonly onBeforeBindObservable: Observable<Mesh>;
  20483. /**
  20484. * An event triggered after rendering the mesh
  20485. */
  20486. readonly onAfterRenderObservable: Observable<Mesh>;
  20487. /**
  20488. * An event triggered before drawing the mesh
  20489. */
  20490. readonly onBeforeDrawObservable: Observable<Mesh>;
  20491. private _onBeforeDrawObserver;
  20492. /**
  20493. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20494. */
  20495. onBeforeDraw: () => void;
  20496. /**
  20497. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20498. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20499. */
  20500. delayLoadState: number;
  20501. /**
  20502. * Gets the list of instances created from this mesh
  20503. * it is not supposed to be modified manually.
  20504. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20505. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20506. */
  20507. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20508. /**
  20509. * Gets the file containing delay loading data for this mesh
  20510. */
  20511. delayLoadingFile: string;
  20512. /** @hidden */
  20513. _binaryInfo: any;
  20514. private _LODLevels;
  20515. /**
  20516. * User defined function used to change how LOD level selection is done
  20517. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20518. */
  20519. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20520. private _morphTargetManager;
  20521. /**
  20522. * Gets or sets the morph target manager
  20523. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20524. */
  20525. morphTargetManager: Nullable<MorphTargetManager>;
  20526. /** @hidden */
  20527. _creationDataStorage: Nullable<_CreationDataStorage>;
  20528. /** @hidden */
  20529. _geometry: Nullable<Geometry>;
  20530. /** @hidden */
  20531. _delayInfo: Array<string>;
  20532. /** @hidden */
  20533. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20534. /** @hidden */
  20535. _instanceDataStorage: _InstanceDataStorage;
  20536. private _effectiveMaterial;
  20537. /** @hidden */
  20538. _shouldGenerateFlatShading: boolean;
  20539. private _preActivateId;
  20540. /** @hidden */
  20541. _originalBuilderSideOrientation: number;
  20542. /**
  20543. * Use this property to change the original side orientation defined at construction time
  20544. */
  20545. overrideMaterialSideOrientation: Nullable<number>;
  20546. private _areNormalsFrozen;
  20547. private _sourcePositions;
  20548. private _sourceNormals;
  20549. private _source;
  20550. private meshMap;
  20551. /**
  20552. * Gets the source mesh (the one used to clone this one from)
  20553. */
  20554. readonly source: Nullable<Mesh>;
  20555. /**
  20556. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20557. */
  20558. isUnIndexed: boolean;
  20559. /**
  20560. * @constructor
  20561. * @param name The value used by scene.getMeshByName() to do a lookup.
  20562. * @param scene The scene to add this mesh to.
  20563. * @param parent The parent of this mesh, if it has one
  20564. * @param source An optional Mesh from which geometry is shared, cloned.
  20565. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20566. * When false, achieved by calling a clone(), also passing False.
  20567. * This will make creation of children, recursive.
  20568. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20569. */
  20570. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20571. /**
  20572. * Gets the class name
  20573. * @returns the string "Mesh".
  20574. */
  20575. getClassName(): string;
  20576. /** @hidden */
  20577. readonly _isMesh: boolean;
  20578. /**
  20579. * Returns a description of this mesh
  20580. * @param fullDetails define if full details about this mesh must be used
  20581. * @returns a descriptive string representing this mesh
  20582. */
  20583. toString(fullDetails?: boolean): string;
  20584. /** @hidden */
  20585. _unBindEffect(): void;
  20586. /**
  20587. * Gets a boolean indicating if this mesh has LOD
  20588. */
  20589. readonly hasLODLevels: boolean;
  20590. /**
  20591. * Gets the list of MeshLODLevel associated with the current mesh
  20592. * @returns an array of MeshLODLevel
  20593. */
  20594. getLODLevels(): MeshLODLevel[];
  20595. private _sortLODLevels;
  20596. /**
  20597. * Add a mesh as LOD level triggered at the given distance.
  20598. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20599. * @param distance The distance from the center of the object to show this level
  20600. * @param mesh The mesh to be added as LOD level (can be null)
  20601. * @return This mesh (for chaining)
  20602. */
  20603. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20604. /**
  20605. * Returns the LOD level mesh at the passed distance or null if not found.
  20606. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20607. * @param distance The distance from the center of the object to show this level
  20608. * @returns a Mesh or `null`
  20609. */
  20610. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20611. /**
  20612. * Remove a mesh from the LOD array
  20613. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20614. * @param mesh defines the mesh to be removed
  20615. * @return This mesh (for chaining)
  20616. */
  20617. removeLODLevel(mesh: Mesh): Mesh;
  20618. /**
  20619. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20620. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20621. * @param camera defines the camera to use to compute distance
  20622. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20623. * @return This mesh (for chaining)
  20624. */
  20625. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20626. /**
  20627. * Gets the mesh internal Geometry object
  20628. */
  20629. readonly geometry: Nullable<Geometry>;
  20630. /**
  20631. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20632. * @returns the total number of vertices
  20633. */
  20634. getTotalVertices(): number;
  20635. /**
  20636. * Returns the content of an associated vertex buffer
  20637. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20638. * - VertexBuffer.PositionKind
  20639. * - VertexBuffer.UVKind
  20640. * - VertexBuffer.UV2Kind
  20641. * - VertexBuffer.UV3Kind
  20642. * - VertexBuffer.UV4Kind
  20643. * - VertexBuffer.UV5Kind
  20644. * - VertexBuffer.UV6Kind
  20645. * - VertexBuffer.ColorKind
  20646. * - VertexBuffer.MatricesIndicesKind
  20647. * - VertexBuffer.MatricesIndicesExtraKind
  20648. * - VertexBuffer.MatricesWeightsKind
  20649. * - VertexBuffer.MatricesWeightsExtraKind
  20650. * @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
  20651. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20652. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20653. */
  20654. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20655. /**
  20656. * Returns the mesh VertexBuffer object from the requested `kind`
  20657. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20658. * - VertexBuffer.PositionKind
  20659. * - VertexBuffer.UVKind
  20660. * - VertexBuffer.UV2Kind
  20661. * - VertexBuffer.UV3Kind
  20662. * - VertexBuffer.UV4Kind
  20663. * - VertexBuffer.UV5Kind
  20664. * - VertexBuffer.UV6Kind
  20665. * - VertexBuffer.ColorKind
  20666. * - VertexBuffer.MatricesIndicesKind
  20667. * - VertexBuffer.MatricesIndicesExtraKind
  20668. * - VertexBuffer.MatricesWeightsKind
  20669. * - VertexBuffer.MatricesWeightsExtraKind
  20670. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20671. */
  20672. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20673. /**
  20674. * Tests if a specific vertex buffer is associated with this mesh
  20675. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20676. * - VertexBuffer.PositionKind
  20677. * - VertexBuffer.UVKind
  20678. * - VertexBuffer.UV2Kind
  20679. * - VertexBuffer.UV3Kind
  20680. * - VertexBuffer.UV4Kind
  20681. * - VertexBuffer.UV5Kind
  20682. * - VertexBuffer.UV6Kind
  20683. * - VertexBuffer.ColorKind
  20684. * - VertexBuffer.MatricesIndicesKind
  20685. * - VertexBuffer.MatricesIndicesExtraKind
  20686. * - VertexBuffer.MatricesWeightsKind
  20687. * - VertexBuffer.MatricesWeightsExtraKind
  20688. * @returns a boolean
  20689. */
  20690. isVerticesDataPresent(kind: string): boolean;
  20691. /**
  20692. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20693. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20694. * - VertexBuffer.PositionKind
  20695. * - VertexBuffer.UVKind
  20696. * - VertexBuffer.UV2Kind
  20697. * - VertexBuffer.UV3Kind
  20698. * - VertexBuffer.UV4Kind
  20699. * - VertexBuffer.UV5Kind
  20700. * - VertexBuffer.UV6Kind
  20701. * - VertexBuffer.ColorKind
  20702. * - VertexBuffer.MatricesIndicesKind
  20703. * - VertexBuffer.MatricesIndicesExtraKind
  20704. * - VertexBuffer.MatricesWeightsKind
  20705. * - VertexBuffer.MatricesWeightsExtraKind
  20706. * @returns a boolean
  20707. */
  20708. isVertexBufferUpdatable(kind: string): boolean;
  20709. /**
  20710. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20711. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20712. * - VertexBuffer.PositionKind
  20713. * - VertexBuffer.UVKind
  20714. * - VertexBuffer.UV2Kind
  20715. * - VertexBuffer.UV3Kind
  20716. * - VertexBuffer.UV4Kind
  20717. * - VertexBuffer.UV5Kind
  20718. * - VertexBuffer.UV6Kind
  20719. * - VertexBuffer.ColorKind
  20720. * - VertexBuffer.MatricesIndicesKind
  20721. * - VertexBuffer.MatricesIndicesExtraKind
  20722. * - VertexBuffer.MatricesWeightsKind
  20723. * - VertexBuffer.MatricesWeightsExtraKind
  20724. * @returns an array of strings
  20725. */
  20726. getVerticesDataKinds(): string[];
  20727. /**
  20728. * Returns a positive integer : the total number of indices in this mesh geometry.
  20729. * @returns the numner of indices or zero if the mesh has no geometry.
  20730. */
  20731. getTotalIndices(): number;
  20732. /**
  20733. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20734. * @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.
  20735. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20736. * @returns the indices array or an empty array if the mesh has no geometry
  20737. */
  20738. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20739. readonly isBlocked: boolean;
  20740. /**
  20741. * Determine if the current mesh is ready to be rendered
  20742. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20743. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20744. * @returns true if all associated assets are ready (material, textures, shaders)
  20745. */
  20746. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20747. /**
  20748. * 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.
  20749. */
  20750. readonly areNormalsFrozen: boolean;
  20751. /**
  20752. * 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.
  20753. * @returns the current mesh
  20754. */
  20755. freezeNormals(): Mesh;
  20756. /**
  20757. * 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
  20758. * @returns the current mesh
  20759. */
  20760. unfreezeNormals(): Mesh;
  20761. /**
  20762. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20763. */
  20764. overridenInstanceCount: number;
  20765. /** @hidden */
  20766. _preActivate(): Mesh;
  20767. /** @hidden */
  20768. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20769. /** @hidden */
  20770. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20771. /**
  20772. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20773. * This means the mesh underlying bounding box and sphere are recomputed.
  20774. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20775. * @returns the current mesh
  20776. */
  20777. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20778. /** @hidden */
  20779. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20780. /**
  20781. * This function will subdivide the mesh into multiple submeshes
  20782. * @param count defines the expected number of submeshes
  20783. */
  20784. subdivide(count: number): void;
  20785. /**
  20786. * Copy a FloatArray into a specific associated vertex buffer
  20787. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20788. * - VertexBuffer.PositionKind
  20789. * - VertexBuffer.UVKind
  20790. * - VertexBuffer.UV2Kind
  20791. * - VertexBuffer.UV3Kind
  20792. * - VertexBuffer.UV4Kind
  20793. * - VertexBuffer.UV5Kind
  20794. * - VertexBuffer.UV6Kind
  20795. * - VertexBuffer.ColorKind
  20796. * - VertexBuffer.MatricesIndicesKind
  20797. * - VertexBuffer.MatricesIndicesExtraKind
  20798. * - VertexBuffer.MatricesWeightsKind
  20799. * - VertexBuffer.MatricesWeightsExtraKind
  20800. * @param data defines the data source
  20801. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20802. * @param stride defines the data stride size (can be null)
  20803. * @returns the current mesh
  20804. */
  20805. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20806. /**
  20807. * Flags an associated vertex buffer as updatable
  20808. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20809. * - VertexBuffer.PositionKind
  20810. * - VertexBuffer.UVKind
  20811. * - VertexBuffer.UV2Kind
  20812. * - VertexBuffer.UV3Kind
  20813. * - VertexBuffer.UV4Kind
  20814. * - VertexBuffer.UV5Kind
  20815. * - VertexBuffer.UV6Kind
  20816. * - VertexBuffer.ColorKind
  20817. * - VertexBuffer.MatricesIndicesKind
  20818. * - VertexBuffer.MatricesIndicesExtraKind
  20819. * - VertexBuffer.MatricesWeightsKind
  20820. * - VertexBuffer.MatricesWeightsExtraKind
  20821. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20822. */
  20823. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20824. /**
  20825. * Sets the mesh global Vertex Buffer
  20826. * @param buffer defines the buffer to use
  20827. * @returns the current mesh
  20828. */
  20829. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20830. /**
  20831. * Update a specific associated vertex buffer
  20832. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20833. * - VertexBuffer.PositionKind
  20834. * - VertexBuffer.UVKind
  20835. * - VertexBuffer.UV2Kind
  20836. * - VertexBuffer.UV3Kind
  20837. * - VertexBuffer.UV4Kind
  20838. * - VertexBuffer.UV5Kind
  20839. * - VertexBuffer.UV6Kind
  20840. * - VertexBuffer.ColorKind
  20841. * - VertexBuffer.MatricesIndicesKind
  20842. * - VertexBuffer.MatricesIndicesExtraKind
  20843. * - VertexBuffer.MatricesWeightsKind
  20844. * - VertexBuffer.MatricesWeightsExtraKind
  20845. * @param data defines the data source
  20846. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20847. * @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)
  20848. * @returns the current mesh
  20849. */
  20850. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20851. /**
  20852. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20853. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20854. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20855. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20856. * @returns the current mesh
  20857. */
  20858. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20859. /**
  20860. * Creates a un-shared specific occurence of the geometry for the mesh.
  20861. * @returns the current mesh
  20862. */
  20863. makeGeometryUnique(): Mesh;
  20864. /**
  20865. * Set the index buffer of this mesh
  20866. * @param indices defines the source data
  20867. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20868. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20869. * @returns the current mesh
  20870. */
  20871. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20872. /**
  20873. * Update the current index buffer
  20874. * @param indices defines the source data
  20875. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20876. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20877. * @returns the current mesh
  20878. */
  20879. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20880. /**
  20881. * Invert the geometry to move from a right handed system to a left handed one.
  20882. * @returns the current mesh
  20883. */
  20884. toLeftHanded(): Mesh;
  20885. /** @hidden */
  20886. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20887. /** @hidden */
  20888. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20889. /**
  20890. * Registers for this mesh a javascript function called just before the rendering process
  20891. * @param func defines the function to call before rendering this mesh
  20892. * @returns the current mesh
  20893. */
  20894. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20895. /**
  20896. * Disposes a previously registered javascript function called before the rendering
  20897. * @param func defines the function to remove
  20898. * @returns the current mesh
  20899. */
  20900. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20901. /**
  20902. * Registers for this mesh a javascript function called just after the rendering is complete
  20903. * @param func defines the function to call after rendering this mesh
  20904. * @returns the current mesh
  20905. */
  20906. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20907. /**
  20908. * Disposes a previously registered javascript function called after the rendering.
  20909. * @param func defines the function to remove
  20910. * @returns the current mesh
  20911. */
  20912. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20913. /** @hidden */
  20914. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20915. /** @hidden */
  20916. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20917. /** @hidden */
  20918. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20919. /**
  20920. * 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
  20921. * @param subMesh defines the subMesh to render
  20922. * @param enableAlphaMode defines if alpha mode can be changed
  20923. * @returns the current mesh
  20924. */
  20925. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20926. private _onBeforeDraw;
  20927. /**
  20928. * Renormalize the mesh and patch it up if there are no weights
  20929. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20930. * However in the case of zero weights then we set just a single influence to 1.
  20931. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20932. */
  20933. cleanMatrixWeights(): void;
  20934. private normalizeSkinFourWeights;
  20935. private normalizeSkinWeightsAndExtra;
  20936. /**
  20937. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20938. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20939. * the user know there was an issue with importing the mesh
  20940. * @returns a validation object with skinned, valid and report string
  20941. */
  20942. validateSkinning(): {
  20943. skinned: boolean;
  20944. valid: boolean;
  20945. report: string;
  20946. };
  20947. /** @hidden */
  20948. _checkDelayState(): Mesh;
  20949. private _queueLoad;
  20950. /**
  20951. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20952. * A mesh is in the frustum if its bounding box intersects the frustum
  20953. * @param frustumPlanes defines the frustum to test
  20954. * @returns true if the mesh is in the frustum planes
  20955. */
  20956. isInFrustum(frustumPlanes: Plane[]): boolean;
  20957. /**
  20958. * Sets the mesh material by the material or multiMaterial `id` property
  20959. * @param id is a string identifying the material or the multiMaterial
  20960. * @returns the current mesh
  20961. */
  20962. setMaterialByID(id: string): Mesh;
  20963. /**
  20964. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20965. * @returns an array of IAnimatable
  20966. */
  20967. getAnimatables(): IAnimatable[];
  20968. /**
  20969. * Modifies the mesh geometry according to the passed transformation matrix.
  20970. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20971. * The mesh normals are modified using the same transformation.
  20972. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20973. * @param transform defines the transform matrix to use
  20974. * @see http://doc.babylonjs.com/resources/baking_transformations
  20975. * @returns the current mesh
  20976. */
  20977. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20978. /**
  20979. * Modifies the mesh geometry according to its own current World Matrix.
  20980. * The mesh World Matrix is then reset.
  20981. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20982. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20983. * @see http://doc.babylonjs.com/resources/baking_transformations
  20984. * @returns the current mesh
  20985. */
  20986. bakeCurrentTransformIntoVertices(): Mesh;
  20987. /** @hidden */
  20988. readonly _positions: Nullable<Vector3[]>;
  20989. /** @hidden */
  20990. _resetPointsArrayCache(): Mesh;
  20991. /** @hidden */
  20992. _generatePointsArray(): boolean;
  20993. /**
  20994. * Returns a new Mesh object generated from the current mesh properties.
  20995. * This method must not get confused with createInstance()
  20996. * @param name is a string, the name given to the new mesh
  20997. * @param newParent can be any Node object (default `null`)
  20998. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20999. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21000. * @returns a new mesh
  21001. */
  21002. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21003. /**
  21004. * Releases resources associated with this mesh.
  21005. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21006. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21007. */
  21008. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21009. /**
  21010. * Modifies the mesh geometry according to a displacement map.
  21011. * 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.
  21012. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21013. * @param url is a string, the URL from the image file is to be downloaded.
  21014. * @param minHeight is the lower limit of the displacement.
  21015. * @param maxHeight is the upper limit of the displacement.
  21016. * @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.
  21017. * @param uvOffset is an optional vector2 used to offset UV.
  21018. * @param uvScale is an optional vector2 used to scale UV.
  21019. * @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.
  21020. * @returns the Mesh.
  21021. */
  21022. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21023. /**
  21024. * Modifies the mesh geometry according to a displacementMap buffer.
  21025. * 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.
  21026. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21027. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21028. * @param heightMapWidth is the width of the buffer image.
  21029. * @param heightMapHeight is the height of the buffer image.
  21030. * @param minHeight is the lower limit of the displacement.
  21031. * @param maxHeight is the upper limit of the displacement.
  21032. * @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.
  21033. * @param uvOffset is an optional vector2 used to offset UV.
  21034. * @param uvScale is an optional vector2 used to scale UV.
  21035. * @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.
  21036. * @returns the Mesh.
  21037. */
  21038. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21039. /**
  21040. * Modify the mesh to get a flat shading rendering.
  21041. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21042. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21043. * @returns current mesh
  21044. */
  21045. convertToFlatShadedMesh(): Mesh;
  21046. /**
  21047. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21048. * In other words, more vertices, no more indices and a single bigger VBO.
  21049. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21050. * @returns current mesh
  21051. */
  21052. convertToUnIndexedMesh(): Mesh;
  21053. /**
  21054. * Inverses facet orientations.
  21055. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21056. * @param flipNormals will also inverts the normals
  21057. * @returns current mesh
  21058. */
  21059. flipFaces(flipNormals?: boolean): Mesh;
  21060. /** @hidden */
  21061. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21062. /** @hidden */
  21063. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21064. /**
  21065. * Creates a new InstancedMesh object from the mesh model.
  21066. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21067. * @param name defines the name of the new instance
  21068. * @returns a new InstancedMesh
  21069. */
  21070. createInstance(name: string): InstancedMesh;
  21071. /**
  21072. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21073. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21074. * @returns the current mesh
  21075. */
  21076. synchronizeInstances(): Mesh;
  21077. /**
  21078. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21079. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21080. * This should be used together with the simplification to avoid disappearing triangles.
  21081. * @param successCallback an optional success callback to be called after the optimization finished.
  21082. * @returns the current mesh
  21083. */
  21084. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21085. /**
  21086. * Serialize current mesh
  21087. * @param serializationObject defines the object which will receive the serialization data
  21088. */
  21089. serialize(serializationObject: any): void;
  21090. /** @hidden */
  21091. _syncGeometryWithMorphTargetManager(): void;
  21092. /** @hidden */
  21093. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21094. /**
  21095. * Returns a new Mesh object parsed from the source provided.
  21096. * @param parsedMesh is the source
  21097. * @param scene defines the hosting scene
  21098. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21099. * @returns a new Mesh
  21100. */
  21101. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21102. /**
  21103. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21104. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21105. * @param name defines the name of the mesh to create
  21106. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21107. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21108. * @param closePath creates a seam between the first and the last points of each path of the path array
  21109. * @param offset is taken in account only if the `pathArray` is containing a single path
  21110. * @param scene defines the hosting scene
  21111. * @param updatable defines if the mesh must be flagged as updatable
  21112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21113. * @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)
  21114. * @returns a new Mesh
  21115. */
  21116. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21117. /**
  21118. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21119. * @param name defines the name of the mesh to create
  21120. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21121. * @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
  21122. * @param scene defines the hosting scene
  21123. * @param updatable defines if the mesh must be flagged as updatable
  21124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21125. * @returns a new Mesh
  21126. */
  21127. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21128. /**
  21129. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21130. * @param name defines the name of the mesh to create
  21131. * @param size sets the size (float) of each box side (default 1)
  21132. * @param scene defines the hosting scene
  21133. * @param updatable defines if the mesh must be flagged as updatable
  21134. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21135. * @returns a new Mesh
  21136. */
  21137. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21138. /**
  21139. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21140. * @param name defines the name of the mesh to create
  21141. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21142. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21143. * @param scene defines the hosting scene
  21144. * @param updatable defines if the mesh must be flagged as updatable
  21145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21146. * @returns a new Mesh
  21147. */
  21148. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21149. /**
  21150. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21151. * @param name defines the name of the mesh to create
  21152. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21153. * @param diameterTop set the top cap diameter (floats, default 1)
  21154. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21155. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21156. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21157. * @param scene defines the hosting scene
  21158. * @param updatable defines if the mesh must be flagged as updatable
  21159. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21160. * @returns a new Mesh
  21161. */
  21162. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21163. /**
  21164. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21165. * @param name defines the name of the mesh to create
  21166. * @param diameter sets the diameter size (float) of the torus (default 1)
  21167. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21168. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21169. * @param scene defines the hosting scene
  21170. * @param updatable defines if the mesh must be flagged as updatable
  21171. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21172. * @returns a new Mesh
  21173. */
  21174. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21175. /**
  21176. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21177. * @param name defines the name of the mesh to create
  21178. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21179. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21180. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21181. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21182. * @param p the number of windings on X axis (positive integers, default 2)
  21183. * @param q the number of windings on Y axis (positive integers, default 3)
  21184. * @param scene defines the hosting scene
  21185. * @param updatable defines if the mesh must be flagged as updatable
  21186. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21187. * @returns a new Mesh
  21188. */
  21189. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21190. /**
  21191. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21192. * @param name defines the name of the mesh to create
  21193. * @param points is an array successive Vector3
  21194. * @param scene defines the hosting scene
  21195. * @param updatable defines if the mesh must be flagged as updatable
  21196. * @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).
  21197. * @returns a new Mesh
  21198. */
  21199. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21200. /**
  21201. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21202. * @param name defines the name of the mesh to create
  21203. * @param points is an array successive Vector3
  21204. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21205. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21206. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21207. * @param scene defines the hosting scene
  21208. * @param updatable defines if the mesh must be flagged as updatable
  21209. * @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)
  21210. * @returns a new Mesh
  21211. */
  21212. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21213. /**
  21214. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21215. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21216. * 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.
  21217. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21218. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21219. * Remember you can only change the shape positions, not their number when updating a polygon.
  21220. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21221. * @param name defines the name of the mesh to create
  21222. * @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
  21223. * @param scene defines the hosting scene
  21224. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21225. * @param updatable defines if the mesh must be flagged as updatable
  21226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21227. * @param earcutInjection can be used to inject your own earcut reference
  21228. * @returns a new Mesh
  21229. */
  21230. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21231. /**
  21232. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21233. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21234. * @param name defines the name of the mesh to create
  21235. * @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
  21236. * @param depth defines the height of extrusion
  21237. * @param scene defines the hosting scene
  21238. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21239. * @param updatable defines if the mesh must be flagged as updatable
  21240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21241. * @param earcutInjection can be used to inject your own earcut reference
  21242. * @returns a new Mesh
  21243. */
  21244. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21245. /**
  21246. * Creates an extruded shape mesh.
  21247. * 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
  21248. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21249. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21250. * @param name defines the name of the mesh to create
  21251. * @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
  21252. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21253. * @param scale is the value to scale the shape
  21254. * @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
  21255. * @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
  21256. * @param scene defines the hosting scene
  21257. * @param updatable defines if the mesh must be flagged as updatable
  21258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21259. * @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)
  21260. * @returns a new Mesh
  21261. */
  21262. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21263. /**
  21264. * Creates an custom extruded shape mesh.
  21265. * The custom extrusion is a parametric shape.
  21266. * It has no predefined shape. Its final shape will depend on the input parameters.
  21267. * Please consider using the same method from the MeshBuilder class instead
  21268. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21269. * @param name defines the name of the mesh to create
  21270. * @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
  21271. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21272. * @param scaleFunction is a custom Javascript function called on each path point
  21273. * @param rotationFunction is a custom Javascript function called on each path point
  21274. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21275. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21276. * @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
  21277. * @param scene defines the hosting scene
  21278. * @param updatable defines if the mesh must be flagged as updatable
  21279. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21280. * @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)
  21281. * @returns a new Mesh
  21282. */
  21283. 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;
  21284. /**
  21285. * Creates lathe mesh.
  21286. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21287. * Please consider using the same method from the MeshBuilder class instead
  21288. * @param name defines the name of the mesh to create
  21289. * @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
  21290. * @param radius is the radius value of the lathe
  21291. * @param tessellation is the side number of the lathe.
  21292. * @param scene defines the hosting scene
  21293. * @param updatable defines if the mesh must be flagged as updatable
  21294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21295. * @returns a new Mesh
  21296. */
  21297. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21298. /**
  21299. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21300. * @param name defines the name of the mesh to create
  21301. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21302. * @param scene defines the hosting scene
  21303. * @param updatable defines if the mesh must be flagged as updatable
  21304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21305. * @returns a new Mesh
  21306. */
  21307. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21308. /**
  21309. * Creates a ground mesh.
  21310. * Please consider using the same method from the MeshBuilder class instead
  21311. * @param name defines the name of the mesh to create
  21312. * @param width set the width of the ground
  21313. * @param height set the height of the ground
  21314. * @param subdivisions sets the number of subdivisions per side
  21315. * @param scene defines the hosting scene
  21316. * @param updatable defines if the mesh must be flagged as updatable
  21317. * @returns a new Mesh
  21318. */
  21319. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21320. /**
  21321. * Creates a tiled ground mesh.
  21322. * Please consider using the same method from the MeshBuilder class instead
  21323. * @param name defines the name of the mesh to create
  21324. * @param xmin set the ground minimum X coordinate
  21325. * @param zmin set the ground minimum Y coordinate
  21326. * @param xmax set the ground maximum X coordinate
  21327. * @param zmax set the ground maximum Z coordinate
  21328. * @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
  21329. * @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
  21330. * @param scene defines the hosting scene
  21331. * @param updatable defines if the mesh must be flagged as updatable
  21332. * @returns a new Mesh
  21333. */
  21334. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21335. w: number;
  21336. h: number;
  21337. }, precision: {
  21338. w: number;
  21339. h: number;
  21340. }, scene: Scene, updatable?: boolean): Mesh;
  21341. /**
  21342. * Creates a ground mesh from a height map.
  21343. * Please consider using the same method from the MeshBuilder class instead
  21344. * @see http://doc.babylonjs.com/babylon101/height_map
  21345. * @param name defines the name of the mesh to create
  21346. * @param url sets the URL of the height map image resource
  21347. * @param width set the ground width size
  21348. * @param height set the ground height size
  21349. * @param subdivisions sets the number of subdivision per side
  21350. * @param minHeight is the minimum altitude on the ground
  21351. * @param maxHeight is the maximum altitude on the ground
  21352. * @param scene defines the hosting scene
  21353. * @param updatable defines if the mesh must be flagged as updatable
  21354. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21355. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21356. * @returns a new Mesh
  21357. */
  21358. 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;
  21359. /**
  21360. * Creates a tube mesh.
  21361. * The tube is a parametric shape.
  21362. * It has no predefined shape. Its final shape will depend on the input parameters.
  21363. * Please consider using the same method from the MeshBuilder class instead
  21364. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21365. * @param name defines the name of the mesh to create
  21366. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21367. * @param radius sets the tube radius size
  21368. * @param tessellation is the number of sides on the tubular surface
  21369. * @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
  21370. * @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
  21371. * @param scene defines the hosting scene
  21372. * @param updatable defines if the mesh must be flagged as updatable
  21373. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21374. * @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)
  21375. * @returns a new Mesh
  21376. */
  21377. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21378. (i: number, distance: number): number;
  21379. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21380. /**
  21381. * Creates a polyhedron mesh.
  21382. * Please consider using the same method from the MeshBuilder class instead.
  21383. * * 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
  21384. * * The parameter `size` (positive float, default 1) sets the polygon size
  21385. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21386. * * 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`
  21387. * * 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
  21388. * * 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)`)
  21389. * * 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
  21390. * * 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
  21391. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21392. * * If you create a double-sided mesh, you can choose what parts of 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
  21393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21394. * @param name defines the name of the mesh to create
  21395. * @param options defines the options used to create the mesh
  21396. * @param scene defines the hosting scene
  21397. * @returns a new Mesh
  21398. */
  21399. static CreatePolyhedron(name: string, options: {
  21400. type?: number;
  21401. size?: number;
  21402. sizeX?: number;
  21403. sizeY?: number;
  21404. sizeZ?: number;
  21405. custom?: any;
  21406. faceUV?: Vector4[];
  21407. faceColors?: Color4[];
  21408. updatable?: boolean;
  21409. sideOrientation?: number;
  21410. }, scene: Scene): Mesh;
  21411. /**
  21412. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21413. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21414. * * 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`)
  21415. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21416. * * 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
  21417. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21418. * * If you create a double-sided mesh, you can choose what parts of 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
  21419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21420. * @param name defines the name of the mesh
  21421. * @param options defines the options used to create the mesh
  21422. * @param scene defines the hosting scene
  21423. * @returns a new Mesh
  21424. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21425. */
  21426. static CreateIcoSphere(name: string, options: {
  21427. radius?: number;
  21428. flat?: boolean;
  21429. subdivisions?: number;
  21430. sideOrientation?: number;
  21431. updatable?: boolean;
  21432. }, scene: Scene): Mesh;
  21433. /**
  21434. * Creates a decal mesh.
  21435. * Please consider using the same method from the MeshBuilder class instead.
  21436. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21437. * @param name defines the name of the mesh
  21438. * @param sourceMesh defines the mesh receiving the decal
  21439. * @param position sets the position of the decal in world coordinates
  21440. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21441. * @param size sets the decal scaling
  21442. * @param angle sets the angle to rotate the decal
  21443. * @returns a new Mesh
  21444. */
  21445. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21446. /**
  21447. * Prepare internal position array for software CPU skinning
  21448. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21449. */
  21450. setPositionsForCPUSkinning(): Float32Array;
  21451. /**
  21452. * Prepare internal normal array for software CPU skinning
  21453. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21454. */
  21455. setNormalsForCPUSkinning(): Float32Array;
  21456. /**
  21457. * Updates the vertex buffer by applying transformation from the bones
  21458. * @param skeleton defines the skeleton to apply to current mesh
  21459. * @returns the current mesh
  21460. */
  21461. applySkeleton(skeleton: Skeleton): Mesh;
  21462. /**
  21463. * 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
  21464. * @param meshes defines the list of meshes to scan
  21465. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21466. */
  21467. static MinMax(meshes: AbstractMesh[]): {
  21468. min: Vector3;
  21469. max: Vector3;
  21470. };
  21471. /**
  21472. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21473. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21474. * @returns a vector3
  21475. */
  21476. static Center(meshesOrMinMaxVector: {
  21477. min: Vector3;
  21478. max: Vector3;
  21479. } | AbstractMesh[]): Vector3;
  21480. /**
  21481. * Merge the array of meshes into a single mesh for performance reasons.
  21482. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21483. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21484. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21485. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21486. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21487. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21488. * @returns a new mesh
  21489. */
  21490. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21491. /** @hidden */
  21492. addInstance(instance: InstancedMesh): void;
  21493. /** @hidden */
  21494. removeInstance(instance: InstancedMesh): void;
  21495. }
  21496. }
  21497. declare module "babylonjs/Materials/material" {
  21498. import { IAnimatable } from "babylonjs/Misc/tools";
  21499. import { SmartArray } from "babylonjs/Misc/smartArray";
  21500. import { Observable } from "babylonjs/Misc/observable";
  21501. import { Nullable } from "babylonjs/types";
  21502. import { Scene } from "babylonjs/scene";
  21503. import { Matrix } from "babylonjs/Maths/math";
  21504. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21506. import { Mesh } from "babylonjs/Meshes/mesh";
  21507. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21508. import { Effect } from "babylonjs/Materials/effect";
  21509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21510. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21511. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21512. import { Animation } from "babylonjs/Animations/animation";
  21513. /**
  21514. * Base class for the main features of a material in Babylon.js
  21515. */
  21516. export class Material implements IAnimatable {
  21517. /**
  21518. * Returns the triangle fill mode
  21519. */
  21520. static readonly TriangleFillMode: number;
  21521. /**
  21522. * Returns the wireframe mode
  21523. */
  21524. static readonly WireFrameFillMode: number;
  21525. /**
  21526. * Returns the point fill mode
  21527. */
  21528. static readonly PointFillMode: number;
  21529. /**
  21530. * Returns the point list draw mode
  21531. */
  21532. static readonly PointListDrawMode: number;
  21533. /**
  21534. * Returns the line list draw mode
  21535. */
  21536. static readonly LineListDrawMode: number;
  21537. /**
  21538. * Returns the line loop draw mode
  21539. */
  21540. static readonly LineLoopDrawMode: number;
  21541. /**
  21542. * Returns the line strip draw mode
  21543. */
  21544. static readonly LineStripDrawMode: number;
  21545. /**
  21546. * Returns the triangle strip draw mode
  21547. */
  21548. static readonly TriangleStripDrawMode: number;
  21549. /**
  21550. * Returns the triangle fan draw mode
  21551. */
  21552. static readonly TriangleFanDrawMode: number;
  21553. /**
  21554. * Stores the clock-wise side orientation
  21555. */
  21556. static readonly ClockWiseSideOrientation: number;
  21557. /**
  21558. * Stores the counter clock-wise side orientation
  21559. */
  21560. static readonly CounterClockWiseSideOrientation: number;
  21561. /**
  21562. * The dirty texture flag value
  21563. */
  21564. static readonly TextureDirtyFlag: number;
  21565. /**
  21566. * The dirty light flag value
  21567. */
  21568. static readonly LightDirtyFlag: number;
  21569. /**
  21570. * The dirty fresnel flag value
  21571. */
  21572. static readonly FresnelDirtyFlag: number;
  21573. /**
  21574. * The dirty attribute flag value
  21575. */
  21576. static readonly AttributesDirtyFlag: number;
  21577. /**
  21578. * The dirty misc flag value
  21579. */
  21580. static readonly MiscDirtyFlag: number;
  21581. /**
  21582. * The all dirty flag value
  21583. */
  21584. static readonly AllDirtyFlag: number;
  21585. /**
  21586. * The ID of the material
  21587. */
  21588. id: string;
  21589. /**
  21590. * Gets or sets the unique id of the material
  21591. */
  21592. uniqueId: number;
  21593. /**
  21594. * The name of the material
  21595. */
  21596. name: string;
  21597. /**
  21598. * Gets or sets user defined metadata
  21599. */
  21600. metadata: any;
  21601. /**
  21602. * For internal use only. Please do not use.
  21603. */
  21604. reservedDataStore: any;
  21605. /**
  21606. * Specifies if the ready state should be checked on each call
  21607. */
  21608. checkReadyOnEveryCall: boolean;
  21609. /**
  21610. * Specifies if the ready state should be checked once
  21611. */
  21612. checkReadyOnlyOnce: boolean;
  21613. /**
  21614. * The state of the material
  21615. */
  21616. state: string;
  21617. /**
  21618. * The alpha value of the material
  21619. */
  21620. protected _alpha: number;
  21621. /**
  21622. * Sets the alpha value of the material
  21623. */
  21624. /**
  21625. * Gets the alpha value of the material
  21626. */
  21627. alpha: number;
  21628. /**
  21629. * Specifies if back face culling is enabled
  21630. */
  21631. protected _backFaceCulling: boolean;
  21632. /**
  21633. * Sets the back-face culling state
  21634. */
  21635. /**
  21636. * Gets the back-face culling state
  21637. */
  21638. backFaceCulling: boolean;
  21639. /**
  21640. * Stores the value for side orientation
  21641. */
  21642. sideOrientation: number;
  21643. /**
  21644. * Callback triggered when the material is compiled
  21645. */
  21646. onCompiled: (effect: Effect) => void;
  21647. /**
  21648. * Callback triggered when an error occurs
  21649. */
  21650. onError: (effect: Effect, errors: string) => void;
  21651. /**
  21652. * Callback triggered to get the render target textures
  21653. */
  21654. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21655. /**
  21656. * Gets a boolean indicating that current material needs to register RTT
  21657. */
  21658. readonly hasRenderTargetTextures: boolean;
  21659. /**
  21660. * Specifies if the material should be serialized
  21661. */
  21662. doNotSerialize: boolean;
  21663. /**
  21664. * @hidden
  21665. */
  21666. _storeEffectOnSubMeshes: boolean;
  21667. /**
  21668. * Stores the animations for the material
  21669. */
  21670. animations: Array<Animation>;
  21671. /**
  21672. * An event triggered when the material is disposed
  21673. */
  21674. onDisposeObservable: Observable<Material>;
  21675. /**
  21676. * An observer which watches for dispose events
  21677. */
  21678. private _onDisposeObserver;
  21679. private _onUnBindObservable;
  21680. /**
  21681. * Called during a dispose event
  21682. */
  21683. onDispose: () => void;
  21684. private _onBindObservable;
  21685. /**
  21686. * An event triggered when the material is bound
  21687. */
  21688. readonly onBindObservable: Observable<AbstractMesh>;
  21689. /**
  21690. * An observer which watches for bind events
  21691. */
  21692. private _onBindObserver;
  21693. /**
  21694. * Called during a bind event
  21695. */
  21696. onBind: (Mesh: AbstractMesh) => void;
  21697. /**
  21698. * An event triggered when the material is unbound
  21699. */
  21700. readonly onUnBindObservable: Observable<Material>;
  21701. /**
  21702. * Stores the value of the alpha mode
  21703. */
  21704. private _alphaMode;
  21705. /**
  21706. * Sets the value of the alpha mode.
  21707. *
  21708. * | Value | Type | Description |
  21709. * | --- | --- | --- |
  21710. * | 0 | ALPHA_DISABLE | |
  21711. * | 1 | ALPHA_ADD | |
  21712. * | 2 | ALPHA_COMBINE | |
  21713. * | 3 | ALPHA_SUBTRACT | |
  21714. * | 4 | ALPHA_MULTIPLY | |
  21715. * | 5 | ALPHA_MAXIMIZED | |
  21716. * | 6 | ALPHA_ONEONE | |
  21717. * | 7 | ALPHA_PREMULTIPLIED | |
  21718. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21719. * | 9 | ALPHA_INTERPOLATE | |
  21720. * | 10 | ALPHA_SCREENMODE | |
  21721. *
  21722. */
  21723. /**
  21724. * Gets the value of the alpha mode
  21725. */
  21726. alphaMode: number;
  21727. /**
  21728. * Stores the state of the need depth pre-pass value
  21729. */
  21730. private _needDepthPrePass;
  21731. /**
  21732. * Sets the need depth pre-pass value
  21733. */
  21734. /**
  21735. * Gets the depth pre-pass value
  21736. */
  21737. needDepthPrePass: boolean;
  21738. /**
  21739. * Specifies if depth writing should be disabled
  21740. */
  21741. disableDepthWrite: boolean;
  21742. /**
  21743. * Specifies if depth writing should be forced
  21744. */
  21745. forceDepthWrite: boolean;
  21746. /**
  21747. * Specifies if there should be a separate pass for culling
  21748. */
  21749. separateCullingPass: boolean;
  21750. /**
  21751. * Stores the state specifing if fog should be enabled
  21752. */
  21753. private _fogEnabled;
  21754. /**
  21755. * Sets the state for enabling fog
  21756. */
  21757. /**
  21758. * Gets the value of the fog enabled state
  21759. */
  21760. fogEnabled: boolean;
  21761. /**
  21762. * Stores the size of points
  21763. */
  21764. pointSize: number;
  21765. /**
  21766. * Stores the z offset value
  21767. */
  21768. zOffset: number;
  21769. /**
  21770. * Gets a value specifying if wireframe mode is enabled
  21771. */
  21772. /**
  21773. * Sets the state of wireframe mode
  21774. */
  21775. wireframe: boolean;
  21776. /**
  21777. * Gets the value specifying if point clouds are enabled
  21778. */
  21779. /**
  21780. * Sets the state of point cloud mode
  21781. */
  21782. pointsCloud: boolean;
  21783. /**
  21784. * Gets the material fill mode
  21785. */
  21786. /**
  21787. * Sets the material fill mode
  21788. */
  21789. fillMode: number;
  21790. /**
  21791. * @hidden
  21792. * Stores the effects for the material
  21793. */
  21794. _effect: Nullable<Effect>;
  21795. /**
  21796. * @hidden
  21797. * Specifies if the material was previously ready
  21798. */
  21799. _wasPreviouslyReady: boolean;
  21800. /**
  21801. * Specifies if uniform buffers should be used
  21802. */
  21803. private _useUBO;
  21804. /**
  21805. * Stores a reference to the scene
  21806. */
  21807. private _scene;
  21808. /**
  21809. * Stores the fill mode state
  21810. */
  21811. private _fillMode;
  21812. /**
  21813. * Specifies if the depth write state should be cached
  21814. */
  21815. private _cachedDepthWriteState;
  21816. /**
  21817. * Stores the uniform buffer
  21818. */
  21819. protected _uniformBuffer: UniformBuffer;
  21820. /** @hidden */
  21821. _indexInSceneMaterialArray: number;
  21822. /** @hidden */
  21823. meshMap: Nullable<{
  21824. [id: string]: AbstractMesh | undefined;
  21825. }>;
  21826. /**
  21827. * Creates a material instance
  21828. * @param name defines the name of the material
  21829. * @param scene defines the scene to reference
  21830. * @param doNotAdd specifies if the material should be added to the scene
  21831. */
  21832. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21833. /**
  21834. * Returns a string representation of the current material
  21835. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21836. * @returns a string with material information
  21837. */
  21838. toString(fullDetails?: boolean): string;
  21839. /**
  21840. * Gets the class name of the material
  21841. * @returns a string with the class name of the material
  21842. */
  21843. getClassName(): string;
  21844. /**
  21845. * Specifies if updates for the material been locked
  21846. */
  21847. readonly isFrozen: boolean;
  21848. /**
  21849. * Locks updates for the material
  21850. */
  21851. freeze(): void;
  21852. /**
  21853. * Unlocks updates for the material
  21854. */
  21855. unfreeze(): void;
  21856. /**
  21857. * Specifies if the material is ready to be used
  21858. * @param mesh defines the mesh to check
  21859. * @param useInstances specifies if instances should be used
  21860. * @returns a boolean indicating if the material is ready to be used
  21861. */
  21862. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21863. /**
  21864. * Specifies that the submesh is ready to be used
  21865. * @param mesh defines the mesh to check
  21866. * @param subMesh defines which submesh to check
  21867. * @param useInstances specifies that instances should be used
  21868. * @returns a boolean indicating that the submesh is ready or not
  21869. */
  21870. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21871. /**
  21872. * Returns the material effect
  21873. * @returns the effect associated with the material
  21874. */
  21875. getEffect(): Nullable<Effect>;
  21876. /**
  21877. * Returns the current scene
  21878. * @returns a Scene
  21879. */
  21880. getScene(): Scene;
  21881. /**
  21882. * Specifies if the material will require alpha blending
  21883. * @returns a boolean specifying if alpha blending is needed
  21884. */
  21885. needAlphaBlending(): boolean;
  21886. /**
  21887. * Specifies if the mesh will require alpha blending
  21888. * @param mesh defines the mesh to check
  21889. * @returns a boolean specifying if alpha blending is needed for the mesh
  21890. */
  21891. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21892. /**
  21893. * Specifies if this material should be rendered in alpha test mode
  21894. * @returns a boolean specifying if an alpha test is needed.
  21895. */
  21896. needAlphaTesting(): boolean;
  21897. /**
  21898. * Gets the texture used for the alpha test
  21899. * @returns the texture to use for alpha testing
  21900. */
  21901. getAlphaTestTexture(): Nullable<BaseTexture>;
  21902. /**
  21903. * Marks the material to indicate that it needs to be re-calculated
  21904. */
  21905. markDirty(): void;
  21906. /** @hidden */
  21907. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21908. /**
  21909. * Binds the material to the mesh
  21910. * @param world defines the world transformation matrix
  21911. * @param mesh defines the mesh to bind the material to
  21912. */
  21913. bind(world: Matrix, mesh?: Mesh): void;
  21914. /**
  21915. * Binds the submesh to the material
  21916. * @param world defines the world transformation matrix
  21917. * @param mesh defines the mesh containing the submesh
  21918. * @param subMesh defines the submesh to bind the material to
  21919. */
  21920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21921. /**
  21922. * Binds the world matrix to the material
  21923. * @param world defines the world transformation matrix
  21924. */
  21925. bindOnlyWorldMatrix(world: Matrix): void;
  21926. /**
  21927. * Binds the scene's uniform buffer to the effect.
  21928. * @param effect defines the effect to bind to the scene uniform buffer
  21929. * @param sceneUbo defines the uniform buffer storing scene data
  21930. */
  21931. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21932. /**
  21933. * Binds the view matrix to the effect
  21934. * @param effect defines the effect to bind the view matrix to
  21935. */
  21936. bindView(effect: Effect): void;
  21937. /**
  21938. * Binds the view projection matrix to the effect
  21939. * @param effect defines the effect to bind the view projection matrix to
  21940. */
  21941. bindViewProjection(effect: Effect): void;
  21942. /**
  21943. * Specifies if material alpha testing should be turned on for the mesh
  21944. * @param mesh defines the mesh to check
  21945. */
  21946. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21947. /**
  21948. * Processes to execute after binding the material to a mesh
  21949. * @param mesh defines the rendered mesh
  21950. */
  21951. protected _afterBind(mesh?: Mesh): void;
  21952. /**
  21953. * Unbinds the material from the mesh
  21954. */
  21955. unbind(): void;
  21956. /**
  21957. * Gets the active textures from the material
  21958. * @returns an array of textures
  21959. */
  21960. getActiveTextures(): BaseTexture[];
  21961. /**
  21962. * Specifies if the material uses a texture
  21963. * @param texture defines the texture to check against the material
  21964. * @returns a boolean specifying if the material uses the texture
  21965. */
  21966. hasTexture(texture: BaseTexture): boolean;
  21967. /**
  21968. * Makes a duplicate of the material, and gives it a new name
  21969. * @param name defines the new name for the duplicated material
  21970. * @returns the cloned material
  21971. */
  21972. clone(name: string): Nullable<Material>;
  21973. /**
  21974. * Gets the meshes bound to the material
  21975. * @returns an array of meshes bound to the material
  21976. */
  21977. getBindedMeshes(): AbstractMesh[];
  21978. /**
  21979. * Force shader compilation
  21980. * @param mesh defines the mesh associated with this material
  21981. * @param onCompiled defines a function to execute once the material is compiled
  21982. * @param options defines the options to configure the compilation
  21983. */
  21984. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21985. clipPlane: boolean;
  21986. }>): void;
  21987. /**
  21988. * Force shader compilation
  21989. * @param mesh defines the mesh that will use this material
  21990. * @param options defines additional options for compiling the shaders
  21991. * @returns a promise that resolves when the compilation completes
  21992. */
  21993. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21994. clipPlane: boolean;
  21995. }>): Promise<void>;
  21996. private static readonly _ImageProcessingDirtyCallBack;
  21997. private static readonly _TextureDirtyCallBack;
  21998. private static readonly _FresnelDirtyCallBack;
  21999. private static readonly _MiscDirtyCallBack;
  22000. private static readonly _LightsDirtyCallBack;
  22001. private static readonly _AttributeDirtyCallBack;
  22002. private static _FresnelAndMiscDirtyCallBack;
  22003. private static _TextureAndMiscDirtyCallBack;
  22004. private static readonly _DirtyCallbackArray;
  22005. private static readonly _RunDirtyCallBacks;
  22006. /**
  22007. * Marks a define in the material to indicate that it needs to be re-computed
  22008. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22009. */
  22010. markAsDirty(flag: number): void;
  22011. /**
  22012. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22013. * @param func defines a function which checks material defines against the submeshes
  22014. */
  22015. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22016. /**
  22017. * Indicates that image processing needs to be re-calculated for all submeshes
  22018. */
  22019. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22020. /**
  22021. * Indicates that textures need to be re-calculated for all submeshes
  22022. */
  22023. protected _markAllSubMeshesAsTexturesDirty(): void;
  22024. /**
  22025. * Indicates that fresnel needs to be re-calculated for all submeshes
  22026. */
  22027. protected _markAllSubMeshesAsFresnelDirty(): void;
  22028. /**
  22029. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22030. */
  22031. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22032. /**
  22033. * Indicates that lights need to be re-calculated for all submeshes
  22034. */
  22035. protected _markAllSubMeshesAsLightsDirty(): void;
  22036. /**
  22037. * Indicates that attributes need to be re-calculated for all submeshes
  22038. */
  22039. protected _markAllSubMeshesAsAttributesDirty(): void;
  22040. /**
  22041. * Indicates that misc needs to be re-calculated for all submeshes
  22042. */
  22043. protected _markAllSubMeshesAsMiscDirty(): void;
  22044. /**
  22045. * Indicates that textures and misc need to be re-calculated for all submeshes
  22046. */
  22047. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22048. /**
  22049. * Disposes the material
  22050. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22051. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22052. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22053. */
  22054. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22055. /** @hidden */
  22056. private releaseVertexArrayObject;
  22057. /**
  22058. * Serializes this material
  22059. * @returns the serialized material object
  22060. */
  22061. serialize(): any;
  22062. /**
  22063. * Creates a material from parsed material data
  22064. * @param parsedMaterial defines parsed material data
  22065. * @param scene defines the hosting scene
  22066. * @param rootUrl defines the root URL to use to load textures
  22067. * @returns a new material
  22068. */
  22069. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22070. }
  22071. }
  22072. declare module "babylonjs/Meshes/subMesh" {
  22073. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22074. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22075. import { Engine } from "babylonjs/Engines/engine";
  22076. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22077. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22078. import { Effect } from "babylonjs/Materials/effect";
  22079. import { Collider } from "babylonjs/Collisions/collider";
  22080. import { Material } from "babylonjs/Materials/material";
  22081. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22083. import { Mesh } from "babylonjs/Meshes/mesh";
  22084. import { Ray } from "babylonjs/Culling/ray";
  22085. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22086. /**
  22087. * Base class for submeshes
  22088. */
  22089. export class BaseSubMesh {
  22090. /** @hidden */
  22091. _materialDefines: Nullable<MaterialDefines>;
  22092. /** @hidden */
  22093. _materialEffect: Nullable<Effect>;
  22094. /**
  22095. * Gets associated effect
  22096. */
  22097. readonly effect: Nullable<Effect>;
  22098. /**
  22099. * Sets associated effect (effect used to render this submesh)
  22100. * @param effect defines the effect to associate with
  22101. * @param defines defines the set of defines used to compile this effect
  22102. */
  22103. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22104. }
  22105. /**
  22106. * Defines a subdivision inside a mesh
  22107. */
  22108. export class SubMesh extends BaseSubMesh implements ICullable {
  22109. /** the material index to use */
  22110. materialIndex: number;
  22111. /** vertex index start */
  22112. verticesStart: number;
  22113. /** vertices count */
  22114. verticesCount: number;
  22115. /** index start */
  22116. indexStart: number;
  22117. /** indices count */
  22118. indexCount: number;
  22119. /** @hidden */
  22120. _linesIndexCount: number;
  22121. private _mesh;
  22122. private _renderingMesh;
  22123. private _boundingInfo;
  22124. private _linesIndexBuffer;
  22125. /** @hidden */
  22126. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22127. /** @hidden */
  22128. _trianglePlanes: Plane[];
  22129. /** @hidden */
  22130. _lastColliderTransformMatrix: Matrix;
  22131. /** @hidden */
  22132. _renderId: number;
  22133. /** @hidden */
  22134. _alphaIndex: number;
  22135. /** @hidden */
  22136. _distanceToCamera: number;
  22137. /** @hidden */
  22138. _id: number;
  22139. private _currentMaterial;
  22140. /**
  22141. * Add a new submesh to a mesh
  22142. * @param materialIndex defines the material index to use
  22143. * @param verticesStart defines vertex index start
  22144. * @param verticesCount defines vertices count
  22145. * @param indexStart defines index start
  22146. * @param indexCount defines indices count
  22147. * @param mesh defines the parent mesh
  22148. * @param renderingMesh defines an optional rendering mesh
  22149. * @param createBoundingBox defines if bounding box should be created for this submesh
  22150. * @returns the new submesh
  22151. */
  22152. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22153. /**
  22154. * Creates a new submesh
  22155. * @param materialIndex defines the material index to use
  22156. * @param verticesStart defines vertex index start
  22157. * @param verticesCount defines vertices count
  22158. * @param indexStart defines index start
  22159. * @param indexCount defines indices count
  22160. * @param mesh defines the parent mesh
  22161. * @param renderingMesh defines an optional rendering mesh
  22162. * @param createBoundingBox defines if bounding box should be created for this submesh
  22163. */
  22164. constructor(
  22165. /** the material index to use */
  22166. materialIndex: number,
  22167. /** vertex index start */
  22168. verticesStart: number,
  22169. /** vertices count */
  22170. verticesCount: number,
  22171. /** index start */
  22172. indexStart: number,
  22173. /** indices count */
  22174. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22175. /**
  22176. * Returns true if this submesh covers the entire parent mesh
  22177. * @ignorenaming
  22178. */
  22179. readonly IsGlobal: boolean;
  22180. /**
  22181. * Returns the submesh BoudingInfo object
  22182. * @returns current bounding info (or mesh's one if the submesh is global)
  22183. */
  22184. getBoundingInfo(): BoundingInfo;
  22185. /**
  22186. * Sets the submesh BoundingInfo
  22187. * @param boundingInfo defines the new bounding info to use
  22188. * @returns the SubMesh
  22189. */
  22190. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22191. /**
  22192. * Returns the mesh of the current submesh
  22193. * @return the parent mesh
  22194. */
  22195. getMesh(): AbstractMesh;
  22196. /**
  22197. * Returns the rendering mesh of the submesh
  22198. * @returns the rendering mesh (could be different from parent mesh)
  22199. */
  22200. getRenderingMesh(): Mesh;
  22201. /**
  22202. * Returns the submesh material
  22203. * @returns null or the current material
  22204. */
  22205. getMaterial(): Nullable<Material>;
  22206. /**
  22207. * Sets a new updated BoundingInfo object to the submesh
  22208. * @returns the SubMesh
  22209. */
  22210. refreshBoundingInfo(): SubMesh;
  22211. /** @hidden */
  22212. _checkCollision(collider: Collider): boolean;
  22213. /**
  22214. * Updates the submesh BoundingInfo
  22215. * @param world defines the world matrix to use to update the bounding info
  22216. * @returns the submesh
  22217. */
  22218. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22219. /**
  22220. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22221. * @param frustumPlanes defines the frustum planes
  22222. * @returns true if the submesh is intersecting with the frustum
  22223. */
  22224. isInFrustum(frustumPlanes: Plane[]): boolean;
  22225. /**
  22226. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22227. * @param frustumPlanes defines the frustum planes
  22228. * @returns true if the submesh is inside the frustum
  22229. */
  22230. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22231. /**
  22232. * Renders the submesh
  22233. * @param enableAlphaMode defines if alpha needs to be used
  22234. * @returns the submesh
  22235. */
  22236. render(enableAlphaMode: boolean): SubMesh;
  22237. /**
  22238. * @hidden
  22239. */
  22240. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22241. /**
  22242. * Checks if the submesh intersects with a ray
  22243. * @param ray defines the ray to test
  22244. * @returns true is the passed ray intersects the submesh bounding box
  22245. */
  22246. canIntersects(ray: Ray): boolean;
  22247. /**
  22248. * Intersects current submesh with a ray
  22249. * @param ray defines the ray to test
  22250. * @param positions defines mesh's positions array
  22251. * @param indices defines mesh's indices array
  22252. * @param fastCheck defines if only bounding info should be used
  22253. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22254. * @returns intersection info or null if no intersection
  22255. */
  22256. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22257. /** @hidden */
  22258. private _intersectLines;
  22259. /** @hidden */
  22260. private _intersectTriangles;
  22261. /** @hidden */
  22262. _rebuild(): void;
  22263. /**
  22264. * Creates a new submesh from the passed mesh
  22265. * @param newMesh defines the new hosting mesh
  22266. * @param newRenderingMesh defines an optional rendering mesh
  22267. * @returns the new submesh
  22268. */
  22269. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22270. /**
  22271. * Release associated resources
  22272. */
  22273. dispose(): void;
  22274. /**
  22275. * Gets the class name
  22276. * @returns the string "SubMesh".
  22277. */
  22278. getClassName(): string;
  22279. /**
  22280. * Creates a new submesh from indices data
  22281. * @param materialIndex the index of the main mesh material
  22282. * @param startIndex the index where to start the copy in the mesh indices array
  22283. * @param indexCount the number of indices to copy then from the startIndex
  22284. * @param mesh the main mesh to create the submesh from
  22285. * @param renderingMesh the optional rendering mesh
  22286. * @returns a new submesh
  22287. */
  22288. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22289. }
  22290. }
  22291. declare module "babylonjs/Meshes/geometry" {
  22292. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22293. import { Scene } from "babylonjs/scene";
  22294. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22295. import { Engine } from "babylonjs/Engines/engine";
  22296. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22297. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22298. import { Effect } from "babylonjs/Materials/effect";
  22299. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22300. import { Mesh } from "babylonjs/Meshes/mesh";
  22301. /**
  22302. * Class used to store geometry data (vertex buffers + index buffer)
  22303. */
  22304. export class Geometry implements IGetSetVerticesData {
  22305. /**
  22306. * Gets or sets the ID of the geometry
  22307. */
  22308. id: string;
  22309. /**
  22310. * Gets or sets the unique ID of the geometry
  22311. */
  22312. uniqueId: number;
  22313. /**
  22314. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22315. */
  22316. delayLoadState: number;
  22317. /**
  22318. * Gets the file containing the data to load when running in delay load state
  22319. */
  22320. delayLoadingFile: Nullable<string>;
  22321. /**
  22322. * Callback called when the geometry is updated
  22323. */
  22324. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22325. private _scene;
  22326. private _engine;
  22327. private _meshes;
  22328. private _totalVertices;
  22329. /** @hidden */
  22330. _indices: IndicesArray;
  22331. /** @hidden */
  22332. _vertexBuffers: {
  22333. [key: string]: VertexBuffer;
  22334. };
  22335. private _isDisposed;
  22336. private _extend;
  22337. private _boundingBias;
  22338. /** @hidden */
  22339. _delayInfo: Array<string>;
  22340. private _indexBuffer;
  22341. private _indexBufferIsUpdatable;
  22342. /** @hidden */
  22343. _boundingInfo: Nullable<BoundingInfo>;
  22344. /** @hidden */
  22345. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22346. /** @hidden */
  22347. _softwareSkinningFrameId: number;
  22348. private _vertexArrayObjects;
  22349. private _updatable;
  22350. /** @hidden */
  22351. _positions: Nullable<Vector3[]>;
  22352. /**
  22353. * 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
  22354. */
  22355. /**
  22356. * 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
  22357. */
  22358. boundingBias: Vector2;
  22359. /**
  22360. * Static function used to attach a new empty geometry to a mesh
  22361. * @param mesh defines the mesh to attach the geometry to
  22362. * @returns the new Geometry
  22363. */
  22364. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22365. /**
  22366. * Creates a new geometry
  22367. * @param id defines the unique ID
  22368. * @param scene defines the hosting scene
  22369. * @param vertexData defines the VertexData used to get geometry data
  22370. * @param updatable defines if geometry must be updatable (false by default)
  22371. * @param mesh defines the mesh that will be associated with the geometry
  22372. */
  22373. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22374. /**
  22375. * Gets the current extend of the geometry
  22376. */
  22377. readonly extend: {
  22378. minimum: Vector3;
  22379. maximum: Vector3;
  22380. };
  22381. /**
  22382. * Gets the hosting scene
  22383. * @returns the hosting Scene
  22384. */
  22385. getScene(): Scene;
  22386. /**
  22387. * Gets the hosting engine
  22388. * @returns the hosting Engine
  22389. */
  22390. getEngine(): Engine;
  22391. /**
  22392. * Defines if the geometry is ready to use
  22393. * @returns true if the geometry is ready to be used
  22394. */
  22395. isReady(): boolean;
  22396. /**
  22397. * Gets a value indicating that the geometry should not be serialized
  22398. */
  22399. readonly doNotSerialize: boolean;
  22400. /** @hidden */
  22401. _rebuild(): void;
  22402. /**
  22403. * Affects all geometry data in one call
  22404. * @param vertexData defines the geometry data
  22405. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22406. */
  22407. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22408. /**
  22409. * Set specific vertex data
  22410. * @param kind defines the data kind (Position, normal, etc...)
  22411. * @param data defines the vertex data to use
  22412. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22413. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22414. */
  22415. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22416. /**
  22417. * Removes a specific vertex data
  22418. * @param kind defines the data kind (Position, normal, etc...)
  22419. */
  22420. removeVerticesData(kind: string): void;
  22421. /**
  22422. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22423. * @param buffer defines the vertex buffer to use
  22424. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22425. */
  22426. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22427. /**
  22428. * Update a specific vertex buffer
  22429. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22430. * It will do nothing if the buffer is not updatable
  22431. * @param kind defines the data kind (Position, normal, etc...)
  22432. * @param data defines the data to use
  22433. * @param offset defines the offset in the target buffer where to store the data
  22434. * @param useBytes set to true if the offset is in bytes
  22435. */
  22436. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22437. /**
  22438. * Update a specific vertex buffer
  22439. * This function will create a new buffer if the current one is not updatable
  22440. * @param kind defines the data kind (Position, normal, etc...)
  22441. * @param data defines the data to use
  22442. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22443. */
  22444. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22445. private _updateBoundingInfo;
  22446. /** @hidden */
  22447. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22448. /**
  22449. * Gets total number of vertices
  22450. * @returns the total number of vertices
  22451. */
  22452. getTotalVertices(): number;
  22453. /**
  22454. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22455. * @param kind defines the data kind (Position, normal, etc...)
  22456. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22458. * @returns a float array containing vertex data
  22459. */
  22460. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22461. /**
  22462. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22463. * @param kind defines the data kind (Position, normal, etc...)
  22464. * @returns true if the vertex buffer with the specified kind is updatable
  22465. */
  22466. isVertexBufferUpdatable(kind: string): boolean;
  22467. /**
  22468. * Gets a specific vertex buffer
  22469. * @param kind defines the data kind (Position, normal, etc...)
  22470. * @returns a VertexBuffer
  22471. */
  22472. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22473. /**
  22474. * Returns all vertex buffers
  22475. * @return an object holding all vertex buffers indexed by kind
  22476. */
  22477. getVertexBuffers(): Nullable<{
  22478. [key: string]: VertexBuffer;
  22479. }>;
  22480. /**
  22481. * Gets a boolean indicating if specific vertex buffer is present
  22482. * @param kind defines the data kind (Position, normal, etc...)
  22483. * @returns true if data is present
  22484. */
  22485. isVerticesDataPresent(kind: string): boolean;
  22486. /**
  22487. * Gets a list of all attached data kinds (Position, normal, etc...)
  22488. * @returns a list of string containing all kinds
  22489. */
  22490. getVerticesDataKinds(): string[];
  22491. /**
  22492. * Update index buffer
  22493. * @param indices defines the indices to store in the index buffer
  22494. * @param offset defines the offset in the target buffer where to store the data
  22495. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22496. */
  22497. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22498. /**
  22499. * Creates a new index buffer
  22500. * @param indices defines the indices to store in the index buffer
  22501. * @param totalVertices defines the total number of vertices (could be null)
  22502. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22503. */
  22504. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22505. /**
  22506. * Return the total number of indices
  22507. * @returns the total number of indices
  22508. */
  22509. getTotalIndices(): number;
  22510. /**
  22511. * Gets the index buffer array
  22512. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22513. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22514. * @returns the index buffer array
  22515. */
  22516. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22517. /**
  22518. * Gets the index buffer
  22519. * @return the index buffer
  22520. */
  22521. getIndexBuffer(): Nullable<WebGLBuffer>;
  22522. /** @hidden */
  22523. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22524. /**
  22525. * Release the associated resources for a specific mesh
  22526. * @param mesh defines the source mesh
  22527. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22528. */
  22529. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22530. /**
  22531. * Apply current geometry to a given mesh
  22532. * @param mesh defines the mesh to apply geometry to
  22533. */
  22534. applyToMesh(mesh: Mesh): void;
  22535. private _updateExtend;
  22536. private _applyToMesh;
  22537. private notifyUpdate;
  22538. /**
  22539. * Load the geometry if it was flagged as delay loaded
  22540. * @param scene defines the hosting scene
  22541. * @param onLoaded defines a callback called when the geometry is loaded
  22542. */
  22543. load(scene: Scene, onLoaded?: () => void): void;
  22544. private _queueLoad;
  22545. /**
  22546. * Invert the geometry to move from a right handed system to a left handed one.
  22547. */
  22548. toLeftHanded(): void;
  22549. /** @hidden */
  22550. _resetPointsArrayCache(): void;
  22551. /** @hidden */
  22552. _generatePointsArray(): boolean;
  22553. /**
  22554. * Gets a value indicating if the geometry is disposed
  22555. * @returns true if the geometry was disposed
  22556. */
  22557. isDisposed(): boolean;
  22558. private _disposeVertexArrayObjects;
  22559. /**
  22560. * Free all associated resources
  22561. */
  22562. dispose(): void;
  22563. /**
  22564. * Clone the current geometry into a new geometry
  22565. * @param id defines the unique ID of the new geometry
  22566. * @returns a new geometry object
  22567. */
  22568. copy(id: string): Geometry;
  22569. /**
  22570. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22571. * @return a JSON representation of the current geometry data (without the vertices data)
  22572. */
  22573. serialize(): any;
  22574. private toNumberArray;
  22575. /**
  22576. * Serialize all vertices data into a JSON oject
  22577. * @returns a JSON representation of the current geometry data
  22578. */
  22579. serializeVerticeData(): any;
  22580. /**
  22581. * Extracts a clone of a mesh geometry
  22582. * @param mesh defines the source mesh
  22583. * @param id defines the unique ID of the new geometry object
  22584. * @returns the new geometry object
  22585. */
  22586. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22587. /**
  22588. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22589. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22590. * Be aware Math.random() could cause collisions, but:
  22591. * "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"
  22592. * @returns a string containing a new GUID
  22593. */
  22594. static RandomId(): string;
  22595. /** @hidden */
  22596. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22597. private static _CleanMatricesWeights;
  22598. /**
  22599. * Create a new geometry from persisted data (Using .babylon file format)
  22600. * @param parsedVertexData defines the persisted data
  22601. * @param scene defines the hosting scene
  22602. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22603. * @returns the new geometry object
  22604. */
  22605. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22606. }
  22607. }
  22608. declare module "babylonjs/Meshes/mesh.vertexData" {
  22609. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22610. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22611. import { Geometry } from "babylonjs/Meshes/geometry";
  22612. import { Mesh } from "babylonjs/Meshes/mesh";
  22613. /**
  22614. * Define an interface for all classes that will get and set the data on vertices
  22615. */
  22616. export interface IGetSetVerticesData {
  22617. /**
  22618. * Gets a boolean indicating if specific vertex data is present
  22619. * @param kind defines the vertex data kind to use
  22620. * @returns true is data kind is present
  22621. */
  22622. isVerticesDataPresent(kind: string): boolean;
  22623. /**
  22624. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22625. * @param kind defines the data kind (Position, normal, etc...)
  22626. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22628. * @returns a float array containing vertex data
  22629. */
  22630. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22631. /**
  22632. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22633. * @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.
  22634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22635. * @returns the indices array or an empty array if the mesh has no geometry
  22636. */
  22637. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22638. /**
  22639. * Set specific vertex data
  22640. * @param kind defines the data kind (Position, normal, etc...)
  22641. * @param data defines the vertex data to use
  22642. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22643. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22644. */
  22645. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22646. /**
  22647. * Update a specific associated vertex buffer
  22648. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22649. * - VertexBuffer.PositionKind
  22650. * - VertexBuffer.UVKind
  22651. * - VertexBuffer.UV2Kind
  22652. * - VertexBuffer.UV3Kind
  22653. * - VertexBuffer.UV4Kind
  22654. * - VertexBuffer.UV5Kind
  22655. * - VertexBuffer.UV6Kind
  22656. * - VertexBuffer.ColorKind
  22657. * - VertexBuffer.MatricesIndicesKind
  22658. * - VertexBuffer.MatricesIndicesExtraKind
  22659. * - VertexBuffer.MatricesWeightsKind
  22660. * - VertexBuffer.MatricesWeightsExtraKind
  22661. * @param data defines the data source
  22662. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22663. * @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)
  22664. */
  22665. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22666. /**
  22667. * Creates a new index buffer
  22668. * @param indices defines the indices to store in the index buffer
  22669. * @param totalVertices defines the total number of vertices (could be null)
  22670. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22671. */
  22672. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22673. }
  22674. /**
  22675. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22676. */
  22677. export class VertexData {
  22678. /**
  22679. * Mesh side orientation : usually the external or front surface
  22680. */
  22681. static readonly FRONTSIDE: number;
  22682. /**
  22683. * Mesh side orientation : usually the internal or back surface
  22684. */
  22685. static readonly BACKSIDE: number;
  22686. /**
  22687. * Mesh side orientation : both internal and external or front and back surfaces
  22688. */
  22689. static readonly DOUBLESIDE: number;
  22690. /**
  22691. * Mesh side orientation : by default, `FRONTSIDE`
  22692. */
  22693. static readonly DEFAULTSIDE: number;
  22694. /**
  22695. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22696. */
  22697. positions: Nullable<FloatArray>;
  22698. /**
  22699. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22700. */
  22701. normals: Nullable<FloatArray>;
  22702. /**
  22703. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22704. */
  22705. tangents: Nullable<FloatArray>;
  22706. /**
  22707. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22708. */
  22709. uvs: Nullable<FloatArray>;
  22710. /**
  22711. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22712. */
  22713. uvs2: Nullable<FloatArray>;
  22714. /**
  22715. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22716. */
  22717. uvs3: Nullable<FloatArray>;
  22718. /**
  22719. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22720. */
  22721. uvs4: Nullable<FloatArray>;
  22722. /**
  22723. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22724. */
  22725. uvs5: Nullable<FloatArray>;
  22726. /**
  22727. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22728. */
  22729. uvs6: Nullable<FloatArray>;
  22730. /**
  22731. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22732. */
  22733. colors: Nullable<FloatArray>;
  22734. /**
  22735. * 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).
  22736. */
  22737. matricesIndices: Nullable<FloatArray>;
  22738. /**
  22739. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22740. */
  22741. matricesWeights: Nullable<FloatArray>;
  22742. /**
  22743. * An array extending the number of possible indices
  22744. */
  22745. matricesIndicesExtra: Nullable<FloatArray>;
  22746. /**
  22747. * An array extending the number of possible weights when the number of indices is extended
  22748. */
  22749. matricesWeightsExtra: Nullable<FloatArray>;
  22750. /**
  22751. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22752. */
  22753. indices: Nullable<IndicesArray>;
  22754. /**
  22755. * Uses the passed data array to set the set the values for the specified kind of data
  22756. * @param data a linear array of floating numbers
  22757. * @param kind the type of data that is being set, eg positions, colors etc
  22758. */
  22759. set(data: FloatArray, kind: string): void;
  22760. /**
  22761. * Associates the vertexData to the passed Mesh.
  22762. * Sets it as updatable or not (default `false`)
  22763. * @param mesh the mesh the vertexData is applied to
  22764. * @param updatable when used and having the value true allows new data to update the vertexData
  22765. * @returns the VertexData
  22766. */
  22767. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22768. /**
  22769. * Associates the vertexData to the passed Geometry.
  22770. * Sets it as updatable or not (default `false`)
  22771. * @param geometry the geometry the vertexData is applied to
  22772. * @param updatable when used and having the value true allows new data to update the vertexData
  22773. * @returns VertexData
  22774. */
  22775. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22776. /**
  22777. * Updates the associated mesh
  22778. * @param mesh the mesh to be updated
  22779. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22780. * @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
  22781. * @returns VertexData
  22782. */
  22783. updateMesh(mesh: Mesh): VertexData;
  22784. /**
  22785. * Updates the associated geometry
  22786. * @param geometry the geometry to be updated
  22787. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22788. * @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
  22789. * @returns VertexData.
  22790. */
  22791. updateGeometry(geometry: Geometry): VertexData;
  22792. private _applyTo;
  22793. private _update;
  22794. /**
  22795. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22796. * @param matrix the transforming matrix
  22797. * @returns the VertexData
  22798. */
  22799. transform(matrix: Matrix): VertexData;
  22800. /**
  22801. * Merges the passed VertexData into the current one
  22802. * @param other the VertexData to be merged into the current one
  22803. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22804. * @returns the modified VertexData
  22805. */
  22806. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22807. private _mergeElement;
  22808. private _validate;
  22809. /**
  22810. * Serializes the VertexData
  22811. * @returns a serialized object
  22812. */
  22813. serialize(): any;
  22814. /**
  22815. * Extracts the vertexData from a mesh
  22816. * @param mesh the mesh from which to extract the VertexData
  22817. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22818. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22819. * @returns the object VertexData associated to the passed mesh
  22820. */
  22821. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22822. /**
  22823. * Extracts the vertexData from the geometry
  22824. * @param geometry the geometry from which to extract the VertexData
  22825. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22826. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22827. * @returns the object VertexData associated to the passed mesh
  22828. */
  22829. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22830. private static _ExtractFrom;
  22831. /**
  22832. * Creates the VertexData for a Ribbon
  22833. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22834. * * pathArray array of paths, each of which an array of successive Vector3
  22835. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22836. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22837. * * 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
  22838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22839. * * 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)
  22840. * * 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)
  22841. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22842. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22843. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22844. * @returns the VertexData of the ribbon
  22845. */
  22846. static CreateRibbon(options: {
  22847. pathArray: Vector3[][];
  22848. closeArray?: boolean;
  22849. closePath?: boolean;
  22850. offset?: number;
  22851. sideOrientation?: number;
  22852. frontUVs?: Vector4;
  22853. backUVs?: Vector4;
  22854. invertUV?: boolean;
  22855. uvs?: Vector2[];
  22856. colors?: Color4[];
  22857. }): VertexData;
  22858. /**
  22859. * Creates the VertexData for a box
  22860. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22861. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22862. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22863. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22864. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22865. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22866. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22868. * * 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)
  22869. * * 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)
  22870. * @returns the VertexData of the box
  22871. */
  22872. static CreateBox(options: {
  22873. size?: number;
  22874. width?: number;
  22875. height?: number;
  22876. depth?: number;
  22877. faceUV?: Vector4[];
  22878. faceColors?: Color4[];
  22879. sideOrientation?: number;
  22880. frontUVs?: Vector4;
  22881. backUVs?: Vector4;
  22882. }): VertexData;
  22883. /**
  22884. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22885. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22886. * * segments sets the number of horizontal strips optional, default 32
  22887. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22888. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22889. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22890. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22891. * * 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
  22892. * * 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
  22893. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22894. * * 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)
  22895. * * 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)
  22896. * @returns the VertexData of the ellipsoid
  22897. */
  22898. static CreateSphere(options: {
  22899. segments?: number;
  22900. diameter?: number;
  22901. diameterX?: number;
  22902. diameterY?: number;
  22903. diameterZ?: number;
  22904. arc?: number;
  22905. slice?: number;
  22906. sideOrientation?: number;
  22907. frontUVs?: Vector4;
  22908. backUVs?: Vector4;
  22909. }): VertexData;
  22910. /**
  22911. * Creates the VertexData for a cylinder, cone or prism
  22912. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22913. * * height sets the height (y direction) of the cylinder, optional, default 2
  22914. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22915. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22916. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22917. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22918. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22919. * * 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
  22920. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22921. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22922. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22923. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22925. * * 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)
  22926. * * 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)
  22927. * @returns the VertexData of the cylinder, cone or prism
  22928. */
  22929. static CreateCylinder(options: {
  22930. height?: number;
  22931. diameterTop?: number;
  22932. diameterBottom?: number;
  22933. diameter?: number;
  22934. tessellation?: number;
  22935. subdivisions?: number;
  22936. arc?: number;
  22937. faceColors?: Color4[];
  22938. faceUV?: Vector4[];
  22939. hasRings?: boolean;
  22940. enclose?: boolean;
  22941. sideOrientation?: number;
  22942. frontUVs?: Vector4;
  22943. backUVs?: Vector4;
  22944. }): VertexData;
  22945. /**
  22946. * Creates the VertexData for a torus
  22947. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22948. * * diameter the diameter of the torus, optional default 1
  22949. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22950. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22952. * * 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)
  22953. * * 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)
  22954. * @returns the VertexData of the torus
  22955. */
  22956. static CreateTorus(options: {
  22957. diameter?: number;
  22958. thickness?: number;
  22959. tessellation?: number;
  22960. sideOrientation?: number;
  22961. frontUVs?: Vector4;
  22962. backUVs?: Vector4;
  22963. }): VertexData;
  22964. /**
  22965. * Creates the VertexData of the LineSystem
  22966. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22967. * - lines an array of lines, each line being an array of successive Vector3
  22968. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22969. * @returns the VertexData of the LineSystem
  22970. */
  22971. static CreateLineSystem(options: {
  22972. lines: Vector3[][];
  22973. colors?: Nullable<Color4[][]>;
  22974. }): VertexData;
  22975. /**
  22976. * Create the VertexData for a DashedLines
  22977. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22978. * - points an array successive Vector3
  22979. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22980. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22981. * - dashNb the intended total number of dashes, optional, default 200
  22982. * @returns the VertexData for the DashedLines
  22983. */
  22984. static CreateDashedLines(options: {
  22985. points: Vector3[];
  22986. dashSize?: number;
  22987. gapSize?: number;
  22988. dashNb?: number;
  22989. }): VertexData;
  22990. /**
  22991. * Creates the VertexData for a Ground
  22992. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22993. * - width the width (x direction) of the ground, optional, default 1
  22994. * - height the height (z direction) of the ground, optional, default 1
  22995. * - subdivisions the number of subdivisions per side, optional, default 1
  22996. * @returns the VertexData of the Ground
  22997. */
  22998. static CreateGround(options: {
  22999. width?: number;
  23000. height?: number;
  23001. subdivisions?: number;
  23002. subdivisionsX?: number;
  23003. subdivisionsY?: number;
  23004. }): VertexData;
  23005. /**
  23006. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23007. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23008. * * xmin the ground minimum X coordinate, optional, default -1
  23009. * * zmin the ground minimum Z coordinate, optional, default -1
  23010. * * xmax the ground maximum X coordinate, optional, default 1
  23011. * * zmax the ground maximum Z coordinate, optional, default 1
  23012. * * 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}
  23013. * * 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}
  23014. * @returns the VertexData of the TiledGround
  23015. */
  23016. static CreateTiledGround(options: {
  23017. xmin: number;
  23018. zmin: number;
  23019. xmax: number;
  23020. zmax: number;
  23021. subdivisions?: {
  23022. w: number;
  23023. h: number;
  23024. };
  23025. precision?: {
  23026. w: number;
  23027. h: number;
  23028. };
  23029. }): VertexData;
  23030. /**
  23031. * Creates the VertexData of the Ground designed from a heightmap
  23032. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23033. * * width the width (x direction) of the ground
  23034. * * height the height (z direction) of the ground
  23035. * * subdivisions the number of subdivisions per side
  23036. * * minHeight the minimum altitude on the ground, optional, default 0
  23037. * * maxHeight the maximum altitude on the ground, optional default 1
  23038. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23039. * * buffer the array holding the image color data
  23040. * * bufferWidth the width of image
  23041. * * bufferHeight the height of image
  23042. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23043. * @returns the VertexData of the Ground designed from a heightmap
  23044. */
  23045. static CreateGroundFromHeightMap(options: {
  23046. width: number;
  23047. height: number;
  23048. subdivisions: number;
  23049. minHeight: number;
  23050. maxHeight: number;
  23051. colorFilter: Color3;
  23052. buffer: Uint8Array;
  23053. bufferWidth: number;
  23054. bufferHeight: number;
  23055. alphaFilter: number;
  23056. }): VertexData;
  23057. /**
  23058. * Creates the VertexData for a Plane
  23059. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23060. * * size sets the width and height of the plane to the value of size, optional default 1
  23061. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23062. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23063. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23064. * * 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)
  23065. * * 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)
  23066. * @returns the VertexData of the box
  23067. */
  23068. static CreatePlane(options: {
  23069. size?: number;
  23070. width?: number;
  23071. height?: number;
  23072. sideOrientation?: number;
  23073. frontUVs?: Vector4;
  23074. backUVs?: Vector4;
  23075. }): VertexData;
  23076. /**
  23077. * Creates the VertexData of the Disc or regular Polygon
  23078. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23079. * * radius the radius of the disc, optional default 0.5
  23080. * * tessellation the number of polygon sides, optional, default 64
  23081. * * 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
  23082. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23083. * * 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)
  23084. * * 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)
  23085. * @returns the VertexData of the box
  23086. */
  23087. static CreateDisc(options: {
  23088. radius?: number;
  23089. tessellation?: number;
  23090. arc?: number;
  23091. sideOrientation?: number;
  23092. frontUVs?: Vector4;
  23093. backUVs?: Vector4;
  23094. }): VertexData;
  23095. /**
  23096. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23097. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23098. * @param polygon a mesh built from polygonTriangulation.build()
  23099. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23100. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23101. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23102. * @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)
  23103. * @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)
  23104. * @returns the VertexData of the Polygon
  23105. */
  23106. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23107. /**
  23108. * Creates the VertexData of the IcoSphere
  23109. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23110. * * radius the radius of the IcoSphere, optional default 1
  23111. * * radiusX allows stretching in the x direction, optional, default radius
  23112. * * radiusY allows stretching in the y direction, optional, default radius
  23113. * * radiusZ allows stretching in the z direction, optional, default radius
  23114. * * flat when true creates a flat shaded mesh, optional, default true
  23115. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23117. * * 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)
  23118. * * 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)
  23119. * @returns the VertexData of the IcoSphere
  23120. */
  23121. static CreateIcoSphere(options: {
  23122. radius?: number;
  23123. radiusX?: number;
  23124. radiusY?: number;
  23125. radiusZ?: number;
  23126. flat?: boolean;
  23127. subdivisions?: number;
  23128. sideOrientation?: number;
  23129. frontUVs?: Vector4;
  23130. backUVs?: Vector4;
  23131. }): VertexData;
  23132. /**
  23133. * Creates the VertexData for a Polyhedron
  23134. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23135. * * type provided types are:
  23136. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23137. * * 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)
  23138. * * size the size of the IcoSphere, optional default 1
  23139. * * sizeX allows stretching in the x direction, optional, default size
  23140. * * sizeY allows stretching in the y direction, optional, default size
  23141. * * sizeZ allows stretching in the z direction, optional, default size
  23142. * * 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
  23143. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23144. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23145. * * flat when true creates a flat shaded mesh, optional, default true
  23146. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23148. * * 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)
  23149. * * 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)
  23150. * @returns the VertexData of the Polyhedron
  23151. */
  23152. static CreatePolyhedron(options: {
  23153. type?: number;
  23154. size?: number;
  23155. sizeX?: number;
  23156. sizeY?: number;
  23157. sizeZ?: number;
  23158. custom?: any;
  23159. faceUV?: Vector4[];
  23160. faceColors?: Color4[];
  23161. flat?: boolean;
  23162. sideOrientation?: number;
  23163. frontUVs?: Vector4;
  23164. backUVs?: Vector4;
  23165. }): VertexData;
  23166. /**
  23167. * Creates the VertexData for a TorusKnot
  23168. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23169. * * radius the radius of the torus knot, optional, default 2
  23170. * * tube the thickness of the tube, optional, default 0.5
  23171. * * radialSegments the number of sides on each tube segments, optional, default 32
  23172. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23173. * * p the number of windings around the z axis, optional, default 2
  23174. * * q the number of windings around the x axis, optional, default 3
  23175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23176. * * 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)
  23177. * * 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)
  23178. * @returns the VertexData of the Torus Knot
  23179. */
  23180. static CreateTorusKnot(options: {
  23181. radius?: number;
  23182. tube?: number;
  23183. radialSegments?: number;
  23184. tubularSegments?: number;
  23185. p?: number;
  23186. q?: number;
  23187. sideOrientation?: number;
  23188. frontUVs?: Vector4;
  23189. backUVs?: Vector4;
  23190. }): VertexData;
  23191. /**
  23192. * Compute normals for given positions and indices
  23193. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23194. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23195. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23196. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23197. * * facetNormals : optional array of facet normals (vector3)
  23198. * * facetPositions : optional array of facet positions (vector3)
  23199. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23200. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23201. * * bInfo : optional bounding info, required for facetPartitioning computation
  23202. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23203. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23204. * * useRightHandedSystem: optional boolean to for right handed system computation
  23205. * * depthSort : optional boolean to enable the facet depth sort computation
  23206. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23207. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23208. */
  23209. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23210. facetNormals?: any;
  23211. facetPositions?: any;
  23212. facetPartitioning?: any;
  23213. ratio?: number;
  23214. bInfo?: any;
  23215. bbSize?: Vector3;
  23216. subDiv?: any;
  23217. useRightHandedSystem?: boolean;
  23218. depthSort?: boolean;
  23219. distanceTo?: Vector3;
  23220. depthSortedFacets?: any;
  23221. }): void;
  23222. /** @hidden */
  23223. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23224. /**
  23225. * Applies VertexData created from the imported parameters to the geometry
  23226. * @param parsedVertexData the parsed data from an imported file
  23227. * @param geometry the geometry to apply the VertexData to
  23228. */
  23229. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23230. }
  23231. }
  23232. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23233. import { Nullable } from "babylonjs/types";
  23234. import { Scene } from "babylonjs/scene";
  23235. import { Vector4 } from "babylonjs/Maths/math";
  23236. import { Mesh } from "babylonjs/Meshes/mesh";
  23237. /**
  23238. * Class containing static functions to help procedurally build meshes
  23239. */
  23240. export class DiscBuilder {
  23241. /**
  23242. * Creates a plane polygonal mesh. By default, this is a disc
  23243. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23244. * * 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
  23245. * * 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
  23246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23249. * @param name defines the name of the mesh
  23250. * @param options defines the options used to create the mesh
  23251. * @param scene defines the hosting scene
  23252. * @returns the plane polygonal mesh
  23253. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23254. */
  23255. static CreateDisc(name: string, options: {
  23256. radius?: number;
  23257. tessellation?: number;
  23258. arc?: number;
  23259. updatable?: boolean;
  23260. sideOrientation?: number;
  23261. frontUVs?: Vector4;
  23262. backUVs?: Vector4;
  23263. }, scene?: Nullable<Scene>): Mesh;
  23264. }
  23265. }
  23266. declare module "babylonjs/Particles/solidParticleSystem" {
  23267. import { Vector3 } from "babylonjs/Maths/math";
  23268. import { Mesh } from "babylonjs/Meshes/mesh";
  23269. import { Scene, IDisposable } from "babylonjs/scene";
  23270. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23271. /**
  23272. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23273. *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.
  23274. * The SPS is also a particle system. It provides some methods to manage the particles.
  23275. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23276. *
  23277. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23278. */
  23279. export class SolidParticleSystem implements IDisposable {
  23280. /**
  23281. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23282. * Example : var p = SPS.particles[i];
  23283. */
  23284. particles: SolidParticle[];
  23285. /**
  23286. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23287. */
  23288. nbParticles: number;
  23289. /**
  23290. * If the particles must ever face the camera (default false). Useful for planar particles.
  23291. */
  23292. billboard: boolean;
  23293. /**
  23294. * Recompute normals when adding a shape
  23295. */
  23296. recomputeNormals: boolean;
  23297. /**
  23298. * This a counter ofr your own usage. It's not set by any SPS functions.
  23299. */
  23300. counter: number;
  23301. /**
  23302. * The SPS name. This name is also given to the underlying mesh.
  23303. */
  23304. name: string;
  23305. /**
  23306. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23307. */
  23308. mesh: Mesh;
  23309. /**
  23310. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23311. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23312. */
  23313. vars: any;
  23314. /**
  23315. * This array is populated when the SPS is set as 'pickable'.
  23316. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23317. * Each element of this array is an object `{idx: int, faceId: int}`.
  23318. * `idx` is the picked particle index in the `SPS.particles` array
  23319. * `faceId` is the picked face index counted within this particle.
  23320. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23321. */
  23322. pickedParticles: {
  23323. idx: number;
  23324. faceId: number;
  23325. }[];
  23326. /**
  23327. * This array is populated when `enableDepthSort` is set to true.
  23328. * Each element of this array is an instance of the class DepthSortedParticle.
  23329. */
  23330. depthSortedParticles: DepthSortedParticle[];
  23331. /**
  23332. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23333. * @hidden
  23334. */
  23335. _bSphereOnly: boolean;
  23336. /**
  23337. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23338. * @hidden
  23339. */
  23340. _bSphereRadiusFactor: number;
  23341. private _scene;
  23342. private _positions;
  23343. private _indices;
  23344. private _normals;
  23345. private _colors;
  23346. private _uvs;
  23347. private _indices32;
  23348. private _positions32;
  23349. private _normals32;
  23350. private _fixedNormal32;
  23351. private _colors32;
  23352. private _uvs32;
  23353. private _index;
  23354. private _updatable;
  23355. private _pickable;
  23356. private _isVisibilityBoxLocked;
  23357. private _alwaysVisible;
  23358. private _depthSort;
  23359. private _shapeCounter;
  23360. private _copy;
  23361. private _color;
  23362. private _computeParticleColor;
  23363. private _computeParticleTexture;
  23364. private _computeParticleRotation;
  23365. private _computeParticleVertex;
  23366. private _computeBoundingBox;
  23367. private _depthSortParticles;
  23368. private _camera;
  23369. private _mustUnrotateFixedNormals;
  23370. private _particlesIntersect;
  23371. private _needs32Bits;
  23372. /**
  23373. * Creates a SPS (Solid Particle System) object.
  23374. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23375. * @param scene (Scene) is the scene in which the SPS is added.
  23376. * @param options defines the options of the sps e.g.
  23377. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23378. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23379. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23380. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23381. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23382. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23383. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23384. */
  23385. constructor(name: string, scene: Scene, options?: {
  23386. updatable?: boolean;
  23387. isPickable?: boolean;
  23388. enableDepthSort?: boolean;
  23389. particleIntersection?: boolean;
  23390. boundingSphereOnly?: boolean;
  23391. bSphereRadiusFactor?: number;
  23392. });
  23393. /**
  23394. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23395. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23396. * @returns the created mesh
  23397. */
  23398. buildMesh(): Mesh;
  23399. /**
  23400. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23401. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23402. * Thus the particles generated from `digest()` have their property `position` set yet.
  23403. * @param mesh ( Mesh ) is the mesh to be digested
  23404. * @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
  23405. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23406. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23407. * @returns the current SPS
  23408. */
  23409. digest(mesh: Mesh, options?: {
  23410. facetNb?: number;
  23411. number?: number;
  23412. delta?: number;
  23413. }): SolidParticleSystem;
  23414. private _unrotateFixedNormals;
  23415. private _resetCopy;
  23416. private _meshBuilder;
  23417. private _posToShape;
  23418. private _uvsToShapeUV;
  23419. private _addParticle;
  23420. /**
  23421. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23422. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23423. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23424. * @param nb (positive integer) the number of particles to be created from this model
  23425. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23426. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23427. * @returns the number of shapes in the system
  23428. */
  23429. addShape(mesh: Mesh, nb: number, options?: {
  23430. positionFunction?: any;
  23431. vertexFunction?: any;
  23432. }): number;
  23433. private _rebuildParticle;
  23434. /**
  23435. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23436. * @returns the SPS.
  23437. */
  23438. rebuildMesh(): SolidParticleSystem;
  23439. /**
  23440. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23441. * This method calls `updateParticle()` for each particle of the SPS.
  23442. * For an animated SPS, it is usually called within the render loop.
  23443. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23444. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23445. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23446. * @returns the SPS.
  23447. */
  23448. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23449. /**
  23450. * Disposes the SPS.
  23451. */
  23452. dispose(): void;
  23453. /**
  23454. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23455. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23456. * @returns the SPS.
  23457. */
  23458. refreshVisibleSize(): SolidParticleSystem;
  23459. /**
  23460. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23461. * @param size the size (float) of the visibility box
  23462. * note : this doesn't lock the SPS mesh bounding box.
  23463. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23464. */
  23465. setVisibilityBox(size: number): void;
  23466. /**
  23467. * Gets whether the SPS as always visible or not
  23468. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23469. */
  23470. /**
  23471. * Sets the SPS as always visible or not
  23472. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23473. */
  23474. isAlwaysVisible: boolean;
  23475. /**
  23476. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23477. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23478. */
  23479. /**
  23480. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23481. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23482. */
  23483. isVisibilityBoxLocked: boolean;
  23484. /**
  23485. * Tells to `setParticles()` to compute the particle rotations or not.
  23486. * Default value : true. The SPS is faster when it's set to false.
  23487. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23488. */
  23489. /**
  23490. * Gets if `setParticles()` computes the particle rotations or not.
  23491. * Default value : true. The SPS is faster when it's set to false.
  23492. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23493. */
  23494. computeParticleRotation: boolean;
  23495. /**
  23496. * Tells to `setParticles()` to compute the particle colors or not.
  23497. * Default value : true. The SPS is faster when it's set to false.
  23498. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23499. */
  23500. /**
  23501. * Gets if `setParticles()` computes the particle colors or not.
  23502. * Default value : true. The SPS is faster when it's set to false.
  23503. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23504. */
  23505. computeParticleColor: boolean;
  23506. /**
  23507. * Gets if `setParticles()` computes the particle textures or not.
  23508. * Default value : true. The SPS is faster when it's set to false.
  23509. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23510. */
  23511. computeParticleTexture: boolean;
  23512. /**
  23513. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23514. * Default value : false. The SPS is faster when it's set to false.
  23515. * Note : the particle custom vertex positions aren't stored values.
  23516. */
  23517. /**
  23518. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23519. * Default value : false. The SPS is faster when it's set to false.
  23520. * Note : the particle custom vertex positions aren't stored values.
  23521. */
  23522. computeParticleVertex: boolean;
  23523. /**
  23524. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23525. */
  23526. /**
  23527. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23528. */
  23529. computeBoundingBox: boolean;
  23530. /**
  23531. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23532. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23533. * Default : `true`
  23534. */
  23535. /**
  23536. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23537. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23538. * Default : `true`
  23539. */
  23540. depthSortParticles: boolean;
  23541. /**
  23542. * This function does nothing. It may be overwritten to set all the particle first values.
  23543. * The SPS doesn't call this function, you may have to call it by your own.
  23544. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23545. */
  23546. initParticles(): void;
  23547. /**
  23548. * This function does nothing. It may be overwritten to recycle a particle.
  23549. * The SPS doesn't call this function, you may have to call it by your own.
  23550. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23551. * @param particle The particle to recycle
  23552. * @returns the recycled particle
  23553. */
  23554. recycleParticle(particle: SolidParticle): SolidParticle;
  23555. /**
  23556. * Updates a particle : this function should be overwritten by the user.
  23557. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23558. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23559. * @example : just set a particle position or velocity and recycle conditions
  23560. * @param particle The particle to update
  23561. * @returns the updated particle
  23562. */
  23563. updateParticle(particle: SolidParticle): SolidParticle;
  23564. /**
  23565. * Updates a vertex of a particle : it can be overwritten by the user.
  23566. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23567. * @param particle the current particle
  23568. * @param vertex the current index of the current particle
  23569. * @param pt the index of the current vertex in the particle shape
  23570. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23571. * @example : just set a vertex particle position
  23572. * @returns the updated vertex
  23573. */
  23574. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23575. /**
  23576. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23577. * This does nothing and may be overwritten by the user.
  23578. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23579. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23580. * @param update the boolean update value actually passed to setParticles()
  23581. */
  23582. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23583. /**
  23584. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23585. * This will be passed three parameters.
  23586. * This does nothing and may be overwritten by the user.
  23587. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23588. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23589. * @param update the boolean update value actually passed to setParticles()
  23590. */
  23591. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23592. }
  23593. }
  23594. declare module "babylonjs/Particles/solidParticle" {
  23595. import { Nullable } from "babylonjs/types";
  23596. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23597. import { Mesh } from "babylonjs/Meshes/mesh";
  23598. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23599. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23600. /**
  23601. * Represents one particle of a solid particle system.
  23602. */
  23603. export class SolidParticle {
  23604. /**
  23605. * particle global index
  23606. */
  23607. idx: number;
  23608. /**
  23609. * The color of the particle
  23610. */
  23611. color: Nullable<Color4>;
  23612. /**
  23613. * The world space position of the particle.
  23614. */
  23615. position: Vector3;
  23616. /**
  23617. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23618. */
  23619. rotation: Vector3;
  23620. /**
  23621. * The world space rotation quaternion of the particle.
  23622. */
  23623. rotationQuaternion: Nullable<Quaternion>;
  23624. /**
  23625. * The scaling of the particle.
  23626. */
  23627. scaling: Vector3;
  23628. /**
  23629. * The uvs of the particle.
  23630. */
  23631. uvs: Vector4;
  23632. /**
  23633. * The current speed of the particle.
  23634. */
  23635. velocity: Vector3;
  23636. /**
  23637. * The pivot point in the particle local space.
  23638. */
  23639. pivot: Vector3;
  23640. /**
  23641. * Must the particle be translated from its pivot point in its local space ?
  23642. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23643. * Default : false
  23644. */
  23645. translateFromPivot: boolean;
  23646. /**
  23647. * Is the particle active or not ?
  23648. */
  23649. alive: boolean;
  23650. /**
  23651. * Is the particle visible or not ?
  23652. */
  23653. isVisible: boolean;
  23654. /**
  23655. * Index of this particle in the global "positions" array (Internal use)
  23656. * @hidden
  23657. */
  23658. _pos: number;
  23659. /**
  23660. * @hidden Index of this particle in the global "indices" array (Internal use)
  23661. */
  23662. _ind: number;
  23663. /**
  23664. * @hidden ModelShape of this particle (Internal use)
  23665. */
  23666. _model: ModelShape;
  23667. /**
  23668. * ModelShape id of this particle
  23669. */
  23670. shapeId: number;
  23671. /**
  23672. * Index of the particle in its shape id (Internal use)
  23673. */
  23674. idxInShape: number;
  23675. /**
  23676. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23677. */
  23678. _modelBoundingInfo: BoundingInfo;
  23679. /**
  23680. * @hidden Particle BoundingInfo object (Internal use)
  23681. */
  23682. _boundingInfo: BoundingInfo;
  23683. /**
  23684. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23685. */
  23686. _sps: SolidParticleSystem;
  23687. /**
  23688. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23689. */
  23690. _stillInvisible: boolean;
  23691. /**
  23692. * @hidden Last computed particle rotation matrix
  23693. */
  23694. _rotationMatrix: number[];
  23695. /**
  23696. * Parent particle Id, if any.
  23697. * Default null.
  23698. */
  23699. parentId: Nullable<number>;
  23700. /**
  23701. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23702. * The possible values are :
  23703. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23704. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23705. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23706. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23707. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23708. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23709. * */
  23710. cullingStrategy: number;
  23711. /**
  23712. * @hidden Internal global position in the SPS.
  23713. */
  23714. _globalPosition: Vector3;
  23715. /**
  23716. * Creates a Solid Particle object.
  23717. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23718. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23719. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23720. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23721. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23722. * @param shapeId (integer) is the model shape identifier in the SPS.
  23723. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23724. * @param sps defines the sps it is associated to
  23725. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23726. */
  23727. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23728. /**
  23729. * Legacy support, changed scale to scaling
  23730. */
  23731. /**
  23732. * Legacy support, changed scale to scaling
  23733. */
  23734. scale: Vector3;
  23735. /**
  23736. * Legacy support, changed quaternion to rotationQuaternion
  23737. */
  23738. /**
  23739. * Legacy support, changed quaternion to rotationQuaternion
  23740. */
  23741. quaternion: Nullable<Quaternion>;
  23742. /**
  23743. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23744. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23745. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23746. * @returns true if it intersects
  23747. */
  23748. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23749. /**
  23750. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23751. * A particle is in the frustum if its bounding box intersects the frustum
  23752. * @param frustumPlanes defines the frustum to test
  23753. * @returns true if the particle is in the frustum planes
  23754. */
  23755. isInFrustum(frustumPlanes: Plane[]): boolean;
  23756. /**
  23757. * get the rotation matrix of the particle
  23758. * @hidden
  23759. */
  23760. getRotationMatrix(m: Matrix): void;
  23761. }
  23762. /**
  23763. * Represents the shape of the model used by one particle of a solid particle system.
  23764. * SPS internal tool, don't use it manually.
  23765. */
  23766. export class ModelShape {
  23767. /**
  23768. * The shape id
  23769. * @hidden
  23770. */
  23771. shapeID: number;
  23772. /**
  23773. * flat array of model positions (internal use)
  23774. * @hidden
  23775. */
  23776. _shape: Vector3[];
  23777. /**
  23778. * flat array of model UVs (internal use)
  23779. * @hidden
  23780. */
  23781. _shapeUV: number[];
  23782. /**
  23783. * length of the shape in the model indices array (internal use)
  23784. * @hidden
  23785. */
  23786. _indicesLength: number;
  23787. /**
  23788. * Custom position function (internal use)
  23789. * @hidden
  23790. */
  23791. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23792. /**
  23793. * Custom vertex function (internal use)
  23794. * @hidden
  23795. */
  23796. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23797. /**
  23798. * 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.
  23799. * SPS internal tool, don't use it manually.
  23800. * @hidden
  23801. */
  23802. 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>);
  23803. }
  23804. /**
  23805. * Represents a Depth Sorted Particle in the solid particle system.
  23806. */
  23807. export class DepthSortedParticle {
  23808. /**
  23809. * Index of the particle in the "indices" array
  23810. */
  23811. ind: number;
  23812. /**
  23813. * Length of the particle shape in the "indices" array
  23814. */
  23815. indicesLength: number;
  23816. /**
  23817. * Squared distance from the particle to the camera
  23818. */
  23819. sqDistance: number;
  23820. }
  23821. }
  23822. declare module "babylonjs/Meshes/abstractMesh" {
  23823. import { Observable } from "babylonjs/Misc/observable";
  23824. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23825. import { Camera } from "babylonjs/Cameras/camera";
  23826. import { Scene, IDisposable } from "babylonjs/scene";
  23827. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23828. import { Node } from "babylonjs/node";
  23829. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23830. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23831. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23832. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23833. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23834. import { Material } from "babylonjs/Materials/material";
  23835. import { Light } from "babylonjs/Lights/light";
  23836. import { Skeleton } from "babylonjs/Bones/skeleton";
  23837. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23838. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23839. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23840. import { Ray } from "babylonjs/Culling/ray";
  23841. import { Collider } from "babylonjs/Collisions/collider";
  23842. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23843. /**
  23844. * Class used to store all common mesh properties
  23845. */
  23846. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23847. /** No occlusion */
  23848. static OCCLUSION_TYPE_NONE: number;
  23849. /** Occlusion set to optimisitic */
  23850. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23851. /** Occlusion set to strict */
  23852. static OCCLUSION_TYPE_STRICT: number;
  23853. /** Use an accurante occlusion algorithm */
  23854. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23855. /** Use a conservative occlusion algorithm */
  23856. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23857. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23858. * Test order :
  23859. * Is the bounding sphere outside the frustum ?
  23860. * If not, are the bounding box vertices outside the frustum ?
  23861. * It not, then the cullable object is in the frustum.
  23862. */
  23863. static readonly CULLINGSTRATEGY_STANDARD: number;
  23864. /** Culling strategy : Bounding Sphere Only.
  23865. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23866. * It's also less accurate than the standard because some not visible objects can still be selected.
  23867. * Test : is the bounding sphere outside the frustum ?
  23868. * If not, then the cullable object is in the frustum.
  23869. */
  23870. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23871. /** Culling strategy : Optimistic Inclusion.
  23872. * This in an inclusion test first, then the standard exclusion test.
  23873. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23874. * 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.
  23875. * Anyway, it's as accurate as the standard strategy.
  23876. * Test :
  23877. * Is the cullable object bounding sphere center in the frustum ?
  23878. * If not, apply the default culling strategy.
  23879. */
  23880. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23881. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23882. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23883. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23884. * 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.
  23885. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23886. * Test :
  23887. * Is the cullable object bounding sphere center in the frustum ?
  23888. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23889. */
  23890. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23891. /**
  23892. * No billboard
  23893. */
  23894. static readonly BILLBOARDMODE_NONE: number;
  23895. /** Billboard on X axis */
  23896. static readonly BILLBOARDMODE_X: number;
  23897. /** Billboard on Y axis */
  23898. static readonly BILLBOARDMODE_Y: number;
  23899. /** Billboard on Z axis */
  23900. static readonly BILLBOARDMODE_Z: number;
  23901. /** Billboard on all axes */
  23902. static readonly BILLBOARDMODE_ALL: number;
  23903. private _facetData;
  23904. /**
  23905. * The culling strategy to use to check whether the mesh must be rendered or not.
  23906. * This value can be changed at any time and will be used on the next render mesh selection.
  23907. * The possible values are :
  23908. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23909. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23910. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23911. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23912. * Please read each static variable documentation to get details about the culling process.
  23913. * */
  23914. cullingStrategy: number;
  23915. /**
  23916. * Gets the number of facets in the mesh
  23917. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23918. */
  23919. readonly facetNb: number;
  23920. /**
  23921. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23923. */
  23924. partitioningSubdivisions: number;
  23925. /**
  23926. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23927. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23929. */
  23930. partitioningBBoxRatio: number;
  23931. /**
  23932. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23933. * Works only for updatable meshes.
  23934. * Doesn't work with multi-materials
  23935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23936. */
  23937. mustDepthSortFacets: boolean;
  23938. /**
  23939. * The location (Vector3) where the facet depth sort must be computed from.
  23940. * By default, the active camera position.
  23941. * Used only when facet depth sort is enabled
  23942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23943. */
  23944. facetDepthSortFrom: Vector3;
  23945. /**
  23946. * gets a boolean indicating if facetData is enabled
  23947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23948. */
  23949. readonly isFacetDataEnabled: boolean;
  23950. /** @hidden */
  23951. _updateNonUniformScalingState(value: boolean): boolean;
  23952. /**
  23953. * An event triggered when this mesh collides with another one
  23954. */
  23955. onCollideObservable: Observable<AbstractMesh>;
  23956. private _onCollideObserver;
  23957. /** Set a function to call when this mesh collides with another one */
  23958. onCollide: () => void;
  23959. /**
  23960. * An event triggered when the collision's position changes
  23961. */
  23962. onCollisionPositionChangeObservable: Observable<Vector3>;
  23963. private _onCollisionPositionChangeObserver;
  23964. /** Set a function to call when the collision's position changes */
  23965. onCollisionPositionChange: () => void;
  23966. /**
  23967. * An event triggered when material is changed
  23968. */
  23969. onMaterialChangedObservable: Observable<AbstractMesh>;
  23970. /**
  23971. * Gets or sets the orientation for POV movement & rotation
  23972. */
  23973. definedFacingForward: boolean;
  23974. /** @hidden */
  23975. _occlusionQuery: Nullable<WebGLQuery>;
  23976. private _visibility;
  23977. /**
  23978. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23979. */
  23980. /**
  23981. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23982. */
  23983. visibility: number;
  23984. /** Gets or sets the alpha index used to sort transparent meshes
  23985. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23986. */
  23987. alphaIndex: number;
  23988. /**
  23989. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23990. */
  23991. isVisible: boolean;
  23992. /**
  23993. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23994. */
  23995. isPickable: boolean;
  23996. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23997. showSubMeshesBoundingBox: boolean;
  23998. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23999. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24000. */
  24001. isBlocker: boolean;
  24002. /**
  24003. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24004. */
  24005. enablePointerMoveEvents: boolean;
  24006. /**
  24007. * Specifies the rendering group id for this mesh (0 by default)
  24008. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24009. */
  24010. renderingGroupId: number;
  24011. private _material;
  24012. /** Gets or sets current material */
  24013. material: Nullable<Material>;
  24014. private _receiveShadows;
  24015. /**
  24016. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24017. * @see http://doc.babylonjs.com/babylon101/shadows
  24018. */
  24019. receiveShadows: boolean;
  24020. /** Defines color to use when rendering outline */
  24021. outlineColor: Color3;
  24022. /** Define width to use when rendering outline */
  24023. outlineWidth: number;
  24024. /** Defines color to use when rendering overlay */
  24025. overlayColor: Color3;
  24026. /** Defines alpha to use when rendering overlay */
  24027. overlayAlpha: number;
  24028. private _hasVertexAlpha;
  24029. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24030. hasVertexAlpha: boolean;
  24031. private _useVertexColors;
  24032. /** 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) */
  24033. useVertexColors: boolean;
  24034. private _computeBonesUsingShaders;
  24035. /**
  24036. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24037. */
  24038. computeBonesUsingShaders: boolean;
  24039. private _numBoneInfluencers;
  24040. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24041. numBoneInfluencers: number;
  24042. private _applyFog;
  24043. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24044. applyFog: boolean;
  24045. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24046. useOctreeForRenderingSelection: boolean;
  24047. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24048. useOctreeForPicking: boolean;
  24049. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24050. useOctreeForCollisions: boolean;
  24051. private _layerMask;
  24052. /**
  24053. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24054. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24055. */
  24056. layerMask: number;
  24057. /**
  24058. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24059. */
  24060. alwaysSelectAsActiveMesh: boolean;
  24061. /**
  24062. * Gets or sets the current action manager
  24063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24064. */
  24065. actionManager: Nullable<AbstractActionManager>;
  24066. private _checkCollisions;
  24067. private _collisionMask;
  24068. private _collisionGroup;
  24069. /**
  24070. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24071. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24072. */
  24073. ellipsoid: Vector3;
  24074. /**
  24075. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24076. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24077. */
  24078. ellipsoidOffset: Vector3;
  24079. private _collider;
  24080. private _oldPositionForCollisions;
  24081. private _diffPositionForCollisions;
  24082. /**
  24083. * Gets or sets a collision mask used to mask collisions (default is -1).
  24084. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24085. */
  24086. collisionMask: number;
  24087. /**
  24088. * Gets or sets the current collision group mask (-1 by default).
  24089. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24090. */
  24091. collisionGroup: number;
  24092. /**
  24093. * Defines edge width used when edgesRenderer is enabled
  24094. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24095. */
  24096. edgesWidth: number;
  24097. /**
  24098. * Defines edge color used when edgesRenderer is enabled
  24099. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24100. */
  24101. edgesColor: Color4;
  24102. /** @hidden */
  24103. _edgesRenderer: Nullable<IEdgesRenderer>;
  24104. /** @hidden */
  24105. _masterMesh: Nullable<AbstractMesh>;
  24106. /** @hidden */
  24107. _boundingInfo: Nullable<BoundingInfo>;
  24108. /** @hidden */
  24109. _renderId: number;
  24110. /**
  24111. * Gets or sets the list of subMeshes
  24112. * @see http://doc.babylonjs.com/how_to/multi_materials
  24113. */
  24114. subMeshes: SubMesh[];
  24115. /** @hidden */
  24116. _intersectionsInProgress: AbstractMesh[];
  24117. /** @hidden */
  24118. _unIndexed: boolean;
  24119. /** @hidden */
  24120. _lightSources: Light[];
  24121. /** @hidden */
  24122. readonly _positions: Nullable<Vector3[]>;
  24123. /** @hidden */
  24124. _waitingActions: any;
  24125. /** @hidden */
  24126. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24127. private _skeleton;
  24128. /** @hidden */
  24129. _bonesTransformMatrices: Nullable<Float32Array>;
  24130. /**
  24131. * Gets or sets a skeleton to apply skining transformations
  24132. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24133. */
  24134. skeleton: Nullable<Skeleton>;
  24135. /**
  24136. * An event triggered when the mesh is rebuilt.
  24137. */
  24138. onRebuildObservable: Observable<AbstractMesh>;
  24139. /**
  24140. * Creates a new AbstractMesh
  24141. * @param name defines the name of the mesh
  24142. * @param scene defines the hosting scene
  24143. */
  24144. constructor(name: string, scene?: Nullable<Scene>);
  24145. /**
  24146. * Returns the string "AbstractMesh"
  24147. * @returns "AbstractMesh"
  24148. */
  24149. getClassName(): string;
  24150. /**
  24151. * Gets a string representation of the current mesh
  24152. * @param fullDetails defines a boolean indicating if full details must be included
  24153. * @returns a string representation of the current mesh
  24154. */
  24155. toString(fullDetails?: boolean): string;
  24156. /** @hidden */
  24157. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24158. /** @hidden */
  24159. _rebuild(): void;
  24160. /** @hidden */
  24161. _resyncLightSources(): void;
  24162. /** @hidden */
  24163. _resyncLighSource(light: Light): void;
  24164. /** @hidden */
  24165. _unBindEffect(): void;
  24166. /** @hidden */
  24167. _removeLightSource(light: Light): void;
  24168. private _markSubMeshesAsDirty;
  24169. /** @hidden */
  24170. _markSubMeshesAsLightDirty(): void;
  24171. /** @hidden */
  24172. _markSubMeshesAsAttributesDirty(): void;
  24173. /** @hidden */
  24174. _markSubMeshesAsMiscDirty(): void;
  24175. /**
  24176. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24177. */
  24178. scaling: Vector3;
  24179. /**
  24180. * Returns true if the mesh is blocked. Implemented by child classes
  24181. */
  24182. readonly isBlocked: boolean;
  24183. /**
  24184. * Returns the mesh itself by default. Implemented by child classes
  24185. * @param camera defines the camera to use to pick the right LOD level
  24186. * @returns the currentAbstractMesh
  24187. */
  24188. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24189. /**
  24190. * Returns 0 by default. Implemented by child classes
  24191. * @returns an integer
  24192. */
  24193. getTotalVertices(): number;
  24194. /**
  24195. * Returns a positive integer : the total number of indices in this mesh geometry.
  24196. * @returns the numner of indices or zero if the mesh has no geometry.
  24197. */
  24198. getTotalIndices(): number;
  24199. /**
  24200. * Returns null by default. Implemented by child classes
  24201. * @returns null
  24202. */
  24203. getIndices(): Nullable<IndicesArray>;
  24204. /**
  24205. * Returns the array of the requested vertex data kind. Implemented by child classes
  24206. * @param kind defines the vertex data kind to use
  24207. * @returns null
  24208. */
  24209. getVerticesData(kind: string): Nullable<FloatArray>;
  24210. /**
  24211. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24212. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24213. * Note that a new underlying VertexBuffer object is created each call.
  24214. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24215. * @param kind defines vertex data kind:
  24216. * * VertexBuffer.PositionKind
  24217. * * VertexBuffer.UVKind
  24218. * * VertexBuffer.UV2Kind
  24219. * * VertexBuffer.UV3Kind
  24220. * * VertexBuffer.UV4Kind
  24221. * * VertexBuffer.UV5Kind
  24222. * * VertexBuffer.UV6Kind
  24223. * * VertexBuffer.ColorKind
  24224. * * VertexBuffer.MatricesIndicesKind
  24225. * * VertexBuffer.MatricesIndicesExtraKind
  24226. * * VertexBuffer.MatricesWeightsKind
  24227. * * VertexBuffer.MatricesWeightsExtraKind
  24228. * @param data defines the data source
  24229. * @param updatable defines if the data must be flagged as updatable (or static)
  24230. * @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
  24231. * @returns the current mesh
  24232. */
  24233. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24234. /**
  24235. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24236. * If the mesh has no geometry, it is simply returned as it is.
  24237. * @param kind defines vertex data kind:
  24238. * * VertexBuffer.PositionKind
  24239. * * VertexBuffer.UVKind
  24240. * * VertexBuffer.UV2Kind
  24241. * * VertexBuffer.UV3Kind
  24242. * * VertexBuffer.UV4Kind
  24243. * * VertexBuffer.UV5Kind
  24244. * * VertexBuffer.UV6Kind
  24245. * * VertexBuffer.ColorKind
  24246. * * VertexBuffer.MatricesIndicesKind
  24247. * * VertexBuffer.MatricesIndicesExtraKind
  24248. * * VertexBuffer.MatricesWeightsKind
  24249. * * VertexBuffer.MatricesWeightsExtraKind
  24250. * @param data defines the data source
  24251. * @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
  24252. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24253. * @returns the current mesh
  24254. */
  24255. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24256. /**
  24257. * Sets the mesh indices,
  24258. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24259. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24260. * @param totalVertices Defines the total number of vertices
  24261. * @returns the current mesh
  24262. */
  24263. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24264. /**
  24265. * Gets a boolean indicating if specific vertex data is present
  24266. * @param kind defines the vertex data kind to use
  24267. * @returns true is data kind is present
  24268. */
  24269. isVerticesDataPresent(kind: string): boolean;
  24270. /**
  24271. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24272. * @returns a BoundingInfo
  24273. */
  24274. getBoundingInfo(): BoundingInfo;
  24275. /**
  24276. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24277. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24278. * @returns the current mesh
  24279. */
  24280. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24281. /**
  24282. * Overwrite the current bounding info
  24283. * @param boundingInfo defines the new bounding info
  24284. * @returns the current mesh
  24285. */
  24286. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24287. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24288. readonly useBones: boolean;
  24289. /** @hidden */
  24290. _preActivate(): void;
  24291. /** @hidden */
  24292. _preActivateForIntermediateRendering(renderId: number): void;
  24293. /** @hidden */
  24294. _activate(renderId: number): void;
  24295. /**
  24296. * Gets the current world matrix
  24297. * @returns a Matrix
  24298. */
  24299. getWorldMatrix(): Matrix;
  24300. /** @hidden */
  24301. _getWorldMatrixDeterminant(): number;
  24302. /**
  24303. * Perform relative position change from the point of view of behind the front of the mesh.
  24304. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24305. * Supports definition of mesh facing forward or backward
  24306. * @param amountRight defines the distance on the right axis
  24307. * @param amountUp defines the distance on the up axis
  24308. * @param amountForward defines the distance on the forward axis
  24309. * @returns the current mesh
  24310. */
  24311. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24312. /**
  24313. * Calculate relative position change from the point of view of behind the front of the mesh.
  24314. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24315. * Supports definition of mesh facing forward or backward
  24316. * @param amountRight defines the distance on the right axis
  24317. * @param amountUp defines the distance on the up axis
  24318. * @param amountForward defines the distance on the forward axis
  24319. * @returns the new displacement vector
  24320. */
  24321. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24322. /**
  24323. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24324. * Supports definition of mesh facing forward or backward
  24325. * @param flipBack defines the flip
  24326. * @param twirlClockwise defines the twirl
  24327. * @param tiltRight defines the tilt
  24328. * @returns the current mesh
  24329. */
  24330. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24331. /**
  24332. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24333. * Supports definition of mesh facing forward or backward.
  24334. * @param flipBack defines the flip
  24335. * @param twirlClockwise defines the twirl
  24336. * @param tiltRight defines the tilt
  24337. * @returns the new rotation vector
  24338. */
  24339. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24340. /**
  24341. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24342. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24343. * @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
  24344. * @returns the new bounding vectors
  24345. */
  24346. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24347. min: Vector3;
  24348. max: Vector3;
  24349. };
  24350. /**
  24351. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24352. * This means the mesh underlying bounding box and sphere are recomputed.
  24353. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24354. * @returns the current mesh
  24355. */
  24356. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24357. /** @hidden */
  24358. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24359. /** @hidden */
  24360. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24361. /** @hidden */
  24362. _updateBoundingInfo(): AbstractMesh;
  24363. /** @hidden */
  24364. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24365. /** @hidden */
  24366. protected _afterComputeWorldMatrix(): void;
  24367. /**
  24368. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24369. * A mesh is in the frustum if its bounding box intersects the frustum
  24370. * @param frustumPlanes defines the frustum to test
  24371. * @returns true if the mesh is in the frustum planes
  24372. */
  24373. isInFrustum(frustumPlanes: Plane[]): boolean;
  24374. /**
  24375. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24376. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24377. * @param frustumPlanes defines the frustum to test
  24378. * @returns true if the mesh is completely in the frustum planes
  24379. */
  24380. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24381. /**
  24382. * True if the mesh intersects another mesh or a SolidParticle object
  24383. * @param mesh defines a target mesh or SolidParticle to test
  24384. * @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)
  24385. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24386. * @returns true if there is an intersection
  24387. */
  24388. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24389. /**
  24390. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24391. * @param point defines the point to test
  24392. * @returns true if there is an intersection
  24393. */
  24394. intersectsPoint(point: Vector3): boolean;
  24395. /**
  24396. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24397. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24398. */
  24399. checkCollisions: boolean;
  24400. /**
  24401. * Gets Collider object used to compute collisions (not physics)
  24402. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24403. */
  24404. readonly collider: Collider;
  24405. /**
  24406. * Move the mesh using collision engine
  24407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24408. * @param displacement defines the requested displacement vector
  24409. * @returns the current mesh
  24410. */
  24411. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24412. private _onCollisionPositionChange;
  24413. /** @hidden */
  24414. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24415. /** @hidden */
  24416. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24417. /** @hidden */
  24418. _checkCollision(collider: Collider): AbstractMesh;
  24419. /** @hidden */
  24420. _generatePointsArray(): boolean;
  24421. /**
  24422. * Checks if the passed Ray intersects with the mesh
  24423. * @param ray defines the ray to use
  24424. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24425. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24426. * @returns the picking info
  24427. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24428. */
  24429. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24430. /**
  24431. * Clones the current mesh
  24432. * @param name defines the mesh name
  24433. * @param newParent defines the new mesh parent
  24434. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24435. * @returns the new mesh
  24436. */
  24437. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24438. /**
  24439. * Disposes all the submeshes of the current meshnp
  24440. * @returns the current mesh
  24441. */
  24442. releaseSubMeshes(): AbstractMesh;
  24443. /**
  24444. * Releases resources associated with this abstract mesh.
  24445. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24446. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24447. */
  24448. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24449. /**
  24450. * Adds the passed mesh as a child to the current mesh
  24451. * @param mesh defines the child mesh
  24452. * @returns the current mesh
  24453. */
  24454. addChild(mesh: AbstractMesh): AbstractMesh;
  24455. /**
  24456. * Removes the passed mesh from the current mesh children list
  24457. * @param mesh defines the child mesh
  24458. * @returns the current mesh
  24459. */
  24460. removeChild(mesh: AbstractMesh): AbstractMesh;
  24461. /** @hidden */
  24462. private _initFacetData;
  24463. /**
  24464. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24465. * This method can be called within the render loop.
  24466. * 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
  24467. * @returns the current mesh
  24468. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24469. */
  24470. updateFacetData(): AbstractMesh;
  24471. /**
  24472. * Returns the facetLocalNormals array.
  24473. * The normals are expressed in the mesh local spac
  24474. * @returns an array of Vector3
  24475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24476. */
  24477. getFacetLocalNormals(): Vector3[];
  24478. /**
  24479. * Returns the facetLocalPositions array.
  24480. * The facet positions are expressed in the mesh local space
  24481. * @returns an array of Vector3
  24482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24483. */
  24484. getFacetLocalPositions(): Vector3[];
  24485. /**
  24486. * Returns the facetLocalPartioning array
  24487. * @returns an array of array of numbers
  24488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24489. */
  24490. getFacetLocalPartitioning(): number[][];
  24491. /**
  24492. * Returns the i-th facet position in the world system.
  24493. * This method allocates a new Vector3 per call
  24494. * @param i defines the facet index
  24495. * @returns a new Vector3
  24496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24497. */
  24498. getFacetPosition(i: number): Vector3;
  24499. /**
  24500. * Sets the reference Vector3 with the i-th facet position in the world system
  24501. * @param i defines the facet index
  24502. * @param ref defines the target vector
  24503. * @returns the current mesh
  24504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24505. */
  24506. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24507. /**
  24508. * Returns the i-th facet normal in the world system.
  24509. * This method allocates a new Vector3 per call
  24510. * @param i defines the facet index
  24511. * @returns a new Vector3
  24512. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24513. */
  24514. getFacetNormal(i: number): Vector3;
  24515. /**
  24516. * Sets the reference Vector3 with the i-th facet normal in the world system
  24517. * @param i defines the facet index
  24518. * @param ref defines the target vector
  24519. * @returns the current mesh
  24520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24521. */
  24522. getFacetNormalToRef(i: number, ref: Vector3): this;
  24523. /**
  24524. * 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)
  24525. * @param x defines x coordinate
  24526. * @param y defines y coordinate
  24527. * @param z defines z coordinate
  24528. * @returns the array of facet indexes
  24529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24530. */
  24531. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24532. /**
  24533. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24534. * @param projected sets as the (x,y,z) world projection on the facet
  24535. * @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
  24536. * @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
  24537. * @param x defines x coordinate
  24538. * @param y defines y coordinate
  24539. * @param z defines z coordinate
  24540. * @returns the face index if found (or null instead)
  24541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24542. */
  24543. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24544. /**
  24545. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24546. * @param projected sets as the (x,y,z) local projection on the facet
  24547. * @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
  24548. * @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
  24549. * @param x defines x coordinate
  24550. * @param y defines y coordinate
  24551. * @param z defines z coordinate
  24552. * @returns the face index if found (or null instead)
  24553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24554. */
  24555. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24556. /**
  24557. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24558. * @returns the parameters
  24559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24560. */
  24561. getFacetDataParameters(): any;
  24562. /**
  24563. * Disables the feature FacetData and frees the related memory
  24564. * @returns the current mesh
  24565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24566. */
  24567. disableFacetData(): AbstractMesh;
  24568. /**
  24569. * Updates the AbstractMesh indices array
  24570. * @param indices defines the data source
  24571. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24572. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24573. * @returns the current mesh
  24574. */
  24575. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24576. /**
  24577. * Creates new normals data for the mesh
  24578. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24579. * @returns the current mesh
  24580. */
  24581. createNormals(updatable: boolean): AbstractMesh;
  24582. /**
  24583. * Align the mesh with a normal
  24584. * @param normal defines the normal to use
  24585. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24586. * @returns the current mesh
  24587. */
  24588. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24589. /** @hidden */
  24590. _checkOcclusionQuery(): boolean;
  24591. }
  24592. }
  24593. declare module "babylonjs/Actions/actionEvent" {
  24594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24595. import { Nullable } from "babylonjs/types";
  24596. import { Sprite } from "babylonjs/Sprites/sprite";
  24597. import { Scene } from "babylonjs/scene";
  24598. import { Vector2 } from "babylonjs/Maths/math";
  24599. /**
  24600. * Interface used to define ActionEvent
  24601. */
  24602. export interface IActionEvent {
  24603. /** The mesh or sprite that triggered the action */
  24604. source: any;
  24605. /** The X mouse cursor position at the time of the event */
  24606. pointerX: number;
  24607. /** The Y mouse cursor position at the time of the event */
  24608. pointerY: number;
  24609. /** The mesh that is currently pointed at (can be null) */
  24610. meshUnderPointer: Nullable<AbstractMesh>;
  24611. /** the original (browser) event that triggered the ActionEvent */
  24612. sourceEvent?: any;
  24613. /** additional data for the event */
  24614. additionalData?: any;
  24615. }
  24616. /**
  24617. * ActionEvent is the event being sent when an action is triggered.
  24618. */
  24619. export class ActionEvent implements IActionEvent {
  24620. /** The mesh or sprite that triggered the action */
  24621. source: any;
  24622. /** The X mouse cursor position at the time of the event */
  24623. pointerX: number;
  24624. /** The Y mouse cursor position at the time of the event */
  24625. pointerY: number;
  24626. /** The mesh that is currently pointed at (can be null) */
  24627. meshUnderPointer: Nullable<AbstractMesh>;
  24628. /** the original (browser) event that triggered the ActionEvent */
  24629. sourceEvent?: any;
  24630. /** additional data for the event */
  24631. additionalData?: any;
  24632. /**
  24633. * Creates a new ActionEvent
  24634. * @param source The mesh or sprite that triggered the action
  24635. * @param pointerX The X mouse cursor position at the time of the event
  24636. * @param pointerY The Y mouse cursor position at the time of the event
  24637. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24638. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24639. * @param additionalData additional data for the event
  24640. */
  24641. constructor(
  24642. /** The mesh or sprite that triggered the action */
  24643. source: any,
  24644. /** The X mouse cursor position at the time of the event */
  24645. pointerX: number,
  24646. /** The Y mouse cursor position at the time of the event */
  24647. pointerY: number,
  24648. /** The mesh that is currently pointed at (can be null) */
  24649. meshUnderPointer: Nullable<AbstractMesh>,
  24650. /** the original (browser) event that triggered the ActionEvent */
  24651. sourceEvent?: any,
  24652. /** additional data for the event */
  24653. additionalData?: any);
  24654. /**
  24655. * Helper function to auto-create an ActionEvent from a source mesh.
  24656. * @param source The source mesh that triggered the event
  24657. * @param evt The original (browser) event
  24658. * @param additionalData additional data for the event
  24659. * @returns the new ActionEvent
  24660. */
  24661. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24662. /**
  24663. * Helper function to auto-create an ActionEvent from a source sprite
  24664. * @param source The source sprite that triggered the event
  24665. * @param scene Scene associated with the sprite
  24666. * @param evt The original (browser) event
  24667. * @param additionalData additional data for the event
  24668. * @returns the new ActionEvent
  24669. */
  24670. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24671. /**
  24672. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24673. * @param scene the scene where the event occurred
  24674. * @param evt The original (browser) event
  24675. * @returns the new ActionEvent
  24676. */
  24677. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24678. /**
  24679. * Helper function to auto-create an ActionEvent from a primitive
  24680. * @param prim defines the target primitive
  24681. * @param pointerPos defines the pointer position
  24682. * @param evt The original (browser) event
  24683. * @param additionalData additional data for the event
  24684. * @returns the new ActionEvent
  24685. */
  24686. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24687. }
  24688. }
  24689. declare module "babylonjs/Actions/abstractActionManager" {
  24690. import { IDisposable } from "babylonjs/scene";
  24691. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24692. import { IAction } from "babylonjs/Actions/action";
  24693. import { Nullable } from "babylonjs/types";
  24694. /**
  24695. * Abstract class used to decouple action Manager from scene and meshes.
  24696. * Do not instantiate.
  24697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24698. */
  24699. export abstract class AbstractActionManager implements IDisposable {
  24700. /** Gets the list of active triggers */
  24701. static Triggers: {
  24702. [key: string]: number;
  24703. };
  24704. /** Gets the cursor to use when hovering items */
  24705. hoverCursor: string;
  24706. /** Gets the list of actions */
  24707. actions: IAction[];
  24708. /**
  24709. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24710. */
  24711. isRecursive: boolean;
  24712. /**
  24713. * Releases all associated resources
  24714. */
  24715. abstract dispose(): void;
  24716. /**
  24717. * Does this action manager has pointer triggers
  24718. */
  24719. abstract readonly hasPointerTriggers: boolean;
  24720. /**
  24721. * Does this action manager has pick triggers
  24722. */
  24723. abstract readonly hasPickTriggers: boolean;
  24724. /**
  24725. * Process a specific trigger
  24726. * @param trigger defines the trigger to process
  24727. * @param evt defines the event details to be processed
  24728. */
  24729. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24730. /**
  24731. * Does this action manager handles actions of any of the given triggers
  24732. * @param triggers defines the triggers to be tested
  24733. * @return a boolean indicating whether one (or more) of the triggers is handled
  24734. */
  24735. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24736. /**
  24737. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24738. * speed.
  24739. * @param triggerA defines the trigger to be tested
  24740. * @param triggerB defines the trigger to be tested
  24741. * @return a boolean indicating whether one (or more) of the triggers is handled
  24742. */
  24743. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24744. /**
  24745. * Does this action manager handles actions of a given trigger
  24746. * @param trigger defines the trigger to be tested
  24747. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24748. * @return whether the trigger is handled
  24749. */
  24750. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24751. /**
  24752. * Serialize this manager to a JSON object
  24753. * @param name defines the property name to store this manager
  24754. * @returns a JSON representation of this manager
  24755. */
  24756. abstract serialize(name: string): any;
  24757. /**
  24758. * Registers an action to this action manager
  24759. * @param action defines the action to be registered
  24760. * @return the action amended (prepared) after registration
  24761. */
  24762. abstract registerAction(action: IAction): Nullable<IAction>;
  24763. /**
  24764. * Unregisters an action to this action manager
  24765. * @param action defines the action to be unregistered
  24766. * @return a boolean indicating whether the action has been unregistered
  24767. */
  24768. abstract unregisterAction(action: IAction): Boolean;
  24769. /**
  24770. * Does exist one action manager with at least one trigger
  24771. **/
  24772. static readonly HasTriggers: boolean;
  24773. /**
  24774. * Does exist one action manager with at least one pick trigger
  24775. **/
  24776. static readonly HasPickTriggers: boolean;
  24777. /**
  24778. * Does exist one action manager that handles actions of a given trigger
  24779. * @param trigger defines the trigger to be tested
  24780. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24781. **/
  24782. static HasSpecificTrigger(trigger: number): boolean;
  24783. }
  24784. }
  24785. declare module "babylonjs/node" {
  24786. import { Scene } from "babylonjs/scene";
  24787. import { Nullable } from "babylonjs/types";
  24788. import { Matrix } from "babylonjs/Maths/math";
  24789. import { Engine } from "babylonjs/Engines/engine";
  24790. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24791. import { Observable } from "babylonjs/Misc/observable";
  24792. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24793. import { Animatable } from "babylonjs/Animations/animatable";
  24794. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24795. import { Animation } from "babylonjs/Animations/animation";
  24796. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24798. /**
  24799. * Defines how a node can be built from a string name.
  24800. */
  24801. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24802. /**
  24803. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24804. */
  24805. export class Node implements IBehaviorAware<Node> {
  24806. /** @hidden */
  24807. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24808. private static _NodeConstructors;
  24809. /**
  24810. * Add a new node constructor
  24811. * @param type defines the type name of the node to construct
  24812. * @param constructorFunc defines the constructor function
  24813. */
  24814. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24815. /**
  24816. * Returns a node constructor based on type name
  24817. * @param type defines the type name
  24818. * @param name defines the new node name
  24819. * @param scene defines the hosting scene
  24820. * @param options defines optional options to transmit to constructors
  24821. * @returns the new constructor or null
  24822. */
  24823. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24824. /**
  24825. * Gets or sets the name of the node
  24826. */
  24827. name: string;
  24828. /**
  24829. * Gets or sets the id of the node
  24830. */
  24831. id: string;
  24832. /**
  24833. * Gets or sets the unique id of the node
  24834. */
  24835. uniqueId: number;
  24836. /**
  24837. * Gets or sets a string used to store user defined state for the node
  24838. */
  24839. state: string;
  24840. /**
  24841. * Gets or sets an object used to store user defined information for the node
  24842. */
  24843. metadata: any;
  24844. /**
  24845. * For internal use only. Please do not use.
  24846. */
  24847. reservedDataStore: any;
  24848. /**
  24849. * Gets or sets a boolean used to define if the node must be serialized
  24850. */
  24851. doNotSerialize: boolean;
  24852. /** @hidden */
  24853. _isDisposed: boolean;
  24854. /**
  24855. * Gets a list of Animations associated with the node
  24856. */
  24857. animations: import("babylonjs/Animations/animation").Animation[];
  24858. protected _ranges: {
  24859. [name: string]: Nullable<AnimationRange>;
  24860. };
  24861. /**
  24862. * Callback raised when the node is ready to be used
  24863. */
  24864. onReady: (node: Node) => void;
  24865. private _isEnabled;
  24866. private _isParentEnabled;
  24867. private _isReady;
  24868. /** @hidden */
  24869. _currentRenderId: number;
  24870. private _parentRenderId;
  24871. protected _childRenderId: number;
  24872. /** @hidden */
  24873. _waitingParentId: Nullable<string>;
  24874. /** @hidden */
  24875. _scene: Scene;
  24876. /** @hidden */
  24877. _cache: any;
  24878. private _parentNode;
  24879. private _children;
  24880. /** @hidden */
  24881. _worldMatrix: Matrix;
  24882. /** @hidden */
  24883. _worldMatrixDeterminant: number;
  24884. /** @hidden */
  24885. private _sceneRootNodesIndex;
  24886. /**
  24887. * Gets a boolean indicating if the node has been disposed
  24888. * @returns true if the node was disposed
  24889. */
  24890. isDisposed(): boolean;
  24891. /**
  24892. * Gets or sets the parent of the node
  24893. */
  24894. parent: Nullable<Node>;
  24895. private addToSceneRootNodes;
  24896. private removeFromSceneRootNodes;
  24897. private _animationPropertiesOverride;
  24898. /**
  24899. * Gets or sets the animation properties override
  24900. */
  24901. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24902. /**
  24903. * Gets a string idenfifying the name of the class
  24904. * @returns "Node" string
  24905. */
  24906. getClassName(): string;
  24907. /** @hidden */
  24908. readonly _isNode: boolean;
  24909. /**
  24910. * An event triggered when the mesh is disposed
  24911. */
  24912. onDisposeObservable: Observable<Node>;
  24913. private _onDisposeObserver;
  24914. /**
  24915. * Sets a callback that will be raised when the node will be disposed
  24916. */
  24917. onDispose: () => void;
  24918. /**
  24919. * Creates a new Node
  24920. * @param name the name and id to be given to this node
  24921. * @param scene the scene this node will be added to
  24922. * @param addToRootNodes the node will be added to scene.rootNodes
  24923. */
  24924. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24925. /**
  24926. * Gets the scene of the node
  24927. * @returns a scene
  24928. */
  24929. getScene(): Scene;
  24930. /**
  24931. * Gets the engine of the node
  24932. * @returns a Engine
  24933. */
  24934. getEngine(): Engine;
  24935. private _behaviors;
  24936. /**
  24937. * Attach a behavior to the node
  24938. * @see http://doc.babylonjs.com/features/behaviour
  24939. * @param behavior defines the behavior to attach
  24940. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24941. * @returns the current Node
  24942. */
  24943. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24944. /**
  24945. * Remove an attached behavior
  24946. * @see http://doc.babylonjs.com/features/behaviour
  24947. * @param behavior defines the behavior to attach
  24948. * @returns the current Node
  24949. */
  24950. removeBehavior(behavior: Behavior<Node>): Node;
  24951. /**
  24952. * Gets the list of attached behaviors
  24953. * @see http://doc.babylonjs.com/features/behaviour
  24954. */
  24955. readonly behaviors: Behavior<Node>[];
  24956. /**
  24957. * Gets an attached behavior by name
  24958. * @param name defines the name of the behavior to look for
  24959. * @see http://doc.babylonjs.com/features/behaviour
  24960. * @returns null if behavior was not found else the requested behavior
  24961. */
  24962. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24963. /**
  24964. * Returns the latest update of the World matrix
  24965. * @returns a Matrix
  24966. */
  24967. getWorldMatrix(): Matrix;
  24968. /** @hidden */
  24969. _getWorldMatrixDeterminant(): number;
  24970. /**
  24971. * Returns directly the latest state of the mesh World matrix.
  24972. * A Matrix is returned.
  24973. */
  24974. readonly worldMatrixFromCache: Matrix;
  24975. /** @hidden */
  24976. _initCache(): void;
  24977. /** @hidden */
  24978. updateCache(force?: boolean): void;
  24979. /** @hidden */
  24980. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24981. /** @hidden */
  24982. _updateCache(ignoreParentClass?: boolean): void;
  24983. /** @hidden */
  24984. _isSynchronized(): boolean;
  24985. /** @hidden */
  24986. _markSyncedWithParent(): void;
  24987. /** @hidden */
  24988. isSynchronizedWithParent(): boolean;
  24989. /** @hidden */
  24990. isSynchronized(): boolean;
  24991. /**
  24992. * Is this node ready to be used/rendered
  24993. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24994. * @return true if the node is ready
  24995. */
  24996. isReady(completeCheck?: boolean): boolean;
  24997. /**
  24998. * Is this node enabled?
  24999. * 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
  25000. * @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
  25001. * @return whether this node (and its parent) is enabled
  25002. */
  25003. isEnabled(checkAncestors?: boolean): boolean;
  25004. /** @hidden */
  25005. protected _syncParentEnabledState(): void;
  25006. /**
  25007. * Set the enabled state of this node
  25008. * @param value defines the new enabled state
  25009. */
  25010. setEnabled(value: boolean): void;
  25011. /**
  25012. * Is this node a descendant of the given node?
  25013. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25014. * @param ancestor defines the parent node to inspect
  25015. * @returns a boolean indicating if this node is a descendant of the given node
  25016. */
  25017. isDescendantOf(ancestor: Node): boolean;
  25018. /** @hidden */
  25019. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25020. /**
  25021. * Will return all nodes that have this node as ascendant
  25022. * @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
  25023. * @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
  25024. * @return all children nodes of all types
  25025. */
  25026. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25027. /**
  25028. * Get all child-meshes of this node
  25029. * @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)
  25030. * @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
  25031. * @returns an array of AbstractMesh
  25032. */
  25033. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25034. /**
  25035. * Get all direct children of this node
  25036. * @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
  25037. * @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)
  25038. * @returns an array of Node
  25039. */
  25040. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25041. /** @hidden */
  25042. _setReady(state: boolean): void;
  25043. /**
  25044. * Get an animation by name
  25045. * @param name defines the name of the animation to look for
  25046. * @returns null if not found else the requested animation
  25047. */
  25048. getAnimationByName(name: string): Nullable<Animation>;
  25049. /**
  25050. * Creates an animation range for this node
  25051. * @param name defines the name of the range
  25052. * @param from defines the starting key
  25053. * @param to defines the end key
  25054. */
  25055. createAnimationRange(name: string, from: number, to: number): void;
  25056. /**
  25057. * Delete a specific animation range
  25058. * @param name defines the name of the range to delete
  25059. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25060. */
  25061. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25062. /**
  25063. * Get an animation range by name
  25064. * @param name defines the name of the animation range to look for
  25065. * @returns null if not found else the requested animation range
  25066. */
  25067. getAnimationRange(name: string): Nullable<AnimationRange>;
  25068. /**
  25069. * Gets the list of all animation ranges defined on this node
  25070. * @returns an array
  25071. */
  25072. getAnimationRanges(): Nullable<AnimationRange>[];
  25073. /**
  25074. * Will start the animation sequence
  25075. * @param name defines the range frames for animation sequence
  25076. * @param loop defines if the animation should loop (false by default)
  25077. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25078. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25079. * @returns the object created for this animation. If range does not exist, it will return null
  25080. */
  25081. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25082. /**
  25083. * Serialize animation ranges into a JSON compatible object
  25084. * @returns serialization object
  25085. */
  25086. serializeAnimationRanges(): any;
  25087. /**
  25088. * Computes the world matrix of the node
  25089. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25090. * @returns the world matrix
  25091. */
  25092. computeWorldMatrix(force?: boolean): Matrix;
  25093. /**
  25094. * Releases resources associated with this node.
  25095. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25096. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25097. */
  25098. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25099. /**
  25100. * Parse animation range data from a serialization object and store them into a given node
  25101. * @param node defines where to store the animation ranges
  25102. * @param parsedNode defines the serialization object to read data from
  25103. * @param scene defines the hosting scene
  25104. */
  25105. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25106. }
  25107. }
  25108. declare module "babylonjs/Animations/animation" {
  25109. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25110. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25111. import { Nullable } from "babylonjs/types";
  25112. import { Scene } from "babylonjs/scene";
  25113. import { IAnimatable } from "babylonjs/Misc/tools";
  25114. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25115. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25116. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25117. import { Node } from "babylonjs/node";
  25118. import { Animatable } from "babylonjs/Animations/animatable";
  25119. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25120. /**
  25121. * Class used to store any kind of animation
  25122. */
  25123. export class Animation {
  25124. /**Name of the animation */
  25125. name: string;
  25126. /**Property to animate */
  25127. targetProperty: string;
  25128. /**The frames per second of the animation */
  25129. framePerSecond: number;
  25130. /**The data type of the animation */
  25131. dataType: number;
  25132. /**The loop mode of the animation */
  25133. loopMode?: number | undefined;
  25134. /**Specifies if blending should be enabled */
  25135. enableBlending?: boolean | undefined;
  25136. /**
  25137. * Use matrix interpolation instead of using direct key value when animating matrices
  25138. */
  25139. static AllowMatricesInterpolation: boolean;
  25140. /**
  25141. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25142. */
  25143. static AllowMatrixDecomposeForInterpolation: boolean;
  25144. /**
  25145. * Stores the key frames of the animation
  25146. */
  25147. private _keys;
  25148. /**
  25149. * Stores the easing function of the animation
  25150. */
  25151. private _easingFunction;
  25152. /**
  25153. * @hidden Internal use only
  25154. */
  25155. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25156. /**
  25157. * The set of event that will be linked to this animation
  25158. */
  25159. private _events;
  25160. /**
  25161. * Stores an array of target property paths
  25162. */
  25163. targetPropertyPath: string[];
  25164. /**
  25165. * Stores the blending speed of the animation
  25166. */
  25167. blendingSpeed: number;
  25168. /**
  25169. * Stores the animation ranges for the animation
  25170. */
  25171. private _ranges;
  25172. /**
  25173. * @hidden Internal use
  25174. */
  25175. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25176. /**
  25177. * Sets up an animation
  25178. * @param property The property to animate
  25179. * @param animationType The animation type to apply
  25180. * @param framePerSecond The frames per second of the animation
  25181. * @param easingFunction The easing function used in the animation
  25182. * @returns The created animation
  25183. */
  25184. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25185. /**
  25186. * Create and start an animation on a node
  25187. * @param name defines the name of the global animation that will be run on all nodes
  25188. * @param node defines the root node where the animation will take place
  25189. * @param targetProperty defines property to animate
  25190. * @param framePerSecond defines the number of frame per second yo use
  25191. * @param totalFrame defines the number of frames in total
  25192. * @param from defines the initial value
  25193. * @param to defines the final value
  25194. * @param loopMode defines which loop mode you want to use (off by default)
  25195. * @param easingFunction defines the easing function to use (linear by default)
  25196. * @param onAnimationEnd defines the callback to call when animation end
  25197. * @returns the animatable created for this animation
  25198. */
  25199. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25200. /**
  25201. * Create and start an animation on a node and its descendants
  25202. * @param name defines the name of the global animation that will be run on all nodes
  25203. * @param node defines the root node where the animation will take place
  25204. * @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
  25205. * @param targetProperty defines property to animate
  25206. * @param framePerSecond defines the number of frame per second to use
  25207. * @param totalFrame defines the number of frames in total
  25208. * @param from defines the initial value
  25209. * @param to defines the final value
  25210. * @param loopMode defines which loop mode you want to use (off by default)
  25211. * @param easingFunction defines the easing function to use (linear by default)
  25212. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25213. * @returns the list of animatables created for all nodes
  25214. * @example https://www.babylonjs-playground.com/#MH0VLI
  25215. */
  25216. 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[]>;
  25217. /**
  25218. * Creates a new animation, merges it with the existing animations and starts it
  25219. * @param name Name of the animation
  25220. * @param node Node which contains the scene that begins the animations
  25221. * @param targetProperty Specifies which property to animate
  25222. * @param framePerSecond The frames per second of the animation
  25223. * @param totalFrame The total number of frames
  25224. * @param from The frame at the beginning of the animation
  25225. * @param to The frame at the end of the animation
  25226. * @param loopMode Specifies the loop mode of the animation
  25227. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25228. * @param onAnimationEnd Callback to run once the animation is complete
  25229. * @returns Nullable animation
  25230. */
  25231. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25232. /**
  25233. * Transition property of an host to the target Value
  25234. * @param property The property to transition
  25235. * @param targetValue The target Value of the property
  25236. * @param host The object where the property to animate belongs
  25237. * @param scene Scene used to run the animation
  25238. * @param frameRate Framerate (in frame/s) to use
  25239. * @param transition The transition type we want to use
  25240. * @param duration The duration of the animation, in milliseconds
  25241. * @param onAnimationEnd Callback trigger at the end of the animation
  25242. * @returns Nullable animation
  25243. */
  25244. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25245. /**
  25246. * Return the array of runtime animations currently using this animation
  25247. */
  25248. readonly runtimeAnimations: RuntimeAnimation[];
  25249. /**
  25250. * Specifies if any of the runtime animations are currently running
  25251. */
  25252. readonly hasRunningRuntimeAnimations: boolean;
  25253. /**
  25254. * Initializes the animation
  25255. * @param name Name of the animation
  25256. * @param targetProperty Property to animate
  25257. * @param framePerSecond The frames per second of the animation
  25258. * @param dataType The data type of the animation
  25259. * @param loopMode The loop mode of the animation
  25260. * @param enableBlending Specifies if blending should be enabled
  25261. */
  25262. constructor(
  25263. /**Name of the animation */
  25264. name: string,
  25265. /**Property to animate */
  25266. targetProperty: string,
  25267. /**The frames per second of the animation */
  25268. framePerSecond: number,
  25269. /**The data type of the animation */
  25270. dataType: number,
  25271. /**The loop mode of the animation */
  25272. loopMode?: number | undefined,
  25273. /**Specifies if blending should be enabled */
  25274. enableBlending?: boolean | undefined);
  25275. /**
  25276. * Converts the animation to a string
  25277. * @param fullDetails support for multiple levels of logging within scene loading
  25278. * @returns String form of the animation
  25279. */
  25280. toString(fullDetails?: boolean): string;
  25281. /**
  25282. * Add an event to this animation
  25283. * @param event Event to add
  25284. */
  25285. addEvent(event: AnimationEvent): void;
  25286. /**
  25287. * Remove all events found at the given frame
  25288. * @param frame The frame to remove events from
  25289. */
  25290. removeEvents(frame: number): void;
  25291. /**
  25292. * Retrieves all the events from the animation
  25293. * @returns Events from the animation
  25294. */
  25295. getEvents(): AnimationEvent[];
  25296. /**
  25297. * Creates an animation range
  25298. * @param name Name of the animation range
  25299. * @param from Starting frame of the animation range
  25300. * @param to Ending frame of the animation
  25301. */
  25302. createRange(name: string, from: number, to: number): void;
  25303. /**
  25304. * Deletes an animation range by name
  25305. * @param name Name of the animation range to delete
  25306. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25307. */
  25308. deleteRange(name: string, deleteFrames?: boolean): void;
  25309. /**
  25310. * Gets the animation range by name, or null if not defined
  25311. * @param name Name of the animation range
  25312. * @returns Nullable animation range
  25313. */
  25314. getRange(name: string): Nullable<AnimationRange>;
  25315. /**
  25316. * Gets the key frames from the animation
  25317. * @returns The key frames of the animation
  25318. */
  25319. getKeys(): Array<IAnimationKey>;
  25320. /**
  25321. * Gets the highest frame rate of the animation
  25322. * @returns Highest frame rate of the animation
  25323. */
  25324. getHighestFrame(): number;
  25325. /**
  25326. * Gets the easing function of the animation
  25327. * @returns Easing function of the animation
  25328. */
  25329. getEasingFunction(): IEasingFunction;
  25330. /**
  25331. * Sets the easing function of the animation
  25332. * @param easingFunction A custom mathematical formula for animation
  25333. */
  25334. setEasingFunction(easingFunction: EasingFunction): void;
  25335. /**
  25336. * Interpolates a scalar linearly
  25337. * @param startValue Start value of the animation curve
  25338. * @param endValue End value of the animation curve
  25339. * @param gradient Scalar amount to interpolate
  25340. * @returns Interpolated scalar value
  25341. */
  25342. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25343. /**
  25344. * Interpolates a scalar cubically
  25345. * @param startValue Start value of the animation curve
  25346. * @param outTangent End tangent of the animation
  25347. * @param endValue End value of the animation curve
  25348. * @param inTangent Start tangent of the animation curve
  25349. * @param gradient Scalar amount to interpolate
  25350. * @returns Interpolated scalar value
  25351. */
  25352. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25353. /**
  25354. * Interpolates a quaternion using a spherical linear interpolation
  25355. * @param startValue Start value of the animation curve
  25356. * @param endValue End value of the animation curve
  25357. * @param gradient Scalar amount to interpolate
  25358. * @returns Interpolated quaternion value
  25359. */
  25360. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25361. /**
  25362. * Interpolates a quaternion cubically
  25363. * @param startValue Start value of the animation curve
  25364. * @param outTangent End tangent of the animation curve
  25365. * @param endValue End value of the animation curve
  25366. * @param inTangent Start tangent of the animation curve
  25367. * @param gradient Scalar amount to interpolate
  25368. * @returns Interpolated quaternion value
  25369. */
  25370. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25371. /**
  25372. * Interpolates a Vector3 linearl
  25373. * @param startValue Start value of the animation curve
  25374. * @param endValue End value of the animation curve
  25375. * @param gradient Scalar amount to interpolate
  25376. * @returns Interpolated scalar value
  25377. */
  25378. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25379. /**
  25380. * Interpolates a Vector3 cubically
  25381. * @param startValue Start value of the animation curve
  25382. * @param outTangent End tangent of the animation
  25383. * @param endValue End value of the animation curve
  25384. * @param inTangent Start tangent of the animation curve
  25385. * @param gradient Scalar amount to interpolate
  25386. * @returns InterpolatedVector3 value
  25387. */
  25388. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25389. /**
  25390. * Interpolates a Vector2 linearly
  25391. * @param startValue Start value of the animation curve
  25392. * @param endValue End value of the animation curve
  25393. * @param gradient Scalar amount to interpolate
  25394. * @returns Interpolated Vector2 value
  25395. */
  25396. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25397. /**
  25398. * Interpolates a Vector2 cubically
  25399. * @param startValue Start value of the animation curve
  25400. * @param outTangent End tangent of the animation
  25401. * @param endValue End value of the animation curve
  25402. * @param inTangent Start tangent of the animation curve
  25403. * @param gradient Scalar amount to interpolate
  25404. * @returns Interpolated Vector2 value
  25405. */
  25406. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25407. /**
  25408. * Interpolates a size linearly
  25409. * @param startValue Start value of the animation curve
  25410. * @param endValue End value of the animation curve
  25411. * @param gradient Scalar amount to interpolate
  25412. * @returns Interpolated Size value
  25413. */
  25414. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25415. /**
  25416. * Interpolates a Color3 linearly
  25417. * @param startValue Start value of the animation curve
  25418. * @param endValue End value of the animation curve
  25419. * @param gradient Scalar amount to interpolate
  25420. * @returns Interpolated Color3 value
  25421. */
  25422. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25423. /**
  25424. * @hidden Internal use only
  25425. */
  25426. _getKeyValue(value: any): any;
  25427. /**
  25428. * @hidden Internal use only
  25429. */
  25430. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25431. /**
  25432. * Defines the function to use to interpolate matrices
  25433. * @param startValue defines the start matrix
  25434. * @param endValue defines the end matrix
  25435. * @param gradient defines the gradient between both matrices
  25436. * @param result defines an optional target matrix where to store the interpolation
  25437. * @returns the interpolated matrix
  25438. */
  25439. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25440. /**
  25441. * Makes a copy of the animation
  25442. * @returns Cloned animation
  25443. */
  25444. clone(): Animation;
  25445. /**
  25446. * Sets the key frames of the animation
  25447. * @param values The animation key frames to set
  25448. */
  25449. setKeys(values: Array<IAnimationKey>): void;
  25450. /**
  25451. * Serializes the animation to an object
  25452. * @returns Serialized object
  25453. */
  25454. serialize(): any;
  25455. /**
  25456. * Float animation type
  25457. */
  25458. private static _ANIMATIONTYPE_FLOAT;
  25459. /**
  25460. * Vector3 animation type
  25461. */
  25462. private static _ANIMATIONTYPE_VECTOR3;
  25463. /**
  25464. * Quaternion animation type
  25465. */
  25466. private static _ANIMATIONTYPE_QUATERNION;
  25467. /**
  25468. * Matrix animation type
  25469. */
  25470. private static _ANIMATIONTYPE_MATRIX;
  25471. /**
  25472. * Color3 animation type
  25473. */
  25474. private static _ANIMATIONTYPE_COLOR3;
  25475. /**
  25476. * Vector2 animation type
  25477. */
  25478. private static _ANIMATIONTYPE_VECTOR2;
  25479. /**
  25480. * Size animation type
  25481. */
  25482. private static _ANIMATIONTYPE_SIZE;
  25483. /**
  25484. * Relative Loop Mode
  25485. */
  25486. private static _ANIMATIONLOOPMODE_RELATIVE;
  25487. /**
  25488. * Cycle Loop Mode
  25489. */
  25490. private static _ANIMATIONLOOPMODE_CYCLE;
  25491. /**
  25492. * Constant Loop Mode
  25493. */
  25494. private static _ANIMATIONLOOPMODE_CONSTANT;
  25495. /**
  25496. * Get the float animation type
  25497. */
  25498. static readonly ANIMATIONTYPE_FLOAT: number;
  25499. /**
  25500. * Get the Vector3 animation type
  25501. */
  25502. static readonly ANIMATIONTYPE_VECTOR3: number;
  25503. /**
  25504. * Get the Vector2 animation type
  25505. */
  25506. static readonly ANIMATIONTYPE_VECTOR2: number;
  25507. /**
  25508. * Get the Size animation type
  25509. */
  25510. static readonly ANIMATIONTYPE_SIZE: number;
  25511. /**
  25512. * Get the Quaternion animation type
  25513. */
  25514. static readonly ANIMATIONTYPE_QUATERNION: number;
  25515. /**
  25516. * Get the Matrix animation type
  25517. */
  25518. static readonly ANIMATIONTYPE_MATRIX: number;
  25519. /**
  25520. * Get the Color3 animation type
  25521. */
  25522. static readonly ANIMATIONTYPE_COLOR3: number;
  25523. /**
  25524. * Get the Relative Loop Mode
  25525. */
  25526. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25527. /**
  25528. * Get the Cycle Loop Mode
  25529. */
  25530. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25531. /**
  25532. * Get the Constant Loop Mode
  25533. */
  25534. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25535. /** @hidden */
  25536. static _UniversalLerp(left: any, right: any, amount: number): any;
  25537. /**
  25538. * Parses an animation object and creates an animation
  25539. * @param parsedAnimation Parsed animation object
  25540. * @returns Animation object
  25541. */
  25542. static Parse(parsedAnimation: any): Animation;
  25543. /**
  25544. * Appends the serialized animations from the source animations
  25545. * @param source Source containing the animations
  25546. * @param destination Target to store the animations
  25547. */
  25548. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25549. }
  25550. }
  25551. declare module "babylonjs/Materials/Textures/baseTexture" {
  25552. import { Observable } from "babylonjs/Misc/observable";
  25553. import { IAnimatable } from "babylonjs/Misc/tools";
  25554. import { Nullable } from "babylonjs/types";
  25555. import { Scene } from "babylonjs/scene";
  25556. import { Matrix, ISize } from "babylonjs/Maths/math";
  25557. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25559. /**
  25560. * Base class of all the textures in babylon.
  25561. * It groups all the common properties the materials, post process, lights... might need
  25562. * in order to make a correct use of the texture.
  25563. */
  25564. export class BaseTexture implements IAnimatable {
  25565. /**
  25566. * Default anisotropic filtering level for the application.
  25567. * It is set to 4 as a good tradeoff between perf and quality.
  25568. */
  25569. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25570. /**
  25571. * Gets or sets the unique id of the texture
  25572. */
  25573. uniqueId: number;
  25574. /**
  25575. * Define the name of the texture.
  25576. */
  25577. name: string;
  25578. /**
  25579. * Gets or sets an object used to store user defined information.
  25580. */
  25581. metadata: any;
  25582. /**
  25583. * For internal use only. Please do not use.
  25584. */
  25585. reservedDataStore: any;
  25586. private _hasAlpha;
  25587. /**
  25588. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25589. */
  25590. hasAlpha: boolean;
  25591. /**
  25592. * Defines if the alpha value should be determined via the rgb values.
  25593. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25594. */
  25595. getAlphaFromRGB: boolean;
  25596. /**
  25597. * Intensity or strength of the texture.
  25598. * It is commonly used by materials to fine tune the intensity of the texture
  25599. */
  25600. level: number;
  25601. /**
  25602. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25603. * This is part of the texture as textures usually maps to one uv set.
  25604. */
  25605. coordinatesIndex: number;
  25606. private _coordinatesMode;
  25607. /**
  25608. * How a texture is mapped.
  25609. *
  25610. * | Value | Type | Description |
  25611. * | ----- | ----------------------------------- | ----------- |
  25612. * | 0 | EXPLICIT_MODE | |
  25613. * | 1 | SPHERICAL_MODE | |
  25614. * | 2 | PLANAR_MODE | |
  25615. * | 3 | CUBIC_MODE | |
  25616. * | 4 | PROJECTION_MODE | |
  25617. * | 5 | SKYBOX_MODE | |
  25618. * | 6 | INVCUBIC_MODE | |
  25619. * | 7 | EQUIRECTANGULAR_MODE | |
  25620. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25621. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25622. */
  25623. coordinatesMode: number;
  25624. /**
  25625. * | Value | Type | Description |
  25626. * | ----- | ------------------ | ----------- |
  25627. * | 0 | CLAMP_ADDRESSMODE | |
  25628. * | 1 | WRAP_ADDRESSMODE | |
  25629. * | 2 | MIRROR_ADDRESSMODE | |
  25630. */
  25631. wrapU: number;
  25632. /**
  25633. * | Value | Type | Description |
  25634. * | ----- | ------------------ | ----------- |
  25635. * | 0 | CLAMP_ADDRESSMODE | |
  25636. * | 1 | WRAP_ADDRESSMODE | |
  25637. * | 2 | MIRROR_ADDRESSMODE | |
  25638. */
  25639. wrapV: number;
  25640. /**
  25641. * | Value | Type | Description |
  25642. * | ----- | ------------------ | ----------- |
  25643. * | 0 | CLAMP_ADDRESSMODE | |
  25644. * | 1 | WRAP_ADDRESSMODE | |
  25645. * | 2 | MIRROR_ADDRESSMODE | |
  25646. */
  25647. wrapR: number;
  25648. /**
  25649. * With compliant hardware and browser (supporting anisotropic filtering)
  25650. * this defines the level of anisotropic filtering in the texture.
  25651. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25652. */
  25653. anisotropicFilteringLevel: number;
  25654. /**
  25655. * Define if the texture is a cube texture or if false a 2d texture.
  25656. */
  25657. isCube: boolean;
  25658. /**
  25659. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25660. */
  25661. is3D: boolean;
  25662. /**
  25663. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25664. * HDR texture are usually stored in linear space.
  25665. * This only impacts the PBR and Background materials
  25666. */
  25667. gammaSpace: boolean;
  25668. /**
  25669. * Gets whether or not the texture contains RGBD data.
  25670. */
  25671. readonly isRGBD: boolean;
  25672. /**
  25673. * Is Z inverted in the texture (useful in a cube texture).
  25674. */
  25675. invertZ: boolean;
  25676. /**
  25677. * Are mip maps generated for this texture or not.
  25678. */
  25679. readonly noMipmap: boolean;
  25680. /**
  25681. * @hidden
  25682. */
  25683. lodLevelInAlpha: boolean;
  25684. /**
  25685. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25686. */
  25687. lodGenerationOffset: number;
  25688. /**
  25689. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25690. */
  25691. lodGenerationScale: number;
  25692. /**
  25693. * Define if the texture is a render target.
  25694. */
  25695. isRenderTarget: boolean;
  25696. /**
  25697. * Define the unique id of the texture in the scene.
  25698. */
  25699. readonly uid: string;
  25700. /**
  25701. * Return a string representation of the texture.
  25702. * @returns the texture as a string
  25703. */
  25704. toString(): string;
  25705. /**
  25706. * Get the class name of the texture.
  25707. * @returns "BaseTexture"
  25708. */
  25709. getClassName(): string;
  25710. /**
  25711. * Define the list of animation attached to the texture.
  25712. */
  25713. animations: import("babylonjs/Animations/animation").Animation[];
  25714. /**
  25715. * An event triggered when the texture is disposed.
  25716. */
  25717. onDisposeObservable: Observable<BaseTexture>;
  25718. private _onDisposeObserver;
  25719. /**
  25720. * Callback triggered when the texture has been disposed.
  25721. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25722. */
  25723. onDispose: () => void;
  25724. /**
  25725. * Define the current state of the loading sequence when in delayed load mode.
  25726. */
  25727. delayLoadState: number;
  25728. private _scene;
  25729. /** @hidden */
  25730. _texture: Nullable<InternalTexture>;
  25731. private _uid;
  25732. /**
  25733. * Define if the texture is preventinga material to render or not.
  25734. * If not and the texture is not ready, the engine will use a default black texture instead.
  25735. */
  25736. readonly isBlocking: boolean;
  25737. /**
  25738. * Instantiates a new BaseTexture.
  25739. * Base class of all the textures in babylon.
  25740. * It groups all the common properties the materials, post process, lights... might need
  25741. * in order to make a correct use of the texture.
  25742. * @param scene Define the scene the texture blongs to
  25743. */
  25744. constructor(scene: Nullable<Scene>);
  25745. /**
  25746. * Get the scene the texture belongs to.
  25747. * @returns the scene or null if undefined
  25748. */
  25749. getScene(): Nullable<Scene>;
  25750. /**
  25751. * Get the texture transform matrix used to offset tile the texture for istance.
  25752. * @returns the transformation matrix
  25753. */
  25754. getTextureMatrix(): Matrix;
  25755. /**
  25756. * Get the texture reflection matrix used to rotate/transform the reflection.
  25757. * @returns the reflection matrix
  25758. */
  25759. getReflectionTextureMatrix(): Matrix;
  25760. /**
  25761. * Get the underlying lower level texture from Babylon.
  25762. * @returns the insternal texture
  25763. */
  25764. getInternalTexture(): Nullable<InternalTexture>;
  25765. /**
  25766. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25767. * @returns true if ready or not blocking
  25768. */
  25769. isReadyOrNotBlocking(): boolean;
  25770. /**
  25771. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25772. * @returns true if fully ready
  25773. */
  25774. isReady(): boolean;
  25775. private _cachedSize;
  25776. /**
  25777. * Get the size of the texture.
  25778. * @returns the texture size.
  25779. */
  25780. getSize(): ISize;
  25781. /**
  25782. * Get the base size of the texture.
  25783. * It can be different from the size if the texture has been resized for POT for instance
  25784. * @returns the base size
  25785. */
  25786. getBaseSize(): ISize;
  25787. /**
  25788. * Update the sampling mode of the texture.
  25789. * Default is Trilinear mode.
  25790. *
  25791. * | Value | Type | Description |
  25792. * | ----- | ------------------ | ----------- |
  25793. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25794. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25795. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25796. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25797. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25798. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25799. * | 7 | NEAREST_LINEAR | |
  25800. * | 8 | NEAREST_NEAREST | |
  25801. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25802. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25803. * | 11 | LINEAR_LINEAR | |
  25804. * | 12 | LINEAR_NEAREST | |
  25805. *
  25806. * > _mag_: magnification filter (close to the viewer)
  25807. * > _min_: minification filter (far from the viewer)
  25808. * > _mip_: filter used between mip map levels
  25809. *@param samplingMode Define the new sampling mode of the texture
  25810. */
  25811. updateSamplingMode(samplingMode: number): void;
  25812. /**
  25813. * Scales the texture if is `canRescale()`
  25814. * @param ratio the resize factor we want to use to rescale
  25815. */
  25816. scale(ratio: number): void;
  25817. /**
  25818. * Get if the texture can rescale.
  25819. */
  25820. readonly canRescale: boolean;
  25821. /** @hidden */
  25822. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25823. /** @hidden */
  25824. _rebuild(): void;
  25825. /**
  25826. * Triggers the load sequence in delayed load mode.
  25827. */
  25828. delayLoad(): void;
  25829. /**
  25830. * Clones the texture.
  25831. * @returns the cloned texture
  25832. */
  25833. clone(): Nullable<BaseTexture>;
  25834. /**
  25835. * Get the texture underlying type (INT, FLOAT...)
  25836. */
  25837. readonly textureType: number;
  25838. /**
  25839. * Get the texture underlying format (RGB, RGBA...)
  25840. */
  25841. readonly textureFormat: number;
  25842. /**
  25843. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25844. * This will returns an RGBA array buffer containing either in values (0-255) or
  25845. * float values (0-1) depending of the underlying buffer type.
  25846. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25847. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25848. * @param buffer defines a user defined buffer to fill with data (can be null)
  25849. * @returns The Array buffer containing the pixels data.
  25850. */
  25851. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25852. /**
  25853. * Release and destroy the underlying lower level texture aka internalTexture.
  25854. */
  25855. releaseInternalTexture(): void;
  25856. /**
  25857. * Get the polynomial representation of the texture data.
  25858. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25859. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25860. */
  25861. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25862. /** @hidden */
  25863. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25864. /** @hidden */
  25865. readonly _lodTextureMid: Nullable<BaseTexture>;
  25866. /** @hidden */
  25867. readonly _lodTextureLow: Nullable<BaseTexture>;
  25868. /**
  25869. * Dispose the texture and release its associated resources.
  25870. */
  25871. dispose(): void;
  25872. /**
  25873. * Serialize the texture into a JSON representation that can be parsed later on.
  25874. * @returns the JSON representation of the texture
  25875. */
  25876. serialize(): any;
  25877. /**
  25878. * Helper function to be called back once a list of texture contains only ready textures.
  25879. * @param textures Define the list of textures to wait for
  25880. * @param callback Define the callback triggered once the entire list will be ready
  25881. */
  25882. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25883. }
  25884. }
  25885. declare module "babylonjs/Materials/uniformBuffer" {
  25886. import { Nullable, FloatArray } from "babylonjs/types";
  25887. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25888. import { Engine } from "babylonjs/Engines/engine";
  25889. import { Effect } from "babylonjs/Materials/effect";
  25890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25891. /**
  25892. * Uniform buffer objects.
  25893. *
  25894. * Handles blocks of uniform on the GPU.
  25895. *
  25896. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25897. *
  25898. * For more information, please refer to :
  25899. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25900. */
  25901. export class UniformBuffer {
  25902. private _engine;
  25903. private _buffer;
  25904. private _data;
  25905. private _bufferData;
  25906. private _dynamic?;
  25907. private _uniformLocations;
  25908. private _uniformSizes;
  25909. private _uniformLocationPointer;
  25910. private _needSync;
  25911. private _noUBO;
  25912. private _currentEffect;
  25913. private static _MAX_UNIFORM_SIZE;
  25914. private static _tempBuffer;
  25915. /**
  25916. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25917. * This is dynamic to allow compat with webgl 1 and 2.
  25918. * You will need to pass the name of the uniform as well as the value.
  25919. */
  25920. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25921. /**
  25922. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25923. * This is dynamic to allow compat with webgl 1 and 2.
  25924. * You will need to pass the name of the uniform as well as the value.
  25925. */
  25926. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25927. /**
  25928. * Lambda to Update a single float in a uniform buffer.
  25929. * This is dynamic to allow compat with webgl 1 and 2.
  25930. * You will need to pass the name of the uniform as well as the value.
  25931. */
  25932. updateFloat: (name: string, x: number) => void;
  25933. /**
  25934. * Lambda to Update a vec2 of float in a uniform buffer.
  25935. * This is dynamic to allow compat with webgl 1 and 2.
  25936. * You will need to pass the name of the uniform as well as the value.
  25937. */
  25938. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25939. /**
  25940. * Lambda to Update a vec3 of float in a uniform buffer.
  25941. * This is dynamic to allow compat with webgl 1 and 2.
  25942. * You will need to pass the name of the uniform as well as the value.
  25943. */
  25944. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25945. /**
  25946. * Lambda to Update a vec4 of float in a uniform buffer.
  25947. * This is dynamic to allow compat with webgl 1 and 2.
  25948. * You will need to pass the name of the uniform as well as the value.
  25949. */
  25950. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25951. /**
  25952. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25953. * This is dynamic to allow compat with webgl 1 and 2.
  25954. * You will need to pass the name of the uniform as well as the value.
  25955. */
  25956. updateMatrix: (name: string, mat: Matrix) => void;
  25957. /**
  25958. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25959. * This is dynamic to allow compat with webgl 1 and 2.
  25960. * You will need to pass the name of the uniform as well as the value.
  25961. */
  25962. updateVector3: (name: string, vector: Vector3) => void;
  25963. /**
  25964. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25965. * This is dynamic to allow compat with webgl 1 and 2.
  25966. * You will need to pass the name of the uniform as well as the value.
  25967. */
  25968. updateVector4: (name: string, vector: Vector4) => void;
  25969. /**
  25970. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25971. * This is dynamic to allow compat with webgl 1 and 2.
  25972. * You will need to pass the name of the uniform as well as the value.
  25973. */
  25974. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25975. /**
  25976. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25977. * This is dynamic to allow compat with webgl 1 and 2.
  25978. * You will need to pass the name of the uniform as well as the value.
  25979. */
  25980. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25981. /**
  25982. * Instantiates a new Uniform buffer objects.
  25983. *
  25984. * Handles blocks of uniform on the GPU.
  25985. *
  25986. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25987. *
  25988. * For more information, please refer to :
  25989. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25990. * @param engine Define the engine the buffer is associated with
  25991. * @param data Define the data contained in the buffer
  25992. * @param dynamic Define if the buffer is updatable
  25993. */
  25994. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25995. /**
  25996. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25997. * or just falling back on setUniformXXX calls.
  25998. */
  25999. readonly useUbo: boolean;
  26000. /**
  26001. * Indicates if the WebGL underlying uniform buffer is in sync
  26002. * with the javascript cache data.
  26003. */
  26004. readonly isSync: boolean;
  26005. /**
  26006. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26007. * Also, a dynamic UniformBuffer will disable cache verification and always
  26008. * update the underlying WebGL uniform buffer to the GPU.
  26009. * @returns if Dynamic, otherwise false
  26010. */
  26011. isDynamic(): boolean;
  26012. /**
  26013. * The data cache on JS side.
  26014. * @returns the underlying data as a float array
  26015. */
  26016. getData(): Float32Array;
  26017. /**
  26018. * The underlying WebGL Uniform buffer.
  26019. * @returns the webgl buffer
  26020. */
  26021. getBuffer(): Nullable<WebGLBuffer>;
  26022. /**
  26023. * std140 layout specifies how to align data within an UBO structure.
  26024. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26025. * for specs.
  26026. */
  26027. private _fillAlignment;
  26028. /**
  26029. * Adds an uniform in the buffer.
  26030. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26031. * for the layout to be correct !
  26032. * @param name Name of the uniform, as used in the uniform block in the shader.
  26033. * @param size Data size, or data directly.
  26034. */
  26035. addUniform(name: string, size: number | number[]): void;
  26036. /**
  26037. * Adds a Matrix 4x4 to the uniform buffer.
  26038. * @param name Name of the uniform, as used in the uniform block in the shader.
  26039. * @param mat A 4x4 matrix.
  26040. */
  26041. addMatrix(name: string, mat: Matrix): void;
  26042. /**
  26043. * Adds a vec2 to the uniform buffer.
  26044. * @param name Name of the uniform, as used in the uniform block in the shader.
  26045. * @param x Define the x component value of the vec2
  26046. * @param y Define the y component value of the vec2
  26047. */
  26048. addFloat2(name: string, x: number, y: number): void;
  26049. /**
  26050. * Adds a vec3 to the uniform buffer.
  26051. * @param name Name of the uniform, as used in the uniform block in the shader.
  26052. * @param x Define the x component value of the vec3
  26053. * @param y Define the y component value of the vec3
  26054. * @param z Define the z component value of the vec3
  26055. */
  26056. addFloat3(name: string, x: number, y: number, z: number): void;
  26057. /**
  26058. * Adds a vec3 to the uniform buffer.
  26059. * @param name Name of the uniform, as used in the uniform block in the shader.
  26060. * @param color Define the vec3 from a Color
  26061. */
  26062. addColor3(name: string, color: Color3): void;
  26063. /**
  26064. * Adds a vec4 to the uniform buffer.
  26065. * @param name Name of the uniform, as used in the uniform block in the shader.
  26066. * @param color Define the rgb components from a Color
  26067. * @param alpha Define the a component of the vec4
  26068. */
  26069. addColor4(name: string, color: Color3, alpha: number): void;
  26070. /**
  26071. * Adds a vec3 to the uniform buffer.
  26072. * @param name Name of the uniform, as used in the uniform block in the shader.
  26073. * @param vector Define the vec3 components from a Vector
  26074. */
  26075. addVector3(name: string, vector: Vector3): void;
  26076. /**
  26077. * Adds a Matrix 3x3 to the uniform buffer.
  26078. * @param name Name of the uniform, as used in the uniform block in the shader.
  26079. */
  26080. addMatrix3x3(name: string): void;
  26081. /**
  26082. * Adds a Matrix 2x2 to the uniform buffer.
  26083. * @param name Name of the uniform, as used in the uniform block in the shader.
  26084. */
  26085. addMatrix2x2(name: string): void;
  26086. /**
  26087. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26088. */
  26089. create(): void;
  26090. /** @hidden */
  26091. _rebuild(): void;
  26092. /**
  26093. * Updates the WebGL Uniform Buffer on the GPU.
  26094. * If the `dynamic` flag is set to true, no cache comparison is done.
  26095. * Otherwise, the buffer will be updated only if the cache differs.
  26096. */
  26097. update(): void;
  26098. /**
  26099. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26100. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26101. * @param data Define the flattened data
  26102. * @param size Define the size of the data.
  26103. */
  26104. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26105. private _updateMatrix3x3ForUniform;
  26106. private _updateMatrix3x3ForEffect;
  26107. private _updateMatrix2x2ForEffect;
  26108. private _updateMatrix2x2ForUniform;
  26109. private _updateFloatForEffect;
  26110. private _updateFloatForUniform;
  26111. private _updateFloat2ForEffect;
  26112. private _updateFloat2ForUniform;
  26113. private _updateFloat3ForEffect;
  26114. private _updateFloat3ForUniform;
  26115. private _updateFloat4ForEffect;
  26116. private _updateFloat4ForUniform;
  26117. private _updateMatrixForEffect;
  26118. private _updateMatrixForUniform;
  26119. private _updateVector3ForEffect;
  26120. private _updateVector3ForUniform;
  26121. private _updateVector4ForEffect;
  26122. private _updateVector4ForUniform;
  26123. private _updateColor3ForEffect;
  26124. private _updateColor3ForUniform;
  26125. private _updateColor4ForEffect;
  26126. private _updateColor4ForUniform;
  26127. /**
  26128. * Sets a sampler uniform on the effect.
  26129. * @param name Define the name of the sampler.
  26130. * @param texture Define the texture to set in the sampler
  26131. */
  26132. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26133. /**
  26134. * Directly updates the value of the uniform in the cache AND on the GPU.
  26135. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26136. * @param data Define the flattened data
  26137. */
  26138. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26139. /**
  26140. * Binds this uniform buffer to an effect.
  26141. * @param effect Define the effect to bind the buffer to
  26142. * @param name Name of the uniform block in the shader.
  26143. */
  26144. bindToEffect(effect: Effect, name: string): void;
  26145. /**
  26146. * Disposes the uniform buffer.
  26147. */
  26148. dispose(): void;
  26149. }
  26150. }
  26151. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26152. import { Nullable } from "babylonjs/types";
  26153. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26154. /**
  26155. * This represents the required contract to create a new type of texture loader.
  26156. */
  26157. export interface IInternalTextureLoader {
  26158. /**
  26159. * Defines wether the loader supports cascade loading the different faces.
  26160. */
  26161. supportCascades: boolean;
  26162. /**
  26163. * This returns if the loader support the current file information.
  26164. * @param extension defines the file extension of the file being loaded
  26165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26166. * @param fallback defines the fallback internal texture if any
  26167. * @param isBase64 defines whether the texture is encoded as a base64
  26168. * @param isBuffer defines whether the texture data are stored as a buffer
  26169. * @returns true if the loader can load the specified file
  26170. */
  26171. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26172. /**
  26173. * Transform the url before loading if required.
  26174. * @param rootUrl the url of the texture
  26175. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26176. * @returns the transformed texture
  26177. */
  26178. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26179. /**
  26180. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26181. * @param rootUrl the url of the texture
  26182. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26183. * @returns the fallback texture
  26184. */
  26185. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26186. /**
  26187. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26188. * @param data contains the texture data
  26189. * @param texture defines the BabylonJS internal texture
  26190. * @param createPolynomials will be true if polynomials have been requested
  26191. * @param onLoad defines the callback to trigger once the texture is ready
  26192. * @param onError defines the callback to trigger in case of error
  26193. */
  26194. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26195. /**
  26196. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26197. * @param data contains the texture data
  26198. * @param texture defines the BabylonJS internal texture
  26199. * @param callback defines the method to call once ready to upload
  26200. */
  26201. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26202. }
  26203. }
  26204. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26205. import { Scene } from "babylonjs/scene";
  26206. import { Engine } from "babylonjs/Engines/engine";
  26207. import { Texture } from "babylonjs/Materials/Textures/texture";
  26208. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26209. /**
  26210. * Creation options of the multi render target texture.
  26211. */
  26212. export interface IMultiRenderTargetOptions {
  26213. /**
  26214. * Define if the texture needs to create mip maps after render.
  26215. */
  26216. generateMipMaps?: boolean;
  26217. /**
  26218. * Define the types of all the draw buffers we want to create
  26219. */
  26220. types?: number[];
  26221. /**
  26222. * Define the sampling modes of all the draw buffers we want to create
  26223. */
  26224. samplingModes?: number[];
  26225. /**
  26226. * Define if a depth buffer is required
  26227. */
  26228. generateDepthBuffer?: boolean;
  26229. /**
  26230. * Define if a stencil buffer is required
  26231. */
  26232. generateStencilBuffer?: boolean;
  26233. /**
  26234. * Define if a depth texture is required instead of a depth buffer
  26235. */
  26236. generateDepthTexture?: boolean;
  26237. /**
  26238. * Define the number of desired draw buffers
  26239. */
  26240. textureCount?: number;
  26241. /**
  26242. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26243. */
  26244. doNotChangeAspectRatio?: boolean;
  26245. /**
  26246. * Define the default type of the buffers we are creating
  26247. */
  26248. defaultType?: number;
  26249. }
  26250. /**
  26251. * A multi render target, like a render target provides the ability to render to a texture.
  26252. * Unlike the render target, it can render to several draw buffers in one draw.
  26253. * This is specially interesting in deferred rendering or for any effects requiring more than
  26254. * just one color from a single pass.
  26255. */
  26256. export class MultiRenderTarget extends RenderTargetTexture {
  26257. private _internalTextures;
  26258. private _textures;
  26259. private _multiRenderTargetOptions;
  26260. /**
  26261. * Get if draw buffers are currently supported by the used hardware and browser.
  26262. */
  26263. readonly isSupported: boolean;
  26264. /**
  26265. * Get the list of textures generated by the multi render target.
  26266. */
  26267. readonly textures: Texture[];
  26268. /**
  26269. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26270. */
  26271. readonly depthTexture: Texture;
  26272. /**
  26273. * Set the wrapping mode on U of all the textures we are rendering to.
  26274. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26275. */
  26276. wrapU: number;
  26277. /**
  26278. * Set the wrapping mode on V of all the textures we are rendering to.
  26279. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26280. */
  26281. wrapV: number;
  26282. /**
  26283. * Instantiate a new multi render target texture.
  26284. * A multi render target, like a render target provides the ability to render to a texture.
  26285. * Unlike the render target, it can render to several draw buffers in one draw.
  26286. * This is specially interesting in deferred rendering or for any effects requiring more than
  26287. * just one color from a single pass.
  26288. * @param name Define the name of the texture
  26289. * @param size Define the size of the buffers to render to
  26290. * @param count Define the number of target we are rendering into
  26291. * @param scene Define the scene the texture belongs to
  26292. * @param options Define the options used to create the multi render target
  26293. */
  26294. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26295. /** @hidden */
  26296. _rebuild(): void;
  26297. private _createInternalTextures;
  26298. private _createTextures;
  26299. /**
  26300. * Define the number of samples used if MSAA is enabled.
  26301. */
  26302. samples: number;
  26303. /**
  26304. * Resize all the textures in the multi render target.
  26305. * Be carrefull as it will recreate all the data in the new texture.
  26306. * @param size Define the new size
  26307. */
  26308. resize(size: any): void;
  26309. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26310. /**
  26311. * Dispose the render targets and their associated resources
  26312. */
  26313. dispose(): void;
  26314. /**
  26315. * Release all the underlying texture used as draw buffers.
  26316. */
  26317. releaseInternalTextures(): void;
  26318. }
  26319. }
  26320. declare module "babylonjs/Audio/analyser" {
  26321. import { Scene } from "babylonjs/scene";
  26322. /**
  26323. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26325. */
  26326. export class Analyser {
  26327. /**
  26328. * Gets or sets the smoothing
  26329. * @ignorenaming
  26330. */
  26331. SMOOTHING: number;
  26332. /**
  26333. * Gets or sets the FFT table size
  26334. * @ignorenaming
  26335. */
  26336. FFT_SIZE: number;
  26337. /**
  26338. * Gets or sets the bar graph amplitude
  26339. * @ignorenaming
  26340. */
  26341. BARGRAPHAMPLITUDE: number;
  26342. /**
  26343. * Gets or sets the position of the debug canvas
  26344. * @ignorenaming
  26345. */
  26346. DEBUGCANVASPOS: {
  26347. x: number;
  26348. y: number;
  26349. };
  26350. /**
  26351. * Gets or sets the debug canvas size
  26352. * @ignorenaming
  26353. */
  26354. DEBUGCANVASSIZE: {
  26355. width: number;
  26356. height: number;
  26357. };
  26358. private _byteFreqs;
  26359. private _byteTime;
  26360. private _floatFreqs;
  26361. private _webAudioAnalyser;
  26362. private _debugCanvas;
  26363. private _debugCanvasContext;
  26364. private _scene;
  26365. private _registerFunc;
  26366. private _audioEngine;
  26367. /**
  26368. * Creates a new analyser
  26369. * @param scene defines hosting scene
  26370. */
  26371. constructor(scene: Scene);
  26372. /**
  26373. * Get the number of data values you will have to play with for the visualization
  26374. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26375. * @returns a number
  26376. */
  26377. getFrequencyBinCount(): number;
  26378. /**
  26379. * Gets the current frequency data as a byte array
  26380. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26381. * @returns a Uint8Array
  26382. */
  26383. getByteFrequencyData(): Uint8Array;
  26384. /**
  26385. * Gets the current waveform as a byte array
  26386. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26387. * @returns a Uint8Array
  26388. */
  26389. getByteTimeDomainData(): Uint8Array;
  26390. /**
  26391. * Gets the current frequency data as a float array
  26392. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26393. * @returns a Float32Array
  26394. */
  26395. getFloatFrequencyData(): Float32Array;
  26396. /**
  26397. * Renders the debug canvas
  26398. */
  26399. drawDebugCanvas(): void;
  26400. /**
  26401. * Stops rendering the debug canvas and removes it
  26402. */
  26403. stopDebugCanvas(): void;
  26404. /**
  26405. * Connects two audio nodes
  26406. * @param inputAudioNode defines first node to connect
  26407. * @param outputAudioNode defines second node to connect
  26408. */
  26409. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26410. /**
  26411. * Releases all associated resources
  26412. */
  26413. dispose(): void;
  26414. }
  26415. }
  26416. declare module "babylonjs/Audio/audioEngine" {
  26417. import { IDisposable } from "babylonjs/scene";
  26418. import { Analyser } from "babylonjs/Audio/analyser";
  26419. import { Nullable } from "babylonjs/types";
  26420. import { Observable } from "babylonjs/Misc/observable";
  26421. /**
  26422. * This represents an audio engine and it is responsible
  26423. * to play, synchronize and analyse sounds throughout the application.
  26424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26425. */
  26426. export interface IAudioEngine extends IDisposable {
  26427. /**
  26428. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26429. */
  26430. readonly canUseWebAudio: boolean;
  26431. /**
  26432. * Gets the current AudioContext if available.
  26433. */
  26434. readonly audioContext: Nullable<AudioContext>;
  26435. /**
  26436. * The master gain node defines the global audio volume of your audio engine.
  26437. */
  26438. readonly masterGain: GainNode;
  26439. /**
  26440. * Gets whether or not mp3 are supported by your browser.
  26441. */
  26442. readonly isMP3supported: boolean;
  26443. /**
  26444. * Gets whether or not ogg are supported by your browser.
  26445. */
  26446. readonly isOGGsupported: boolean;
  26447. /**
  26448. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26449. * @ignoreNaming
  26450. */
  26451. WarnedWebAudioUnsupported: boolean;
  26452. /**
  26453. * Defines if the audio engine relies on a custom unlocked button.
  26454. * In this case, the embedded button will not be displayed.
  26455. */
  26456. useCustomUnlockedButton: boolean;
  26457. /**
  26458. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26459. */
  26460. readonly unlocked: boolean;
  26461. /**
  26462. * Event raised when audio has been unlocked on the browser.
  26463. */
  26464. onAudioUnlockedObservable: Observable<AudioEngine>;
  26465. /**
  26466. * Event raised when audio has been locked on the browser.
  26467. */
  26468. onAudioLockedObservable: Observable<AudioEngine>;
  26469. /**
  26470. * Flags the audio engine in Locked state.
  26471. * This happens due to new browser policies preventing audio to autoplay.
  26472. */
  26473. lock(): void;
  26474. /**
  26475. * Unlocks the audio engine once a user action has been done on the dom.
  26476. * This is helpful to resume play once browser policies have been satisfied.
  26477. */
  26478. unlock(): void;
  26479. }
  26480. /**
  26481. * This represents the default audio engine used in babylon.
  26482. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26484. */
  26485. export class AudioEngine implements IAudioEngine {
  26486. private _audioContext;
  26487. private _audioContextInitialized;
  26488. private _muteButton;
  26489. private _hostElement;
  26490. /**
  26491. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26492. */
  26493. canUseWebAudio: boolean;
  26494. /**
  26495. * The master gain node defines the global audio volume of your audio engine.
  26496. */
  26497. masterGain: GainNode;
  26498. /**
  26499. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26500. * @ignoreNaming
  26501. */
  26502. WarnedWebAudioUnsupported: boolean;
  26503. /**
  26504. * Gets whether or not mp3 are supported by your browser.
  26505. */
  26506. isMP3supported: boolean;
  26507. /**
  26508. * Gets whether or not ogg are supported by your browser.
  26509. */
  26510. isOGGsupported: boolean;
  26511. /**
  26512. * Gets whether audio has been unlocked on the device.
  26513. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26514. * a user interaction has happened.
  26515. */
  26516. unlocked: boolean;
  26517. /**
  26518. * Defines if the audio engine relies on a custom unlocked button.
  26519. * In this case, the embedded button will not be displayed.
  26520. */
  26521. useCustomUnlockedButton: boolean;
  26522. /**
  26523. * Event raised when audio has been unlocked on the browser.
  26524. */
  26525. onAudioUnlockedObservable: Observable<AudioEngine>;
  26526. /**
  26527. * Event raised when audio has been locked on the browser.
  26528. */
  26529. onAudioLockedObservable: Observable<AudioEngine>;
  26530. /**
  26531. * Gets the current AudioContext if available.
  26532. */
  26533. readonly audioContext: Nullable<AudioContext>;
  26534. private _connectedAnalyser;
  26535. /**
  26536. * Instantiates a new audio engine.
  26537. *
  26538. * There should be only one per page as some browsers restrict the number
  26539. * of audio contexts you can create.
  26540. * @param hostElement defines the host element where to display the mute icon if necessary
  26541. */
  26542. constructor(hostElement?: Nullable<HTMLElement>);
  26543. /**
  26544. * Flags the audio engine in Locked state.
  26545. * This happens due to new browser policies preventing audio to autoplay.
  26546. */
  26547. lock(): void;
  26548. /**
  26549. * Unlocks the audio engine once a user action has been done on the dom.
  26550. * This is helpful to resume play once browser policies have been satisfied.
  26551. */
  26552. unlock(): void;
  26553. private _resumeAudioContext;
  26554. private _initializeAudioContext;
  26555. private _tryToRun;
  26556. private _triggerRunningState;
  26557. private _triggerSuspendedState;
  26558. private _displayMuteButton;
  26559. private _moveButtonToTopLeft;
  26560. private _onResize;
  26561. private _hideMuteButton;
  26562. /**
  26563. * Destroy and release the resources associated with the audio ccontext.
  26564. */
  26565. dispose(): void;
  26566. /**
  26567. * Gets the global volume sets on the master gain.
  26568. * @returns the global volume if set or -1 otherwise
  26569. */
  26570. getGlobalVolume(): number;
  26571. /**
  26572. * Sets the global volume of your experience (sets on the master gain).
  26573. * @param newVolume Defines the new global volume of the application
  26574. */
  26575. setGlobalVolume(newVolume: number): void;
  26576. /**
  26577. * Connect the audio engine to an audio analyser allowing some amazing
  26578. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26580. * @param analyser The analyser to connect to the engine
  26581. */
  26582. connectToAnalyser(analyser: Analyser): void;
  26583. }
  26584. }
  26585. declare module "babylonjs/Loading/loadingScreen" {
  26586. /**
  26587. * Interface used to present a loading screen while loading a scene
  26588. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26589. */
  26590. export interface ILoadingScreen {
  26591. /**
  26592. * Function called to display the loading screen
  26593. */
  26594. displayLoadingUI: () => void;
  26595. /**
  26596. * Function called to hide the loading screen
  26597. */
  26598. hideLoadingUI: () => void;
  26599. /**
  26600. * Gets or sets the color to use for the background
  26601. */
  26602. loadingUIBackgroundColor: string;
  26603. /**
  26604. * Gets or sets the text to display while loading
  26605. */
  26606. loadingUIText: string;
  26607. }
  26608. /**
  26609. * Class used for the default loading screen
  26610. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26611. */
  26612. export class DefaultLoadingScreen implements ILoadingScreen {
  26613. private _renderingCanvas;
  26614. private _loadingText;
  26615. private _loadingDivBackgroundColor;
  26616. private _loadingDiv;
  26617. private _loadingTextDiv;
  26618. /**
  26619. * Creates a new default loading screen
  26620. * @param _renderingCanvas defines the canvas used to render the scene
  26621. * @param _loadingText defines the default text to display
  26622. * @param _loadingDivBackgroundColor defines the default background color
  26623. */
  26624. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26625. /**
  26626. * Function called to display the loading screen
  26627. */
  26628. displayLoadingUI(): void;
  26629. /**
  26630. * Function called to hide the loading screen
  26631. */
  26632. hideLoadingUI(): void;
  26633. /**
  26634. * Gets or sets the text to display while loading
  26635. */
  26636. loadingUIText: string;
  26637. /**
  26638. * Gets or sets the color to use for the background
  26639. */
  26640. loadingUIBackgroundColor: string;
  26641. private _resizeLoadingUI;
  26642. }
  26643. }
  26644. declare module "babylonjs/Materials/Textures/videoTexture" {
  26645. import { Observable } from "babylonjs/Misc/observable";
  26646. import { Nullable } from "babylonjs/types";
  26647. import { Scene } from "babylonjs/scene";
  26648. import { Texture } from "babylonjs/Materials/Textures/texture";
  26649. /**
  26650. * Settings for finer control over video usage
  26651. */
  26652. export interface VideoTextureSettings {
  26653. /**
  26654. * Applies `autoplay` to video, if specified
  26655. */
  26656. autoPlay?: boolean;
  26657. /**
  26658. * Applies `loop` to video, if specified
  26659. */
  26660. loop?: boolean;
  26661. /**
  26662. * Automatically updates internal texture from video at every frame in the render loop
  26663. */
  26664. autoUpdateTexture: boolean;
  26665. /**
  26666. * Image src displayed during the video loading or until the user interacts with the video.
  26667. */
  26668. poster?: string;
  26669. }
  26670. /**
  26671. * If you want to display a video in your scene, this is the special texture for that.
  26672. * This special texture works similar to other textures, with the exception of a few parameters.
  26673. * @see https://doc.babylonjs.com/how_to/video_texture
  26674. */
  26675. export class VideoTexture extends Texture {
  26676. /**
  26677. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26678. */
  26679. readonly autoUpdateTexture: boolean;
  26680. /**
  26681. * The video instance used by the texture internally
  26682. */
  26683. readonly video: HTMLVideoElement;
  26684. private _onUserActionRequestedObservable;
  26685. /**
  26686. * Event triggerd when a dom action is required by the user to play the video.
  26687. * This happens due to recent changes in browser policies preventing video to auto start.
  26688. */
  26689. readonly onUserActionRequestedObservable: Observable<Texture>;
  26690. private _generateMipMaps;
  26691. private _engine;
  26692. private _stillImageCaptured;
  26693. private _displayingPosterTexture;
  26694. private _settings;
  26695. private _createInternalTextureOnEvent;
  26696. /**
  26697. * Creates a video texture.
  26698. * If you want to display a video in your scene, this is the special texture for that.
  26699. * This special texture works similar to other textures, with the exception of a few parameters.
  26700. * @see https://doc.babylonjs.com/how_to/video_texture
  26701. * @param name optional name, will detect from video source, if not defined
  26702. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26703. * @param scene is obviously the current scene.
  26704. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26705. * @param invertY is false by default but can be used to invert video on Y axis
  26706. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26707. * @param settings allows finer control over video usage
  26708. */
  26709. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26710. private _getName;
  26711. private _getVideo;
  26712. private _createInternalTexture;
  26713. private reset;
  26714. /**
  26715. * @hidden Internal method to initiate `update`.
  26716. */
  26717. _rebuild(): void;
  26718. /**
  26719. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26720. */
  26721. update(): void;
  26722. /**
  26723. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26724. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26725. */
  26726. updateTexture(isVisible: boolean): void;
  26727. protected _updateInternalTexture: () => void;
  26728. /**
  26729. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26730. * @param url New url.
  26731. */
  26732. updateURL(url: string): void;
  26733. /**
  26734. * Dispose the texture and release its associated resources.
  26735. */
  26736. dispose(): void;
  26737. /**
  26738. * Creates a video texture straight from a stream.
  26739. * @param scene Define the scene the texture should be created in
  26740. * @param stream Define the stream the texture should be created from
  26741. * @returns The created video texture as a promise
  26742. */
  26743. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26744. /**
  26745. * Creates a video texture straight from your WebCam video feed.
  26746. * @param scene Define the scene the texture should be created in
  26747. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26748. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26749. * @returns The created video texture as a promise
  26750. */
  26751. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26752. minWidth: number;
  26753. maxWidth: number;
  26754. minHeight: number;
  26755. maxHeight: number;
  26756. deviceId: string;
  26757. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26758. /**
  26759. * Creates a video texture straight from your WebCam video feed.
  26760. * @param scene Define the scene the texture should be created in
  26761. * @param onReady Define a callback to triggered once the texture will be ready
  26762. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26763. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26764. */
  26765. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26766. minWidth: number;
  26767. maxWidth: number;
  26768. minHeight: number;
  26769. maxHeight: number;
  26770. deviceId: string;
  26771. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26772. }
  26773. }
  26774. declare module "babylonjs/Engines/engine" {
  26775. import { Observable } from "babylonjs/Misc/observable";
  26776. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26777. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26778. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26779. import { Camera } from "babylonjs/Cameras/camera";
  26780. import { Scene } from "babylonjs/scene";
  26781. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26782. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26783. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26784. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26785. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26786. import { Material } from "babylonjs/Materials/material";
  26787. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26790. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26791. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26792. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26793. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26794. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26795. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26796. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26797. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26798. /**
  26799. * Interface for attribute information associated with buffer instanciation
  26800. */
  26801. export class InstancingAttributeInfo {
  26802. /**
  26803. * Index/offset of the attribute in the vertex shader
  26804. */
  26805. index: number;
  26806. /**
  26807. * size of the attribute, 1, 2, 3 or 4
  26808. */
  26809. attributeSize: number;
  26810. /**
  26811. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26812. * default is FLOAT
  26813. */
  26814. attribyteType: number;
  26815. /**
  26816. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26817. */
  26818. normalized: boolean;
  26819. /**
  26820. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26821. */
  26822. offset: number;
  26823. /**
  26824. * Name of the GLSL attribute, for debugging purpose only
  26825. */
  26826. attributeName: string;
  26827. }
  26828. /**
  26829. * Define options used to create a depth texture
  26830. */
  26831. export class DepthTextureCreationOptions {
  26832. /** Specifies whether or not a stencil should be allocated in the texture */
  26833. generateStencil?: boolean;
  26834. /** Specifies whether or not bilinear filtering is enable on the texture */
  26835. bilinearFiltering?: boolean;
  26836. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26837. comparisonFunction?: number;
  26838. /** Specifies if the created texture is a cube texture */
  26839. isCube?: boolean;
  26840. }
  26841. /**
  26842. * Class used to describe the capabilities of the engine relatively to the current browser
  26843. */
  26844. export class EngineCapabilities {
  26845. /** Maximum textures units per fragment shader */
  26846. maxTexturesImageUnits: number;
  26847. /** Maximum texture units per vertex shader */
  26848. maxVertexTextureImageUnits: number;
  26849. /** Maximum textures units in the entire pipeline */
  26850. maxCombinedTexturesImageUnits: number;
  26851. /** Maximum texture size */
  26852. maxTextureSize: number;
  26853. /** Maximum cube texture size */
  26854. maxCubemapTextureSize: number;
  26855. /** Maximum render texture size */
  26856. maxRenderTextureSize: number;
  26857. /** Maximum number of vertex attributes */
  26858. maxVertexAttribs: number;
  26859. /** Maximum number of varyings */
  26860. maxVaryingVectors: number;
  26861. /** Maximum number of uniforms per vertex shader */
  26862. maxVertexUniformVectors: number;
  26863. /** Maximum number of uniforms per fragment shader */
  26864. maxFragmentUniformVectors: number;
  26865. /** Defines if standard derivates (dx/dy) are supported */
  26866. standardDerivatives: boolean;
  26867. /** Defines if s3tc texture compression is supported */
  26868. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26869. /** Defines if pvrtc texture compression is supported */
  26870. pvrtc: any;
  26871. /** Defines if etc1 texture compression is supported */
  26872. etc1: any;
  26873. /** Defines if etc2 texture compression is supported */
  26874. etc2: any;
  26875. /** Defines if astc texture compression is supported */
  26876. astc: any;
  26877. /** Defines if float textures are supported */
  26878. textureFloat: boolean;
  26879. /** Defines if vertex array objects are supported */
  26880. vertexArrayObject: boolean;
  26881. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26882. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26883. /** Gets the maximum level of anisotropy supported */
  26884. maxAnisotropy: number;
  26885. /** Defines if instancing is supported */
  26886. instancedArrays: boolean;
  26887. /** Defines if 32 bits indices are supported */
  26888. uintIndices: boolean;
  26889. /** Defines if high precision shaders are supported */
  26890. highPrecisionShaderSupported: boolean;
  26891. /** Defines if depth reading in the fragment shader is supported */
  26892. fragmentDepthSupported: boolean;
  26893. /** Defines if float texture linear filtering is supported*/
  26894. textureFloatLinearFiltering: boolean;
  26895. /** Defines if rendering to float textures is supported */
  26896. textureFloatRender: boolean;
  26897. /** Defines if half float textures are supported*/
  26898. textureHalfFloat: boolean;
  26899. /** Defines if half float texture linear filtering is supported*/
  26900. textureHalfFloatLinearFiltering: boolean;
  26901. /** Defines if rendering to half float textures is supported */
  26902. textureHalfFloatRender: boolean;
  26903. /** Defines if textureLOD shader command is supported */
  26904. textureLOD: boolean;
  26905. /** Defines if draw buffers extension is supported */
  26906. drawBuffersExtension: boolean;
  26907. /** Defines if depth textures are supported */
  26908. depthTextureExtension: boolean;
  26909. /** Defines if float color buffer are supported */
  26910. colorBufferFloat: boolean;
  26911. /** Gets disjoint timer query extension (null if not supported) */
  26912. timerQuery: EXT_disjoint_timer_query;
  26913. /** Defines if timestamp can be used with timer query */
  26914. canUseTimestampForTimerQuery: boolean;
  26915. /** Function used to let the system compiles shaders in background */
  26916. parallelShaderCompile: {
  26917. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26918. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26919. COMPLETION_STATUS_KHR: number;
  26920. };
  26921. }
  26922. /** Interface defining initialization parameters for Engine class */
  26923. export interface EngineOptions extends WebGLContextAttributes {
  26924. /**
  26925. * Defines if the engine should no exceed a specified device ratio
  26926. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26927. */
  26928. limitDeviceRatio?: number;
  26929. /**
  26930. * Defines if webvr should be enabled automatically
  26931. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26932. */
  26933. autoEnableWebVR?: boolean;
  26934. /**
  26935. * Defines if webgl2 should be turned off even if supported
  26936. * @see http://doc.babylonjs.com/features/webgl2
  26937. */
  26938. disableWebGL2Support?: boolean;
  26939. /**
  26940. * Defines if webaudio should be initialized as well
  26941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26942. */
  26943. audioEngine?: boolean;
  26944. /**
  26945. * Defines if animations should run using a deterministic lock step
  26946. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26947. */
  26948. deterministicLockstep?: boolean;
  26949. /** Defines the maximum steps to use with deterministic lock step mode */
  26950. lockstepMaxSteps?: number;
  26951. /**
  26952. * Defines that engine should ignore context lost events
  26953. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26954. */
  26955. doNotHandleContextLost?: boolean;
  26956. /**
  26957. * Defines that engine should ignore modifying touch action attribute and style
  26958. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26959. */
  26960. doNotHandleTouchAction?: boolean;
  26961. }
  26962. /**
  26963. * Defines the interface used by display changed events
  26964. */
  26965. export interface IDisplayChangedEventArgs {
  26966. /** Gets the vrDisplay object (if any) */
  26967. vrDisplay: Nullable<any>;
  26968. /** Gets a boolean indicating if webVR is supported */
  26969. vrSupported: boolean;
  26970. }
  26971. /**
  26972. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26973. */
  26974. export class Engine {
  26975. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26976. static ExceptionList: ({
  26977. key: string;
  26978. capture: string;
  26979. captureConstraint: number;
  26980. targets: string[];
  26981. } | {
  26982. key: string;
  26983. capture: null;
  26984. captureConstraint: null;
  26985. targets: string[];
  26986. })[];
  26987. /** Gets the list of created engines */
  26988. static readonly Instances: Engine[];
  26989. /**
  26990. * Gets the latest created engine
  26991. */
  26992. static readonly LastCreatedEngine: Nullable<Engine>;
  26993. /**
  26994. * Gets the latest created scene
  26995. */
  26996. static readonly LastCreatedScene: Nullable<Scene>;
  26997. /**
  26998. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26999. * @param flag defines which part of the materials must be marked as dirty
  27000. * @param predicate defines a predicate used to filter which materials should be affected
  27001. */
  27002. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27003. /**
  27004. * Hidden
  27005. */
  27006. static _TextureLoaders: IInternalTextureLoader[];
  27007. /** Defines that alpha blending is disabled */
  27008. static readonly ALPHA_DISABLE: number;
  27009. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27010. static readonly ALPHA_ADD: number;
  27011. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27012. static readonly ALPHA_COMBINE: number;
  27013. /** Defines that alpha blending to DEST - SRC * DEST */
  27014. static readonly ALPHA_SUBTRACT: number;
  27015. /** Defines that alpha blending to SRC * DEST */
  27016. static readonly ALPHA_MULTIPLY: number;
  27017. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27018. static readonly ALPHA_MAXIMIZED: number;
  27019. /** Defines that alpha blending to SRC + DEST */
  27020. static readonly ALPHA_ONEONE: number;
  27021. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27022. static readonly ALPHA_PREMULTIPLIED: number;
  27023. /**
  27024. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27025. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27026. */
  27027. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27028. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27029. static readonly ALPHA_INTERPOLATE: number;
  27030. /**
  27031. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27032. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27033. */
  27034. static readonly ALPHA_SCREENMODE: number;
  27035. /** Defines that the ressource is not delayed*/
  27036. static readonly DELAYLOADSTATE_NONE: number;
  27037. /** Defines that the ressource was successfully delay loaded */
  27038. static readonly DELAYLOADSTATE_LOADED: number;
  27039. /** Defines that the ressource is currently delay loading */
  27040. static readonly DELAYLOADSTATE_LOADING: number;
  27041. /** Defines that the ressource is delayed and has not started loading */
  27042. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27043. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27044. static readonly NEVER: number;
  27045. /** 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 */
  27046. static readonly ALWAYS: number;
  27047. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27048. static readonly LESS: number;
  27049. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27050. static readonly EQUAL: number;
  27051. /** 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 */
  27052. static readonly LEQUAL: number;
  27053. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27054. static readonly GREATER: number;
  27055. /** 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 */
  27056. static readonly GEQUAL: number;
  27057. /** 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 */
  27058. static readonly NOTEQUAL: number;
  27059. /** Passed to stencilOperation to specify that stencil value must be kept */
  27060. static readonly KEEP: number;
  27061. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27062. static readonly REPLACE: number;
  27063. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27064. static readonly INCR: number;
  27065. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27066. static readonly DECR: number;
  27067. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27068. static readonly INVERT: number;
  27069. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27070. static readonly INCR_WRAP: number;
  27071. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27072. static readonly DECR_WRAP: number;
  27073. /** Texture is not repeating outside of 0..1 UVs */
  27074. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27075. /** Texture is repeating outside of 0..1 UVs */
  27076. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27077. /** Texture is repeating and mirrored */
  27078. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27079. /** ALPHA */
  27080. static readonly TEXTUREFORMAT_ALPHA: number;
  27081. /** LUMINANCE */
  27082. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27083. /** LUMINANCE_ALPHA */
  27084. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27085. /** RGB */
  27086. static readonly TEXTUREFORMAT_RGB: number;
  27087. /** RGBA */
  27088. static readonly TEXTUREFORMAT_RGBA: number;
  27089. /** RED */
  27090. static readonly TEXTUREFORMAT_RED: number;
  27091. /** RED (2nd reference) */
  27092. static readonly TEXTUREFORMAT_R: number;
  27093. /** RG */
  27094. static readonly TEXTUREFORMAT_RG: number;
  27095. /** RED_INTEGER */
  27096. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27097. /** RED_INTEGER (2nd reference) */
  27098. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27099. /** RG_INTEGER */
  27100. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27101. /** RGB_INTEGER */
  27102. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27103. /** RGBA_INTEGER */
  27104. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27105. /** UNSIGNED_BYTE */
  27106. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27107. /** UNSIGNED_BYTE (2nd reference) */
  27108. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27109. /** FLOAT */
  27110. static readonly TEXTURETYPE_FLOAT: number;
  27111. /** HALF_FLOAT */
  27112. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27113. /** BYTE */
  27114. static readonly TEXTURETYPE_BYTE: number;
  27115. /** SHORT */
  27116. static readonly TEXTURETYPE_SHORT: number;
  27117. /** UNSIGNED_SHORT */
  27118. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27119. /** INT */
  27120. static readonly TEXTURETYPE_INT: number;
  27121. /** UNSIGNED_INT */
  27122. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27123. /** UNSIGNED_SHORT_4_4_4_4 */
  27124. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27125. /** UNSIGNED_SHORT_5_5_5_1 */
  27126. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27127. /** UNSIGNED_SHORT_5_6_5 */
  27128. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27129. /** UNSIGNED_INT_2_10_10_10_REV */
  27130. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27131. /** UNSIGNED_INT_24_8 */
  27132. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27133. /** UNSIGNED_INT_10F_11F_11F_REV */
  27134. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27135. /** UNSIGNED_INT_5_9_9_9_REV */
  27136. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27137. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27138. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27139. /** nearest is mag = nearest and min = nearest and mip = linear */
  27140. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27141. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27142. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27143. /** Trilinear is mag = linear and min = linear and mip = linear */
  27144. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27145. /** nearest is mag = nearest and min = nearest and mip = linear */
  27146. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27147. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27148. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27149. /** Trilinear is mag = linear and min = linear and mip = linear */
  27150. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27151. /** mag = nearest and min = nearest and mip = nearest */
  27152. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27153. /** mag = nearest and min = linear and mip = nearest */
  27154. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27155. /** mag = nearest and min = linear and mip = linear */
  27156. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27157. /** mag = nearest and min = linear and mip = none */
  27158. static readonly TEXTURE_NEAREST_LINEAR: number;
  27159. /** mag = nearest and min = nearest and mip = none */
  27160. static readonly TEXTURE_NEAREST_NEAREST: number;
  27161. /** mag = linear and min = nearest and mip = nearest */
  27162. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27163. /** mag = linear and min = nearest and mip = linear */
  27164. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27165. /** mag = linear and min = linear and mip = none */
  27166. static readonly TEXTURE_LINEAR_LINEAR: number;
  27167. /** mag = linear and min = nearest and mip = none */
  27168. static readonly TEXTURE_LINEAR_NEAREST: number;
  27169. /** Explicit coordinates mode */
  27170. static readonly TEXTURE_EXPLICIT_MODE: number;
  27171. /** Spherical coordinates mode */
  27172. static readonly TEXTURE_SPHERICAL_MODE: number;
  27173. /** Planar coordinates mode */
  27174. static readonly TEXTURE_PLANAR_MODE: number;
  27175. /** Cubic coordinates mode */
  27176. static readonly TEXTURE_CUBIC_MODE: number;
  27177. /** Projection coordinates mode */
  27178. static readonly TEXTURE_PROJECTION_MODE: number;
  27179. /** Skybox coordinates mode */
  27180. static readonly TEXTURE_SKYBOX_MODE: number;
  27181. /** Inverse Cubic coordinates mode */
  27182. static readonly TEXTURE_INVCUBIC_MODE: number;
  27183. /** Equirectangular coordinates mode */
  27184. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27185. /** Equirectangular Fixed coordinates mode */
  27186. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27187. /** Equirectangular Fixed Mirrored coordinates mode */
  27188. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27189. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27190. static readonly SCALEMODE_FLOOR: number;
  27191. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27192. static readonly SCALEMODE_NEAREST: number;
  27193. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27194. static readonly SCALEMODE_CEILING: number;
  27195. /**
  27196. * Returns the current version of the framework
  27197. */
  27198. static readonly Version: string;
  27199. /**
  27200. * Returns a string describing the current engine
  27201. */
  27202. readonly description: string;
  27203. /**
  27204. * Gets or sets the epsilon value used by collision engine
  27205. */
  27206. static CollisionsEpsilon: number;
  27207. /**
  27208. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27209. */
  27210. static ShadersRepository: string;
  27211. /**
  27212. * Method called to create the default loading screen.
  27213. * This can be overriden in your own app.
  27214. * @param canvas The rendering canvas element
  27215. * @returns The loading screen
  27216. */
  27217. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27218. /**
  27219. * Method called to create the default rescale post process on each engine.
  27220. */
  27221. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27222. /**
  27223. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27224. */
  27225. forcePOTTextures: boolean;
  27226. /**
  27227. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27228. */
  27229. isFullscreen: boolean;
  27230. /**
  27231. * Gets a boolean indicating if the pointer is currently locked
  27232. */
  27233. isPointerLock: boolean;
  27234. /**
  27235. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27236. */
  27237. cullBackFaces: boolean;
  27238. /**
  27239. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27240. */
  27241. renderEvenInBackground: boolean;
  27242. /**
  27243. * Gets or sets a boolean indicating that cache can be kept between frames
  27244. */
  27245. preventCacheWipeBetweenFrames: boolean;
  27246. /**
  27247. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27248. **/
  27249. enableOfflineSupport: boolean;
  27250. /**
  27251. * 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)
  27252. **/
  27253. disableManifestCheck: boolean;
  27254. /**
  27255. * Gets the list of created scenes
  27256. */
  27257. scenes: Scene[];
  27258. /**
  27259. * Event raised when a new scene is created
  27260. */
  27261. onNewSceneAddedObservable: Observable<Scene>;
  27262. /**
  27263. * Gets the list of created postprocesses
  27264. */
  27265. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27266. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27267. validateShaderPrograms: boolean;
  27268. /**
  27269. * Observable event triggered each time the rendering canvas is resized
  27270. */
  27271. onResizeObservable: Observable<Engine>;
  27272. /**
  27273. * Observable event triggered each time the canvas loses focus
  27274. */
  27275. onCanvasBlurObservable: Observable<Engine>;
  27276. /**
  27277. * Observable event triggered each time the canvas gains focus
  27278. */
  27279. onCanvasFocusObservable: Observable<Engine>;
  27280. /**
  27281. * Observable event triggered each time the canvas receives pointerout event
  27282. */
  27283. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27284. /**
  27285. * Observable event triggered before each texture is initialized
  27286. */
  27287. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27288. private _vrDisplay;
  27289. private _vrSupported;
  27290. private _oldSize;
  27291. private _oldHardwareScaleFactor;
  27292. private _vrExclusivePointerMode;
  27293. private _webVRInitPromise;
  27294. /**
  27295. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27296. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27297. */
  27298. readonly isInVRExclusivePointerMode: boolean;
  27299. /**
  27300. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27301. */
  27302. disableUniformBuffers: boolean;
  27303. /** @hidden */
  27304. _uniformBuffers: UniformBuffer[];
  27305. /**
  27306. * Gets a boolean indicating that the engine supports uniform buffers
  27307. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27308. */
  27309. readonly supportsUniformBuffers: boolean;
  27310. /**
  27311. * Observable raised when the engine begins a new frame
  27312. */
  27313. onBeginFrameObservable: Observable<Engine>;
  27314. /**
  27315. * If set, will be used to request the next animation frame for the render loop
  27316. */
  27317. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27318. /**
  27319. * Observable raised when the engine ends the current frame
  27320. */
  27321. onEndFrameObservable: Observable<Engine>;
  27322. /**
  27323. * Observable raised when the engine is about to compile a shader
  27324. */
  27325. onBeforeShaderCompilationObservable: Observable<Engine>;
  27326. /**
  27327. * Observable raised when the engine has jsut compiled a shader
  27328. */
  27329. onAfterShaderCompilationObservable: Observable<Engine>;
  27330. /** @hidden */
  27331. _gl: WebGLRenderingContext;
  27332. private _renderingCanvas;
  27333. private _windowIsBackground;
  27334. private _webGLVersion;
  27335. /**
  27336. * Gets a boolean indicating that only power of 2 textures are supported
  27337. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27338. */
  27339. readonly needPOTTextures: boolean;
  27340. /** @hidden */
  27341. _badOS: boolean;
  27342. /** @hidden */
  27343. _badDesktopOS: boolean;
  27344. /**
  27345. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27346. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27347. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27348. */
  27349. disableTextureBindingOptimization: boolean;
  27350. /**
  27351. * Gets the audio engine
  27352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27353. * @ignorenaming
  27354. */
  27355. static audioEngine: IAudioEngine;
  27356. /**
  27357. * Default AudioEngine factory responsible of creating the Audio Engine.
  27358. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27359. */
  27360. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27361. /**
  27362. * Default offline support factory responsible of creating a tool used to store data locally.
  27363. * By default, this will create a Database object if the workload has been embedded.
  27364. */
  27365. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27366. private _onFocus;
  27367. private _onBlur;
  27368. private _onCanvasPointerOut;
  27369. private _onCanvasBlur;
  27370. private _onCanvasFocus;
  27371. private _onFullscreenChange;
  27372. private _onPointerLockChange;
  27373. private _onVRDisplayPointerRestricted;
  27374. private _onVRDisplayPointerUnrestricted;
  27375. private _onVrDisplayConnect;
  27376. private _onVrDisplayDisconnect;
  27377. private _onVrDisplayPresentChange;
  27378. /**
  27379. * Observable signaled when VR display mode changes
  27380. */
  27381. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27382. /**
  27383. * Observable signaled when VR request present is complete
  27384. */
  27385. onVRRequestPresentComplete: Observable<boolean>;
  27386. /**
  27387. * Observable signaled when VR request present starts
  27388. */
  27389. onVRRequestPresentStart: Observable<Engine>;
  27390. private _hardwareScalingLevel;
  27391. /** @hidden */
  27392. protected _caps: EngineCapabilities;
  27393. private _pointerLockRequested;
  27394. private _isStencilEnable;
  27395. private _colorWrite;
  27396. private _loadingScreen;
  27397. /** @hidden */
  27398. _drawCalls: PerfCounter;
  27399. /** @hidden */
  27400. _textureCollisions: PerfCounter;
  27401. private _glVersion;
  27402. private _glRenderer;
  27403. private _glVendor;
  27404. private _videoTextureSupported;
  27405. private _renderingQueueLaunched;
  27406. private _activeRenderLoops;
  27407. private _deterministicLockstep;
  27408. private _lockstepMaxSteps;
  27409. /**
  27410. * Observable signaled when a context lost event is raised
  27411. */
  27412. onContextLostObservable: Observable<Engine>;
  27413. /**
  27414. * Observable signaled when a context restored event is raised
  27415. */
  27416. onContextRestoredObservable: Observable<Engine>;
  27417. private _onContextLost;
  27418. private _onContextRestored;
  27419. private _contextWasLost;
  27420. private _doNotHandleContextLost;
  27421. /**
  27422. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27424. */
  27425. doNotHandleContextLost: boolean;
  27426. private _performanceMonitor;
  27427. private _fps;
  27428. private _deltaTime;
  27429. /**
  27430. * Turn this value on if you want to pause FPS computation when in background
  27431. */
  27432. disablePerformanceMonitorInBackground: boolean;
  27433. /**
  27434. * Gets the performance monitor attached to this engine
  27435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27436. */
  27437. readonly performanceMonitor: PerformanceMonitor;
  27438. /** @hidden */
  27439. protected _depthCullingState: _DepthCullingState;
  27440. /** @hidden */
  27441. protected _stencilState: _StencilState;
  27442. /** @hidden */
  27443. protected _alphaState: _AlphaState;
  27444. /** @hidden */
  27445. protected _alphaMode: number;
  27446. protected _internalTexturesCache: InternalTexture[];
  27447. /** @hidden */
  27448. protected _activeChannel: number;
  27449. private _currentTextureChannel;
  27450. /** @hidden */
  27451. protected _boundTexturesCache: {
  27452. [key: string]: Nullable<InternalTexture>;
  27453. };
  27454. /** @hidden */
  27455. protected _currentEffect: Nullable<Effect>;
  27456. /** @hidden */
  27457. protected _currentProgram: Nullable<WebGLProgram>;
  27458. private _compiledEffects;
  27459. private _vertexAttribArraysEnabled;
  27460. /** @hidden */
  27461. protected _cachedViewport: Nullable<Viewport>;
  27462. private _cachedVertexArrayObject;
  27463. /** @hidden */
  27464. protected _cachedVertexBuffers: any;
  27465. /** @hidden */
  27466. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27467. /** @hidden */
  27468. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27469. /** @hidden */
  27470. protected _currentRenderTarget: Nullable<InternalTexture>;
  27471. private _uintIndicesCurrentlySet;
  27472. private _currentBoundBuffer;
  27473. /** @hidden */
  27474. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27475. private _currentBufferPointers;
  27476. private _currentInstanceLocations;
  27477. private _currentInstanceBuffers;
  27478. private _textureUnits;
  27479. private _firstBoundInternalTextureTracker;
  27480. private _lastBoundInternalTextureTracker;
  27481. private _workingCanvas;
  27482. private _workingContext;
  27483. private _rescalePostProcess;
  27484. private _dummyFramebuffer;
  27485. private _externalData;
  27486. private _bindedRenderFunction;
  27487. private _vaoRecordInProgress;
  27488. private _mustWipeVertexAttributes;
  27489. private _emptyTexture;
  27490. private _emptyCubeTexture;
  27491. private _emptyTexture3D;
  27492. /** @hidden */
  27493. _frameHandler: number;
  27494. private _nextFreeTextureSlots;
  27495. private _maxSimultaneousTextures;
  27496. private _activeRequests;
  27497. private _texturesSupported;
  27498. private _textureFormatInUse;
  27499. /**
  27500. * Gets the list of texture formats supported
  27501. */
  27502. readonly texturesSupported: Array<string>;
  27503. /**
  27504. * Gets the list of texture formats in use
  27505. */
  27506. readonly textureFormatInUse: Nullable<string>;
  27507. /**
  27508. * Gets the current viewport
  27509. */
  27510. readonly currentViewport: Nullable<Viewport>;
  27511. /**
  27512. * Gets the default empty texture
  27513. */
  27514. readonly emptyTexture: InternalTexture;
  27515. /**
  27516. * Gets the default empty 3D texture
  27517. */
  27518. readonly emptyTexture3D: InternalTexture;
  27519. /**
  27520. * Gets the default empty cube texture
  27521. */
  27522. readonly emptyCubeTexture: InternalTexture;
  27523. /**
  27524. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27525. */
  27526. readonly premultipliedAlpha: boolean;
  27527. /**
  27528. * Creates a new engine
  27529. * @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
  27530. * @param antialias defines enable antialiasing (default: false)
  27531. * @param options defines further options to be sent to the getContext() function
  27532. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27533. */
  27534. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27535. private _disableTouchAction;
  27536. private _rebuildInternalTextures;
  27537. private _rebuildEffects;
  27538. /**
  27539. * Gets a boolean indicating if all created effects are ready
  27540. * @returns true if all effects are ready
  27541. */
  27542. areAllEffectsReady(): boolean;
  27543. private _rebuildBuffers;
  27544. private _initGLContext;
  27545. /**
  27546. * Gets version of the current webGL context
  27547. */
  27548. readonly webGLVersion: number;
  27549. /**
  27550. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27551. */
  27552. readonly isStencilEnable: boolean;
  27553. private _prepareWorkingCanvas;
  27554. /**
  27555. * Reset the texture cache to empty state
  27556. */
  27557. resetTextureCache(): void;
  27558. /**
  27559. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27561. * @returns true if engine is in deterministic lock step mode
  27562. */
  27563. isDeterministicLockStep(): boolean;
  27564. /**
  27565. * Gets the max steps when engine is running in deterministic lock step
  27566. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27567. * @returns the max steps
  27568. */
  27569. getLockstepMaxSteps(): number;
  27570. /**
  27571. * Gets an object containing information about the current webGL context
  27572. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27573. */
  27574. getGlInfo(): {
  27575. vendor: string;
  27576. renderer: string;
  27577. version: string;
  27578. };
  27579. /**
  27580. * Gets current aspect ratio
  27581. * @param camera defines the camera to use to get the aspect ratio
  27582. * @param useScreen defines if screen size must be used (or the current render target if any)
  27583. * @returns a number defining the aspect ratio
  27584. */
  27585. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27586. /**
  27587. * Gets current screen aspect ratio
  27588. * @returns a number defining the aspect ratio
  27589. */
  27590. getScreenAspectRatio(): number;
  27591. /**
  27592. * Gets the current render width
  27593. * @param useScreen defines if screen size must be used (or the current render target if any)
  27594. * @returns a number defining the current render width
  27595. */
  27596. getRenderWidth(useScreen?: boolean): number;
  27597. /**
  27598. * Gets the current render height
  27599. * @param useScreen defines if screen size must be used (or the current render target if any)
  27600. * @returns a number defining the current render height
  27601. */
  27602. getRenderHeight(useScreen?: boolean): number;
  27603. /**
  27604. * Gets the HTML canvas attached with the current webGL context
  27605. * @returns a HTML canvas
  27606. */
  27607. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27608. /**
  27609. * Gets the client rect of the HTML canvas attached with the current webGL context
  27610. * @returns a client rectanglee
  27611. */
  27612. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27613. /**
  27614. * Defines the hardware scaling level.
  27615. * By default the hardware scaling level is computed from the window device ratio.
  27616. * 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.
  27617. * @param level defines the level to use
  27618. */
  27619. setHardwareScalingLevel(level: number): void;
  27620. /**
  27621. * Gets the current hardware scaling level.
  27622. * By default the hardware scaling level is computed from the window device ratio.
  27623. * 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.
  27624. * @returns a number indicating the current hardware scaling level
  27625. */
  27626. getHardwareScalingLevel(): number;
  27627. /**
  27628. * Gets the list of loaded textures
  27629. * @returns an array containing all loaded textures
  27630. */
  27631. getLoadedTexturesCache(): InternalTexture[];
  27632. /**
  27633. * Gets the object containing all engine capabilities
  27634. * @returns the EngineCapabilities object
  27635. */
  27636. getCaps(): EngineCapabilities;
  27637. /**
  27638. * Gets the current depth function
  27639. * @returns a number defining the depth function
  27640. */
  27641. getDepthFunction(): Nullable<number>;
  27642. /**
  27643. * Sets the current depth function
  27644. * @param depthFunc defines the function to use
  27645. */
  27646. setDepthFunction(depthFunc: number): void;
  27647. /**
  27648. * Sets the current depth function to GREATER
  27649. */
  27650. setDepthFunctionToGreater(): void;
  27651. /**
  27652. * Sets the current depth function to GEQUAL
  27653. */
  27654. setDepthFunctionToGreaterOrEqual(): void;
  27655. /**
  27656. * Sets the current depth function to LESS
  27657. */
  27658. setDepthFunctionToLess(): void;
  27659. /**
  27660. * Sets the current depth function to LEQUAL
  27661. */
  27662. setDepthFunctionToLessOrEqual(): void;
  27663. /**
  27664. * Gets a boolean indicating if stencil buffer is enabled
  27665. * @returns the current stencil buffer state
  27666. */
  27667. getStencilBuffer(): boolean;
  27668. /**
  27669. * Enable or disable the stencil buffer
  27670. * @param enable defines if the stencil buffer must be enabled or disabled
  27671. */
  27672. setStencilBuffer(enable: boolean): void;
  27673. /**
  27674. * Gets the current stencil mask
  27675. * @returns a number defining the new stencil mask to use
  27676. */
  27677. getStencilMask(): number;
  27678. /**
  27679. * Sets the current stencil mask
  27680. * @param mask defines the new stencil mask to use
  27681. */
  27682. setStencilMask(mask: number): void;
  27683. /**
  27684. * Gets the current stencil function
  27685. * @returns a number defining the stencil function to use
  27686. */
  27687. getStencilFunction(): number;
  27688. /**
  27689. * Gets the current stencil reference value
  27690. * @returns a number defining the stencil reference value to use
  27691. */
  27692. getStencilFunctionReference(): number;
  27693. /**
  27694. * Gets the current stencil mask
  27695. * @returns a number defining the stencil mask to use
  27696. */
  27697. getStencilFunctionMask(): number;
  27698. /**
  27699. * Sets the current stencil function
  27700. * @param stencilFunc defines the new stencil function to use
  27701. */
  27702. setStencilFunction(stencilFunc: number): void;
  27703. /**
  27704. * Sets the current stencil reference
  27705. * @param reference defines the new stencil reference to use
  27706. */
  27707. setStencilFunctionReference(reference: number): void;
  27708. /**
  27709. * Sets the current stencil mask
  27710. * @param mask defines the new stencil mask to use
  27711. */
  27712. setStencilFunctionMask(mask: number): void;
  27713. /**
  27714. * Gets the current stencil operation when stencil fails
  27715. * @returns a number defining stencil operation to use when stencil fails
  27716. */
  27717. getStencilOperationFail(): number;
  27718. /**
  27719. * Gets the current stencil operation when depth fails
  27720. * @returns a number defining stencil operation to use when depth fails
  27721. */
  27722. getStencilOperationDepthFail(): number;
  27723. /**
  27724. * Gets the current stencil operation when stencil passes
  27725. * @returns a number defining stencil operation to use when stencil passes
  27726. */
  27727. getStencilOperationPass(): number;
  27728. /**
  27729. * Sets the stencil operation to use when stencil fails
  27730. * @param operation defines the stencil operation to use when stencil fails
  27731. */
  27732. setStencilOperationFail(operation: number): void;
  27733. /**
  27734. * Sets the stencil operation to use when depth fails
  27735. * @param operation defines the stencil operation to use when depth fails
  27736. */
  27737. setStencilOperationDepthFail(operation: number): void;
  27738. /**
  27739. * Sets the stencil operation to use when stencil passes
  27740. * @param operation defines the stencil operation to use when stencil passes
  27741. */
  27742. setStencilOperationPass(operation: number): void;
  27743. /**
  27744. * Sets a boolean indicating if the dithering state is enabled or disabled
  27745. * @param value defines the dithering state
  27746. */
  27747. setDitheringState(value: boolean): void;
  27748. /**
  27749. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27750. * @param value defines the rasterizer state
  27751. */
  27752. setRasterizerState(value: boolean): void;
  27753. /**
  27754. * stop executing a render loop function and remove it from the execution array
  27755. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27756. */
  27757. stopRenderLoop(renderFunction?: () => void): void;
  27758. /** @hidden */
  27759. _renderLoop(): void;
  27760. /**
  27761. * Register and execute a render loop. The engine can have more than one render function
  27762. * @param renderFunction defines the function to continuously execute
  27763. */
  27764. runRenderLoop(renderFunction: () => void): void;
  27765. /**
  27766. * Toggle full screen mode
  27767. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27768. */
  27769. switchFullscreen(requestPointerLock: boolean): void;
  27770. /**
  27771. * Enters full screen mode
  27772. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27773. */
  27774. enterFullscreen(requestPointerLock: boolean): void;
  27775. /**
  27776. * Exits full screen mode
  27777. */
  27778. exitFullscreen(): void;
  27779. /**
  27780. * Clear the current render buffer or the current render target (if any is set up)
  27781. * @param color defines the color to use
  27782. * @param backBuffer defines if the back buffer must be cleared
  27783. * @param depth defines if the depth buffer must be cleared
  27784. * @param stencil defines if the stencil buffer must be cleared
  27785. */
  27786. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27787. /**
  27788. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27789. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27790. * @param y defines the y-coordinate of the corner of the clear rectangle
  27791. * @param width defines the width of the clear rectangle
  27792. * @param height defines the height of the clear rectangle
  27793. * @param clearColor defines the clear color
  27794. */
  27795. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27796. /**
  27797. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27798. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27799. * @param y defines the y-coordinate of the corner of the clear rectangle
  27800. * @param width defines the width of the clear rectangle
  27801. * @param height defines the height of the clear rectangle
  27802. */
  27803. enableScissor(x: number, y: number, width: number, height: number): void;
  27804. /**
  27805. * Disable previously set scissor test rectangle
  27806. */
  27807. disableScissor(): void;
  27808. private _viewportCached;
  27809. /** @hidden */
  27810. _viewport(x: number, y: number, width: number, height: number): void;
  27811. /**
  27812. * Set the WebGL's viewport
  27813. * @param viewport defines the viewport element to be used
  27814. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27815. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27816. */
  27817. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27818. /**
  27819. * Directly set the WebGL Viewport
  27820. * @param x defines the x coordinate of the viewport (in screen space)
  27821. * @param y defines the y coordinate of the viewport (in screen space)
  27822. * @param width defines the width of the viewport (in screen space)
  27823. * @param height defines the height of the viewport (in screen space)
  27824. * @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
  27825. */
  27826. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27827. /**
  27828. * Begin a new frame
  27829. */
  27830. beginFrame(): void;
  27831. /**
  27832. * Enf the current frame
  27833. */
  27834. endFrame(): void;
  27835. /**
  27836. * Resize the view according to the canvas' size
  27837. */
  27838. resize(): void;
  27839. /**
  27840. * Force a specific size of the canvas
  27841. * @param width defines the new canvas' width
  27842. * @param height defines the new canvas' height
  27843. */
  27844. setSize(width: number, height: number): void;
  27845. /**
  27846. * Gets a boolean indicating if a webVR device was detected
  27847. * @returns true if a webVR device was detected
  27848. */
  27849. isVRDevicePresent(): boolean;
  27850. /**
  27851. * Gets the current webVR device
  27852. * @returns the current webVR device (or null)
  27853. */
  27854. getVRDevice(): any;
  27855. /**
  27856. * Initializes a webVR display and starts listening to display change events
  27857. * The onVRDisplayChangedObservable will be notified upon these changes
  27858. * @returns The onVRDisplayChangedObservable
  27859. */
  27860. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27861. /**
  27862. * Initializes a webVR display and starts listening to display change events
  27863. * The onVRDisplayChangedObservable will be notified upon these changes
  27864. * @returns A promise containing a VRDisplay and if vr is supported
  27865. */
  27866. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27867. /**
  27868. * Call this function to switch to webVR mode
  27869. * Will do nothing if webVR is not supported or if there is no webVR device
  27870. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27871. */
  27872. enableVR(): void;
  27873. /**
  27874. * Call this function to leave webVR mode
  27875. * Will do nothing if webVR is not supported or if there is no webVR device
  27876. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27877. */
  27878. disableVR(): void;
  27879. private _onVRFullScreenTriggered;
  27880. private _getVRDisplaysAsync;
  27881. /**
  27882. * Binds the frame buffer to the specified texture.
  27883. * @param texture The texture to render to or null for the default canvas
  27884. * @param faceIndex The face of the texture to render to in case of cube texture
  27885. * @param requiredWidth The width of the target to render to
  27886. * @param requiredHeight The height of the target to render to
  27887. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27888. * @param depthStencilTexture The depth stencil texture to use to render
  27889. * @param lodLevel defines le lod level to bind to the frame buffer
  27890. */
  27891. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27892. private bindUnboundFramebuffer;
  27893. /**
  27894. * Unbind the current render target texture from the webGL context
  27895. * @param texture defines the render target texture to unbind
  27896. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27897. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27898. */
  27899. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27900. /**
  27901. * Unbind a list of render target textures from the webGL context
  27902. * This is used only when drawBuffer extension or webGL2 are active
  27903. * @param textures defines the render target textures to unbind
  27904. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27905. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27906. */
  27907. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27908. /**
  27909. * Force the mipmap generation for the given render target texture
  27910. * @param texture defines the render target texture to use
  27911. */
  27912. generateMipMapsForCubemap(texture: InternalTexture): void;
  27913. /**
  27914. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27915. */
  27916. flushFramebuffer(): void;
  27917. /**
  27918. * Unbind the current render target and bind the default framebuffer
  27919. */
  27920. restoreDefaultFramebuffer(): void;
  27921. /**
  27922. * Create an uniform buffer
  27923. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27924. * @param elements defines the content of the uniform buffer
  27925. * @returns the webGL uniform buffer
  27926. */
  27927. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27928. /**
  27929. * Create a dynamic uniform buffer
  27930. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27931. * @param elements defines the content of the uniform buffer
  27932. * @returns the webGL uniform buffer
  27933. */
  27934. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27935. /**
  27936. * Update an existing uniform buffer
  27937. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27938. * @param uniformBuffer defines the target uniform buffer
  27939. * @param elements defines the content to update
  27940. * @param offset defines the offset in the uniform buffer where update should start
  27941. * @param count defines the size of the data to update
  27942. */
  27943. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27944. private _resetVertexBufferBinding;
  27945. /**
  27946. * Creates a vertex buffer
  27947. * @param data the data for the vertex buffer
  27948. * @returns the new WebGL static buffer
  27949. */
  27950. createVertexBuffer(data: DataArray): WebGLBuffer;
  27951. /**
  27952. * Creates a dynamic vertex buffer
  27953. * @param data the data for the dynamic vertex buffer
  27954. * @returns the new WebGL dynamic buffer
  27955. */
  27956. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27957. /**
  27958. * Update a dynamic index buffer
  27959. * @param indexBuffer defines the target index buffer
  27960. * @param indices defines the data to update
  27961. * @param offset defines the offset in the target index buffer where update should start
  27962. */
  27963. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27964. /**
  27965. * Updates a dynamic vertex buffer.
  27966. * @param vertexBuffer the vertex buffer to update
  27967. * @param data the data used to update the vertex buffer
  27968. * @param byteOffset the byte offset of the data
  27969. * @param byteLength the byte length of the data
  27970. */
  27971. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27972. private _resetIndexBufferBinding;
  27973. /**
  27974. * Creates a new index buffer
  27975. * @param indices defines the content of the index buffer
  27976. * @param updatable defines if the index buffer must be updatable
  27977. * @returns a new webGL buffer
  27978. */
  27979. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27980. /**
  27981. * Bind a webGL buffer to the webGL context
  27982. * @param buffer defines the buffer to bind
  27983. */
  27984. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27985. /**
  27986. * Bind an uniform buffer to the current webGL context
  27987. * @param buffer defines the buffer to bind
  27988. */
  27989. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27990. /**
  27991. * Bind a buffer to the current webGL context at a given location
  27992. * @param buffer defines the buffer to bind
  27993. * @param location defines the index where to bind the buffer
  27994. */
  27995. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27996. /**
  27997. * Bind a specific block at a given index in a specific shader program
  27998. * @param shaderProgram defines the shader program
  27999. * @param blockName defines the block name
  28000. * @param index defines the index where to bind the block
  28001. */
  28002. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28003. private bindIndexBuffer;
  28004. private bindBuffer;
  28005. /**
  28006. * update the bound buffer with the given data
  28007. * @param data defines the data to update
  28008. */
  28009. updateArrayBuffer(data: Float32Array): void;
  28010. private _vertexAttribPointer;
  28011. private _bindIndexBufferWithCache;
  28012. private _bindVertexBuffersAttributes;
  28013. /**
  28014. * Records a vertex array object
  28015. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28016. * @param vertexBuffers defines the list of vertex buffers to store
  28017. * @param indexBuffer defines the index buffer to store
  28018. * @param effect defines the effect to store
  28019. * @returns the new vertex array object
  28020. */
  28021. recordVertexArrayObject(vertexBuffers: {
  28022. [key: string]: VertexBuffer;
  28023. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28024. /**
  28025. * Bind a specific vertex array object
  28026. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28027. * @param vertexArrayObject defines the vertex array object to bind
  28028. * @param indexBuffer defines the index buffer to bind
  28029. */
  28030. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28031. /**
  28032. * Bind webGl buffers directly to the webGL context
  28033. * @param vertexBuffer defines the vertex buffer to bind
  28034. * @param indexBuffer defines the index buffer to bind
  28035. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28036. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28037. * @param effect defines the effect associated with the vertex buffer
  28038. */
  28039. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28040. private _unbindVertexArrayObject;
  28041. /**
  28042. * Bind a list of vertex buffers to the webGL context
  28043. * @param vertexBuffers defines the list of vertex buffers to bind
  28044. * @param indexBuffer defines the index buffer to bind
  28045. * @param effect defines the effect associated with the vertex buffers
  28046. */
  28047. bindBuffers(vertexBuffers: {
  28048. [key: string]: Nullable<VertexBuffer>;
  28049. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28050. /**
  28051. * Unbind all instance attributes
  28052. */
  28053. unbindInstanceAttributes(): void;
  28054. /**
  28055. * Release and free the memory of a vertex array object
  28056. * @param vao defines the vertex array object to delete
  28057. */
  28058. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28059. /** @hidden */
  28060. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28061. /**
  28062. * Creates a webGL buffer to use with instanciation
  28063. * @param capacity defines the size of the buffer
  28064. * @returns the webGL buffer
  28065. */
  28066. createInstancesBuffer(capacity: number): WebGLBuffer;
  28067. /**
  28068. * Delete a webGL buffer used with instanciation
  28069. * @param buffer defines the webGL buffer to delete
  28070. */
  28071. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28072. /**
  28073. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28074. * @param instancesBuffer defines the webGL buffer to update and bind
  28075. * @param data defines the data to store in the buffer
  28076. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28077. */
  28078. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28079. /**
  28080. * Apply all cached states (depth, culling, stencil and alpha)
  28081. */
  28082. applyStates(): void;
  28083. /**
  28084. * Send a draw order
  28085. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28086. * @param indexStart defines the starting index
  28087. * @param indexCount defines the number of index to draw
  28088. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28089. */
  28090. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28091. /**
  28092. * Draw a list of points
  28093. * @param verticesStart defines the index of first vertex to draw
  28094. * @param verticesCount defines the count of vertices to draw
  28095. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28096. */
  28097. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28098. /**
  28099. * Draw a list of unindexed primitives
  28100. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28101. * @param verticesStart defines the index of first vertex to draw
  28102. * @param verticesCount defines the count of vertices to draw
  28103. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28104. */
  28105. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28106. /**
  28107. * Draw a list of indexed primitives
  28108. * @param fillMode defines the primitive to use
  28109. * @param indexStart defines the starting index
  28110. * @param indexCount defines the number of index to draw
  28111. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28112. */
  28113. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28114. /**
  28115. * Draw a list of unindexed primitives
  28116. * @param fillMode defines the primitive to use
  28117. * @param verticesStart defines the index of first vertex to draw
  28118. * @param verticesCount defines the count of vertices to draw
  28119. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28120. */
  28121. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28122. private _drawMode;
  28123. /** @hidden */
  28124. _releaseEffect(effect: Effect): void;
  28125. /** @hidden */
  28126. _deleteProgram(program: WebGLProgram): void;
  28127. /**
  28128. * Create a new effect (used to store vertex/fragment shaders)
  28129. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28130. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28131. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28132. * @param samplers defines an array of string used to represent textures
  28133. * @param defines defines the string containing the defines to use to compile the shaders
  28134. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28135. * @param onCompiled defines a function to call when the effect creation is successful
  28136. * @param onError defines a function to call when the effect creation has failed
  28137. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28138. * @returns the new Effect
  28139. */
  28140. 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;
  28141. private _compileShader;
  28142. private _compileRawShader;
  28143. /**
  28144. * Directly creates a webGL program
  28145. * @param vertexCode defines the vertex shader code to use
  28146. * @param fragmentCode defines the fragment shader code to use
  28147. * @param context defines the webGL context to use (if not set, the current one will be used)
  28148. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28149. * @returns the new webGL program
  28150. */
  28151. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28152. /**
  28153. * Creates a webGL program
  28154. * @param vertexCode defines the vertex shader code to use
  28155. * @param fragmentCode defines the fragment shader code to use
  28156. * @param defines defines the string containing the defines to use to compile the shaders
  28157. * @param context defines the webGL context to use (if not set, the current one will be used)
  28158. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28159. * @returns the new webGL program
  28160. */
  28161. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28162. private _createShaderProgram;
  28163. private _finalizeProgram;
  28164. /** @hidden */
  28165. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28166. /** @hidden */
  28167. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28168. /**
  28169. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28170. * @param shaderProgram defines the webGL program to use
  28171. * @param uniformsNames defines the list of uniform names
  28172. * @returns an array of webGL uniform locations
  28173. */
  28174. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28175. /**
  28176. * Gets the lsit of active attributes for a given webGL program
  28177. * @param shaderProgram defines the webGL program to use
  28178. * @param attributesNames defines the list of attribute names to get
  28179. * @returns an array of indices indicating the offset of each attribute
  28180. */
  28181. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28182. /**
  28183. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28184. * @param effect defines the effect to activate
  28185. */
  28186. enableEffect(effect: Nullable<Effect>): void;
  28187. /**
  28188. * Set the value of an uniform to an array of int32
  28189. * @param uniform defines the webGL uniform location where to store the value
  28190. * @param array defines the array of int32 to store
  28191. */
  28192. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28193. /**
  28194. * Set the value of an uniform to an array of int32 (stored as vec2)
  28195. * @param uniform defines the webGL uniform location where to store the value
  28196. * @param array defines the array of int32 to store
  28197. */
  28198. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28199. /**
  28200. * Set the value of an uniform to an array of int32 (stored as vec3)
  28201. * @param uniform defines the webGL uniform location where to store the value
  28202. * @param array defines the array of int32 to store
  28203. */
  28204. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28205. /**
  28206. * Set the value of an uniform to an array of int32 (stored as vec4)
  28207. * @param uniform defines the webGL uniform location where to store the value
  28208. * @param array defines the array of int32 to store
  28209. */
  28210. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28211. /**
  28212. * Set the value of an uniform to an array of float32
  28213. * @param uniform defines the webGL uniform location where to store the value
  28214. * @param array defines the array of float32 to store
  28215. */
  28216. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28217. /**
  28218. * Set the value of an uniform to an array of float32 (stored as vec2)
  28219. * @param uniform defines the webGL uniform location where to store the value
  28220. * @param array defines the array of float32 to store
  28221. */
  28222. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28223. /**
  28224. * Set the value of an uniform to an array of float32 (stored as vec3)
  28225. * @param uniform defines the webGL uniform location where to store the value
  28226. * @param array defines the array of float32 to store
  28227. */
  28228. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28229. /**
  28230. * Set the value of an uniform to an array of float32 (stored as vec4)
  28231. * @param uniform defines the webGL uniform location where to store the value
  28232. * @param array defines the array of float32 to store
  28233. */
  28234. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28235. /**
  28236. * Set the value of an uniform to an array of number
  28237. * @param uniform defines the webGL uniform location where to store the value
  28238. * @param array defines the array of number to store
  28239. */
  28240. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28241. /**
  28242. * Set the value of an uniform to an array of number (stored as vec2)
  28243. * @param uniform defines the webGL uniform location where to store the value
  28244. * @param array defines the array of number to store
  28245. */
  28246. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28247. /**
  28248. * Set the value of an uniform to an array of number (stored as vec3)
  28249. * @param uniform defines the webGL uniform location where to store the value
  28250. * @param array defines the array of number to store
  28251. */
  28252. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28253. /**
  28254. * Set the value of an uniform to an array of number (stored as vec4)
  28255. * @param uniform defines the webGL uniform location where to store the value
  28256. * @param array defines the array of number to store
  28257. */
  28258. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28259. /**
  28260. * Set the value of an uniform to an array of float32 (stored as matrices)
  28261. * @param uniform defines the webGL uniform location where to store the value
  28262. * @param matrices defines the array of float32 to store
  28263. */
  28264. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28265. /**
  28266. * Set the value of an uniform to a matrix
  28267. * @param uniform defines the webGL uniform location where to store the value
  28268. * @param matrix defines the matrix to store
  28269. */
  28270. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28271. /**
  28272. * Set the value of an uniform to a matrix (3x3)
  28273. * @param uniform defines the webGL uniform location where to store the value
  28274. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28275. */
  28276. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28277. /**
  28278. * Set the value of an uniform to a matrix (2x2)
  28279. * @param uniform defines the webGL uniform location where to store the value
  28280. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28281. */
  28282. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28283. /**
  28284. * Set the value of an uniform to a number (int)
  28285. * @param uniform defines the webGL uniform location where to store the value
  28286. * @param value defines the int number to store
  28287. */
  28288. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28289. /**
  28290. * Set the value of an uniform to a number (float)
  28291. * @param uniform defines the webGL uniform location where to store the value
  28292. * @param value defines the float number to store
  28293. */
  28294. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28295. /**
  28296. * Set the value of an uniform to a vec2
  28297. * @param uniform defines the webGL uniform location where to store the value
  28298. * @param x defines the 1st component of the value
  28299. * @param y defines the 2nd component of the value
  28300. */
  28301. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28302. /**
  28303. * Set the value of an uniform to a vec3
  28304. * @param uniform defines the webGL uniform location where to store the value
  28305. * @param x defines the 1st component of the value
  28306. * @param y defines the 2nd component of the value
  28307. * @param z defines the 3rd component of the value
  28308. */
  28309. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28310. /**
  28311. * Set the value of an uniform to a boolean
  28312. * @param uniform defines the webGL uniform location where to store the value
  28313. * @param bool defines the boolean to store
  28314. */
  28315. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28316. /**
  28317. * Set the value of an uniform to a vec4
  28318. * @param uniform defines the webGL uniform location where to store the value
  28319. * @param x defines the 1st component of the value
  28320. * @param y defines the 2nd component of the value
  28321. * @param z defines the 3rd component of the value
  28322. * @param w defines the 4th component of the value
  28323. */
  28324. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28325. /**
  28326. * Set the value of an uniform to a Color3
  28327. * @param uniform defines the webGL uniform location where to store the value
  28328. * @param color3 defines the color to store
  28329. */
  28330. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28331. /**
  28332. * Set the value of an uniform to a Color3 and an alpha value
  28333. * @param uniform defines the webGL uniform location where to store the value
  28334. * @param color3 defines the color to store
  28335. * @param alpha defines the alpha component to store
  28336. */
  28337. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28338. /**
  28339. * Sets a Color4 on a uniform variable
  28340. * @param uniform defines the uniform location
  28341. * @param color4 defines the value to be set
  28342. */
  28343. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28344. /**
  28345. * Set various states to the webGL context
  28346. * @param culling defines backface culling state
  28347. * @param zOffset defines the value to apply to zOffset (0 by default)
  28348. * @param force defines if states must be applied even if cache is up to date
  28349. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28350. */
  28351. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28352. /**
  28353. * Set the z offset to apply to current rendering
  28354. * @param value defines the offset to apply
  28355. */
  28356. setZOffset(value: number): void;
  28357. /**
  28358. * Gets the current value of the zOffset
  28359. * @returns the current zOffset state
  28360. */
  28361. getZOffset(): number;
  28362. /**
  28363. * Enable or disable depth buffering
  28364. * @param enable defines the state to set
  28365. */
  28366. setDepthBuffer(enable: boolean): void;
  28367. /**
  28368. * Gets a boolean indicating if depth writing is enabled
  28369. * @returns the current depth writing state
  28370. */
  28371. getDepthWrite(): boolean;
  28372. /**
  28373. * Enable or disable depth writing
  28374. * @param enable defines the state to set
  28375. */
  28376. setDepthWrite(enable: boolean): void;
  28377. /**
  28378. * Enable or disable color writing
  28379. * @param enable defines the state to set
  28380. */
  28381. setColorWrite(enable: boolean): void;
  28382. /**
  28383. * Gets a boolean indicating if color writing is enabled
  28384. * @returns the current color writing state
  28385. */
  28386. getColorWrite(): boolean;
  28387. /**
  28388. * Sets alpha constants used by some alpha blending modes
  28389. * @param r defines the red component
  28390. * @param g defines the green component
  28391. * @param b defines the blue component
  28392. * @param a defines the alpha component
  28393. */
  28394. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28395. /**
  28396. * Sets the current alpha mode
  28397. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28398. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28399. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28400. */
  28401. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28402. /**
  28403. * Gets the current alpha mode
  28404. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28405. * @returns the current alpha mode
  28406. */
  28407. getAlphaMode(): number;
  28408. /**
  28409. * Clears the list of texture accessible through engine.
  28410. * This can help preventing texture load conflict due to name collision.
  28411. */
  28412. clearInternalTexturesCache(): void;
  28413. /**
  28414. * Force the entire cache to be cleared
  28415. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28416. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28417. */
  28418. wipeCaches(bruteForce?: boolean): void;
  28419. /**
  28420. * Set the compressed texture format to use, based on the formats you have, and the formats
  28421. * supported by the hardware / browser.
  28422. *
  28423. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28424. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28425. * to API arguments needed to compressed textures. This puts the burden on the container
  28426. * generator to house the arcane code for determining these for current & future formats.
  28427. *
  28428. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28429. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28430. *
  28431. * Note: The result of this call is not taken into account when a texture is base64.
  28432. *
  28433. * @param formatsAvailable defines the list of those format families you have created
  28434. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28435. *
  28436. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28437. * @returns The extension selected.
  28438. */
  28439. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28440. private _getSamplingParameters;
  28441. private _partialLoadImg;
  28442. private _cascadeLoadImgs;
  28443. /** @hidden */
  28444. _createTexture(): WebGLTexture;
  28445. /**
  28446. * Usually called from Texture.ts.
  28447. * Passed information to create a WebGLTexture
  28448. * @param urlArg defines a value which contains one of the following:
  28449. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28450. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28451. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28452. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28453. * @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)
  28454. * @param scene needed for loading to the correct scene
  28455. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28456. * @param onLoad optional callback to be called upon successful completion
  28457. * @param onError optional callback to be called upon failure
  28458. * @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
  28459. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28460. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28461. * @param forcedExtension defines the extension to use to pick the right loader
  28462. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28463. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28464. */
  28465. 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;
  28466. private _rescaleTexture;
  28467. /**
  28468. * Update a raw texture
  28469. * @param texture defines the texture to update
  28470. * @param data defines the data to store in the texture
  28471. * @param format defines the format of the data
  28472. * @param invertY defines if data must be stored with Y axis inverted
  28473. * @param compression defines the compression used (null by default)
  28474. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28475. */
  28476. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28477. /**
  28478. * Creates a raw texture
  28479. * @param data defines the data to store in the texture
  28480. * @param width defines the width of the texture
  28481. * @param height defines the height of the texture
  28482. * @param format defines the format of the data
  28483. * @param generateMipMaps defines if the engine should generate the mip levels
  28484. * @param invertY defines if data must be stored with Y axis inverted
  28485. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28486. * @param compression defines the compression used (null by default)
  28487. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28488. * @returns the raw texture inside an InternalTexture
  28489. */
  28490. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28491. private _unpackFlipYCached;
  28492. /**
  28493. * In case you are sharing the context with other applications, it might
  28494. * be interested to not cache the unpack flip y state to ensure a consistent
  28495. * value would be set.
  28496. */
  28497. enableUnpackFlipYCached: boolean;
  28498. /** @hidden */
  28499. _unpackFlipY(value: boolean): void;
  28500. /** @hidden */
  28501. _getUnpackAlignement(): number;
  28502. /**
  28503. * Creates a dynamic texture
  28504. * @param width defines the width of the texture
  28505. * @param height defines the height of the texture
  28506. * @param generateMipMaps defines if the engine should generate the mip levels
  28507. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28508. * @returns the dynamic texture inside an InternalTexture
  28509. */
  28510. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28511. /**
  28512. * Update the sampling mode of a given texture
  28513. * @param samplingMode defines the required sampling mode
  28514. * @param texture defines the texture to update
  28515. */
  28516. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28517. /**
  28518. * Update the content of a dynamic texture
  28519. * @param texture defines the texture to update
  28520. * @param canvas defines the canvas containing the source
  28521. * @param invertY defines if data must be stored with Y axis inverted
  28522. * @param premulAlpha defines if alpha is stored as premultiplied
  28523. * @param format defines the format of the data
  28524. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28525. */
  28526. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28527. /**
  28528. * Update a video texture
  28529. * @param texture defines the texture to update
  28530. * @param video defines the video element to use
  28531. * @param invertY defines if data must be stored with Y axis inverted
  28532. */
  28533. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28534. /**
  28535. * Updates a depth texture Comparison Mode and Function.
  28536. * If the comparison Function is equal to 0, the mode will be set to none.
  28537. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28538. * @param texture The texture to set the comparison function for
  28539. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28540. */
  28541. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28542. private _setupDepthStencilTexture;
  28543. /**
  28544. * Creates a depth stencil texture.
  28545. * This is only available in WebGL 2 or with the depth texture extension available.
  28546. * @param size The size of face edge in the texture.
  28547. * @param options The options defining the texture.
  28548. * @returns The texture
  28549. */
  28550. createDepthStencilTexture(size: number | {
  28551. width: number;
  28552. height: number;
  28553. }, options: DepthTextureCreationOptions): InternalTexture;
  28554. /**
  28555. * Creates a depth stencil texture.
  28556. * This is only available in WebGL 2 or with the depth texture extension available.
  28557. * @param size The size of face edge in the texture.
  28558. * @param options The options defining the texture.
  28559. * @returns The texture
  28560. */
  28561. private _createDepthStencilTexture;
  28562. /**
  28563. * Creates a depth stencil cube texture.
  28564. * This is only available in WebGL 2.
  28565. * @param size The size of face edge in the cube texture.
  28566. * @param options The options defining the cube texture.
  28567. * @returns The cube texture
  28568. */
  28569. private _createDepthStencilCubeTexture;
  28570. /**
  28571. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28572. * @param renderTarget The render target to set the frame buffer for
  28573. */
  28574. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28575. /**
  28576. * Creates a new render target texture
  28577. * @param size defines the size of the texture
  28578. * @param options defines the options used to create the texture
  28579. * @returns a new render target texture stored in an InternalTexture
  28580. */
  28581. createRenderTargetTexture(size: number | {
  28582. width: number;
  28583. height: number;
  28584. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28585. /**
  28586. * Create a multi render target texture
  28587. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28588. * @param size defines the size of the texture
  28589. * @param options defines the creation options
  28590. * @returns the cube texture as an InternalTexture
  28591. */
  28592. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28593. private _setupFramebufferDepthAttachments;
  28594. /**
  28595. * Updates the sample count of a render target texture
  28596. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28597. * @param texture defines the texture to update
  28598. * @param samples defines the sample count to set
  28599. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28600. */
  28601. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28602. /**
  28603. * Update the sample count for a given multiple render target texture
  28604. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28605. * @param textures defines the textures to update
  28606. * @param samples defines the sample count to set
  28607. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28608. */
  28609. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28610. /** @hidden */
  28611. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28612. /** @hidden */
  28613. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28614. /** @hidden */
  28615. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28616. /** @hidden */
  28617. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28618. /**
  28619. * Creates a new render target cube texture
  28620. * @param size defines the size of the texture
  28621. * @param options defines the options used to create the texture
  28622. * @returns a new render target cube texture stored in an InternalTexture
  28623. */
  28624. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28625. /**
  28626. * Creates a cube texture
  28627. * @param rootUrl defines the url where the files to load is located
  28628. * @param scene defines the current scene
  28629. * @param files defines the list of files to load (1 per face)
  28630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28631. * @param onLoad defines an optional callback raised when the texture is loaded
  28632. * @param onError defines an optional callback raised if there is an issue to load the texture
  28633. * @param format defines the format of the data
  28634. * @param forcedExtension defines the extension to use to pick the right loader
  28635. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28636. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28637. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28638. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28639. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28640. * @returns the cube texture as an InternalTexture
  28641. */
  28642. 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;
  28643. /**
  28644. * @hidden
  28645. */
  28646. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28647. /**
  28648. * Update a raw cube texture
  28649. * @param texture defines the texture to udpdate
  28650. * @param data defines the data to store
  28651. * @param format defines the data format
  28652. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28653. * @param invertY defines if data must be stored with Y axis inverted
  28654. * @param compression defines the compression used (null by default)
  28655. * @param level defines which level of the texture to update
  28656. */
  28657. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28658. /**
  28659. * Creates a new raw cube texture
  28660. * @param data defines the array of data to use to create each face
  28661. * @param size defines the size of the textures
  28662. * @param format defines the format of the data
  28663. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28664. * @param generateMipMaps defines if the engine should generate the mip levels
  28665. * @param invertY defines if data must be stored with Y axis inverted
  28666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28667. * @param compression defines the compression used (null by default)
  28668. * @returns the cube texture as an InternalTexture
  28669. */
  28670. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28671. /**
  28672. * Creates a new raw cube texture from a specified url
  28673. * @param url defines the url where the data is located
  28674. * @param scene defines the current scene
  28675. * @param size defines the size of the textures
  28676. * @param format defines the format of the data
  28677. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28678. * @param noMipmap defines if the engine should avoid generating the mip levels
  28679. * @param callback defines a callback used to extract texture data from loaded data
  28680. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28681. * @param onLoad defines a callback called when texture is loaded
  28682. * @param onError defines a callback called if there is an error
  28683. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28684. * @param invertY defines if data must be stored with Y axis inverted
  28685. * @returns the cube texture as an InternalTexture
  28686. */
  28687. 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;
  28688. /**
  28689. * Update a raw 3D texture
  28690. * @param texture defines the texture to update
  28691. * @param data defines the data to store
  28692. * @param format defines the data format
  28693. * @param invertY defines if data must be stored with Y axis inverted
  28694. * @param compression defines the used compression (can be null)
  28695. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28696. */
  28697. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28698. /**
  28699. * Creates a new raw 3D texture
  28700. * @param data defines the data used to create the texture
  28701. * @param width defines the width of the texture
  28702. * @param height defines the height of the texture
  28703. * @param depth defines the depth of the texture
  28704. * @param format defines the format of the texture
  28705. * @param generateMipMaps defines if the engine must generate mip levels
  28706. * @param invertY defines if data must be stored with Y axis inverted
  28707. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28708. * @param compression defines the compressed used (can be null)
  28709. * @param textureType defines the compressed used (can be null)
  28710. * @returns a new raw 3D texture (stored in an InternalTexture)
  28711. */
  28712. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28713. private _prepareWebGLTextureContinuation;
  28714. private _prepareWebGLTexture;
  28715. private _convertRGBtoRGBATextureData;
  28716. /** @hidden */
  28717. _releaseFramebufferObjects(texture: InternalTexture): void;
  28718. /** @hidden */
  28719. _releaseTexture(texture: InternalTexture): void;
  28720. private setProgram;
  28721. private _boundUniforms;
  28722. /**
  28723. * Binds an effect to the webGL context
  28724. * @param effect defines the effect to bind
  28725. */
  28726. bindSamplers(effect: Effect): void;
  28727. private _moveBoundTextureOnTop;
  28728. private _getCorrectTextureChannel;
  28729. private _linkTrackers;
  28730. private _removeDesignatedSlot;
  28731. private _activateCurrentTexture;
  28732. /** @hidden */
  28733. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28734. /** @hidden */
  28735. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28736. /**
  28737. * Sets a texture to the webGL context from a postprocess
  28738. * @param channel defines the channel to use
  28739. * @param postProcess defines the source postprocess
  28740. */
  28741. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28742. /**
  28743. * Binds the output of the passed in post process to the texture channel specified
  28744. * @param channel The channel the texture should be bound to
  28745. * @param postProcess The post process which's output should be bound
  28746. */
  28747. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28748. /**
  28749. * Unbind all textures from the webGL context
  28750. */
  28751. unbindAllTextures(): void;
  28752. /**
  28753. * Sets a texture to the according uniform.
  28754. * @param channel The texture channel
  28755. * @param uniform The uniform to set
  28756. * @param texture The texture to apply
  28757. */
  28758. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28759. /**
  28760. * Sets a depth stencil texture from a render target to the according uniform.
  28761. * @param channel The texture channel
  28762. * @param uniform The uniform to set
  28763. * @param texture The render target texture containing the depth stencil texture to apply
  28764. */
  28765. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28766. private _bindSamplerUniformToChannel;
  28767. private _getTextureWrapMode;
  28768. private _setTexture;
  28769. /**
  28770. * Sets an array of texture to the webGL context
  28771. * @param channel defines the channel where the texture array must be set
  28772. * @param uniform defines the associated uniform location
  28773. * @param textures defines the array of textures to bind
  28774. */
  28775. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28776. /** @hidden */
  28777. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28778. private _setTextureParameterFloat;
  28779. private _setTextureParameterInteger;
  28780. /**
  28781. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28782. * @param x defines the x coordinate of the rectangle where pixels must be read
  28783. * @param y defines the y coordinate of the rectangle where pixels must be read
  28784. * @param width defines the width of the rectangle where pixels must be read
  28785. * @param height defines the height of the rectangle where pixels must be read
  28786. * @returns a Uint8Array containing RGBA colors
  28787. */
  28788. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28789. /**
  28790. * Add an externaly attached data from its key.
  28791. * This method call will fail and return false, if such key already exists.
  28792. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28793. * @param key the unique key that identifies the data
  28794. * @param data the data object to associate to the key for this Engine instance
  28795. * @return true if no such key were already present and the data was added successfully, false otherwise
  28796. */
  28797. addExternalData<T>(key: string, data: T): boolean;
  28798. /**
  28799. * Get an externaly attached data from its key
  28800. * @param key the unique key that identifies the data
  28801. * @return the associated data, if present (can be null), or undefined if not present
  28802. */
  28803. getExternalData<T>(key: string): T;
  28804. /**
  28805. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28806. * @param key the unique key that identifies the data
  28807. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28808. * @return the associated data, can be null if the factory returned null.
  28809. */
  28810. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28811. /**
  28812. * Remove an externaly attached data from the Engine instance
  28813. * @param key the unique key that identifies the data
  28814. * @return true if the data was successfully removed, false if it doesn't exist
  28815. */
  28816. removeExternalData(key: string): boolean;
  28817. /**
  28818. * Unbind all vertex attributes from the webGL context
  28819. */
  28820. unbindAllAttributes(): void;
  28821. /**
  28822. * 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
  28823. */
  28824. releaseEffects(): void;
  28825. /**
  28826. * Dispose and release all associated resources
  28827. */
  28828. dispose(): void;
  28829. /**
  28830. * Display the loading screen
  28831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28832. */
  28833. displayLoadingUI(): void;
  28834. /**
  28835. * Hide the loading screen
  28836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28837. */
  28838. hideLoadingUI(): void;
  28839. /**
  28840. * Gets the current loading screen object
  28841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28842. */
  28843. /**
  28844. * Sets the current loading screen object
  28845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28846. */
  28847. loadingScreen: ILoadingScreen;
  28848. /**
  28849. * Sets the current loading screen text
  28850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28851. */
  28852. loadingUIText: string;
  28853. /**
  28854. * Sets the current loading screen background color
  28855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28856. */
  28857. loadingUIBackgroundColor: string;
  28858. /**
  28859. * Attach a new callback raised when context lost event is fired
  28860. * @param callback defines the callback to call
  28861. */
  28862. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28863. /**
  28864. * Attach a new callback raised when context restored event is fired
  28865. * @param callback defines the callback to call
  28866. */
  28867. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28868. /**
  28869. * Gets the source code of the vertex shader associated with a specific webGL program
  28870. * @param program defines the program to use
  28871. * @returns a string containing the source code of the vertex shader associated with the program
  28872. */
  28873. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28874. /**
  28875. * Gets the source code of the fragment shader associated with a specific webGL program
  28876. * @param program defines the program to use
  28877. * @returns a string containing the source code of the fragment shader associated with the program
  28878. */
  28879. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28880. /**
  28881. * Get the current error code of the webGL context
  28882. * @returns the error code
  28883. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28884. */
  28885. getError(): number;
  28886. /**
  28887. * Gets the current framerate
  28888. * @returns a number representing the framerate
  28889. */
  28890. getFps(): number;
  28891. /**
  28892. * Gets the time spent between current and previous frame
  28893. * @returns a number representing the delta time in ms
  28894. */
  28895. getDeltaTime(): number;
  28896. private _measureFps;
  28897. /** @hidden */
  28898. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28899. private _canRenderToFloatFramebuffer;
  28900. private _canRenderToHalfFloatFramebuffer;
  28901. private _canRenderToFramebuffer;
  28902. /** @hidden */
  28903. _getWebGLTextureType(type: number): number;
  28904. private _getInternalFormat;
  28905. /** @hidden */
  28906. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28907. /** @hidden */
  28908. _getRGBAMultiSampleBufferFormat(type: number): number;
  28909. /** @hidden */
  28910. _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;
  28911. /** @hidden */
  28912. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28913. private _partialLoadFile;
  28914. private _cascadeLoadFiles;
  28915. /**
  28916. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28917. * @returns true if the engine can be created
  28918. * @ignorenaming
  28919. */
  28920. static isSupported(): boolean;
  28921. }
  28922. }
  28923. declare module "babylonjs/Materials/effect" {
  28924. import { Observable } from "babylonjs/Misc/observable";
  28925. import { Nullable } from "babylonjs/types";
  28926. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28927. import { Engine } from "babylonjs/Engines/engine";
  28928. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28930. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28931. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28933. /**
  28934. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28935. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28936. */
  28937. export class EffectFallbacks {
  28938. private _defines;
  28939. private _currentRank;
  28940. private _maxRank;
  28941. private _mesh;
  28942. /**
  28943. * Removes the fallback from the bound mesh.
  28944. */
  28945. unBindMesh(): void;
  28946. /**
  28947. * Adds a fallback on the specified property.
  28948. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28949. * @param define The name of the define in the shader
  28950. */
  28951. addFallback(rank: number, define: string): void;
  28952. /**
  28953. * Sets the mesh to use CPU skinning when needing to fallback.
  28954. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28955. * @param mesh The mesh to use the fallbacks.
  28956. */
  28957. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28958. /**
  28959. * Checks to see if more fallbacks are still availible.
  28960. */
  28961. readonly isMoreFallbacks: boolean;
  28962. /**
  28963. * Removes the defines that shoould be removed when falling back.
  28964. * @param currentDefines defines the current define statements for the shader.
  28965. * @param effect defines the current effect we try to compile
  28966. * @returns The resulting defines with defines of the current rank removed.
  28967. */
  28968. reduce(currentDefines: string, effect: Effect): string;
  28969. }
  28970. /**
  28971. * Options to be used when creating an effect.
  28972. */
  28973. export class EffectCreationOptions {
  28974. /**
  28975. * Atrributes that will be used in the shader.
  28976. */
  28977. attributes: string[];
  28978. /**
  28979. * Uniform varible names that will be set in the shader.
  28980. */
  28981. uniformsNames: string[];
  28982. /**
  28983. * Uniform buffer varible names that will be set in the shader.
  28984. */
  28985. uniformBuffersNames: string[];
  28986. /**
  28987. * Sampler texture variable names that will be set in the shader.
  28988. */
  28989. samplers: string[];
  28990. /**
  28991. * Define statements that will be set in the shader.
  28992. */
  28993. defines: any;
  28994. /**
  28995. * Possible fallbacks for this effect to improve performance when needed.
  28996. */
  28997. fallbacks: Nullable<EffectFallbacks>;
  28998. /**
  28999. * Callback that will be called when the shader is compiled.
  29000. */
  29001. onCompiled: Nullable<(effect: Effect) => void>;
  29002. /**
  29003. * Callback that will be called if an error occurs during shader compilation.
  29004. */
  29005. onError: Nullable<(effect: Effect, errors: string) => void>;
  29006. /**
  29007. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29008. */
  29009. indexParameters: any;
  29010. /**
  29011. * Max number of lights that can be used in the shader.
  29012. */
  29013. maxSimultaneousLights: number;
  29014. /**
  29015. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29016. */
  29017. transformFeedbackVaryings: Nullable<string[]>;
  29018. }
  29019. /**
  29020. * Effect containing vertex and fragment shader that can be executed on an object.
  29021. */
  29022. export class Effect {
  29023. /**
  29024. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29025. */
  29026. static ShadersRepository: string;
  29027. /**
  29028. * Name of the effect.
  29029. */
  29030. name: any;
  29031. /**
  29032. * String container all the define statements that should be set on the shader.
  29033. */
  29034. defines: string;
  29035. /**
  29036. * Callback that will be called when the shader is compiled.
  29037. */
  29038. onCompiled: Nullable<(effect: Effect) => void>;
  29039. /**
  29040. * Callback that will be called if an error occurs during shader compilation.
  29041. */
  29042. onError: Nullable<(effect: Effect, errors: string) => void>;
  29043. /**
  29044. * Callback that will be called when effect is bound.
  29045. */
  29046. onBind: Nullable<(effect: Effect) => void>;
  29047. /**
  29048. * Unique ID of the effect.
  29049. */
  29050. uniqueId: number;
  29051. /**
  29052. * Observable that will be called when the shader is compiled.
  29053. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29054. */
  29055. onCompileObservable: Observable<Effect>;
  29056. /**
  29057. * Observable that will be called if an error occurs during shader compilation.
  29058. */
  29059. onErrorObservable: Observable<Effect>;
  29060. /** @hidden */
  29061. _onBindObservable: Nullable<Observable<Effect>>;
  29062. /**
  29063. * Observable that will be called when effect is bound.
  29064. */
  29065. readonly onBindObservable: Observable<Effect>;
  29066. /** @hidden */
  29067. _bonesComputationForcedToCPU: boolean;
  29068. private static _uniqueIdSeed;
  29069. private _engine;
  29070. private _uniformBuffersNames;
  29071. private _uniformsNames;
  29072. private _samplers;
  29073. private _isReady;
  29074. private _compilationError;
  29075. private _attributesNames;
  29076. private _attributes;
  29077. private _uniforms;
  29078. /**
  29079. * Key for the effect.
  29080. * @hidden
  29081. */
  29082. _key: string;
  29083. private _indexParameters;
  29084. private _fallbacks;
  29085. private _vertexSourceCode;
  29086. private _fragmentSourceCode;
  29087. private _vertexSourceCodeOverride;
  29088. private _fragmentSourceCodeOverride;
  29089. private _transformFeedbackVaryings;
  29090. /**
  29091. * Compiled shader to webGL program.
  29092. * @hidden
  29093. */
  29094. _program: WebGLProgram;
  29095. private _valueCache;
  29096. private static _baseCache;
  29097. /**
  29098. * Instantiates an effect.
  29099. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29100. * @param baseName Name of the effect.
  29101. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29102. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29103. * @param samplers List of sampler variables that will be passed to the shader.
  29104. * @param engine Engine to be used to render the effect
  29105. * @param defines Define statements to be added to the shader.
  29106. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29107. * @param onCompiled Callback that will be called when the shader is compiled.
  29108. * @param onError Callback that will be called if an error occurs during shader compilation.
  29109. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29110. */
  29111. 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);
  29112. /**
  29113. * Unique key for this effect
  29114. */
  29115. readonly key: string;
  29116. /**
  29117. * If the effect has been compiled and prepared.
  29118. * @returns if the effect is compiled and prepared.
  29119. */
  29120. isReady(): boolean;
  29121. /**
  29122. * The engine the effect was initialized with.
  29123. * @returns the engine.
  29124. */
  29125. getEngine(): Engine;
  29126. /**
  29127. * The compiled webGL program for the effect
  29128. * @returns the webGL program.
  29129. */
  29130. getProgram(): WebGLProgram;
  29131. /**
  29132. * The set of names of attribute variables for the shader.
  29133. * @returns An array of attribute names.
  29134. */
  29135. getAttributesNames(): string[];
  29136. /**
  29137. * Returns the attribute at the given index.
  29138. * @param index The index of the attribute.
  29139. * @returns The location of the attribute.
  29140. */
  29141. getAttributeLocation(index: number): number;
  29142. /**
  29143. * Returns the attribute based on the name of the variable.
  29144. * @param name of the attribute to look up.
  29145. * @returns the attribute location.
  29146. */
  29147. getAttributeLocationByName(name: string): number;
  29148. /**
  29149. * The number of attributes.
  29150. * @returns the numnber of attributes.
  29151. */
  29152. getAttributesCount(): number;
  29153. /**
  29154. * Gets the index of a uniform variable.
  29155. * @param uniformName of the uniform to look up.
  29156. * @returns the index.
  29157. */
  29158. getUniformIndex(uniformName: string): number;
  29159. /**
  29160. * Returns the attribute based on the name of the variable.
  29161. * @param uniformName of the uniform to look up.
  29162. * @returns the location of the uniform.
  29163. */
  29164. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29165. /**
  29166. * Returns an array of sampler variable names
  29167. * @returns The array of sampler variable neames.
  29168. */
  29169. getSamplers(): string[];
  29170. /**
  29171. * The error from the last compilation.
  29172. * @returns the error string.
  29173. */
  29174. getCompilationError(): string;
  29175. /**
  29176. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29177. * @param func The callback to be used.
  29178. */
  29179. executeWhenCompiled(func: (effect: Effect) => void): void;
  29180. private _checkIsReady;
  29181. /** @hidden */
  29182. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29183. /** @hidden */
  29184. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29185. /** @hidden */
  29186. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29187. private _processShaderConversion;
  29188. private _processIncludes;
  29189. private _processPrecision;
  29190. /**
  29191. * Recompiles the webGL program
  29192. * @param vertexSourceCode The source code for the vertex shader.
  29193. * @param fragmentSourceCode The source code for the fragment shader.
  29194. * @param onCompiled Callback called when completed.
  29195. * @param onError Callback called on error.
  29196. * @hidden
  29197. */
  29198. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29199. /**
  29200. * Gets the uniform locations of the the specified variable names
  29201. * @param names THe names of the variables to lookup.
  29202. * @returns Array of locations in the same order as variable names.
  29203. */
  29204. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29205. /**
  29206. * Prepares the effect
  29207. * @hidden
  29208. */
  29209. _prepareEffect(): void;
  29210. /**
  29211. * Checks if the effect is supported. (Must be called after compilation)
  29212. */
  29213. readonly isSupported: boolean;
  29214. /**
  29215. * Binds a texture to the engine to be used as output of the shader.
  29216. * @param channel Name of the output variable.
  29217. * @param texture Texture to bind.
  29218. * @hidden
  29219. */
  29220. _bindTexture(channel: string, texture: InternalTexture): void;
  29221. /**
  29222. * Sets a texture on the engine to be used in the shader.
  29223. * @param channel Name of the sampler variable.
  29224. * @param texture Texture to set.
  29225. */
  29226. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29227. /**
  29228. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29229. * @param channel Name of the sampler variable.
  29230. * @param texture Texture to set.
  29231. */
  29232. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29233. /**
  29234. * Sets an array of textures on the engine to be used in the shader.
  29235. * @param channel Name of the variable.
  29236. * @param textures Textures to set.
  29237. */
  29238. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29239. /**
  29240. * 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)
  29241. * @param channel Name of the sampler variable.
  29242. * @param postProcess Post process to get the input texture from.
  29243. */
  29244. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29245. /**
  29246. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29247. * 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)
  29248. * @param channel Name of the sampler variable.
  29249. * @param postProcess Post process to get the output texture from.
  29250. */
  29251. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29252. /** @hidden */
  29253. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29254. /** @hidden */
  29255. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29256. /** @hidden */
  29257. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29258. /** @hidden */
  29259. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29260. /**
  29261. * Binds a buffer to a uniform.
  29262. * @param buffer Buffer to bind.
  29263. * @param name Name of the uniform variable to bind to.
  29264. */
  29265. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29266. /**
  29267. * Binds block to a uniform.
  29268. * @param blockName Name of the block to bind.
  29269. * @param index Index to bind.
  29270. */
  29271. bindUniformBlock(blockName: string, index: number): void;
  29272. /**
  29273. * Sets an interger value on a uniform variable.
  29274. * @param uniformName Name of the variable.
  29275. * @param value Value to be set.
  29276. * @returns this effect.
  29277. */
  29278. setInt(uniformName: string, value: number): Effect;
  29279. /**
  29280. * Sets an int array on a uniform variable.
  29281. * @param uniformName Name of the variable.
  29282. * @param array array to be set.
  29283. * @returns this effect.
  29284. */
  29285. setIntArray(uniformName: string, array: Int32Array): Effect;
  29286. /**
  29287. * 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)
  29288. * @param uniformName Name of the variable.
  29289. * @param array array to be set.
  29290. * @returns this effect.
  29291. */
  29292. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29293. /**
  29294. * 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)
  29295. * @param uniformName Name of the variable.
  29296. * @param array array to be set.
  29297. * @returns this effect.
  29298. */
  29299. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29300. /**
  29301. * 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)
  29302. * @param uniformName Name of the variable.
  29303. * @param array array to be set.
  29304. * @returns this effect.
  29305. */
  29306. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29307. /**
  29308. * Sets an float array on a uniform variable.
  29309. * @param uniformName Name of the variable.
  29310. * @param array array to be set.
  29311. * @returns this effect.
  29312. */
  29313. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29314. /**
  29315. * 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)
  29316. * @param uniformName Name of the variable.
  29317. * @param array array to be set.
  29318. * @returns this effect.
  29319. */
  29320. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29321. /**
  29322. * 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)
  29323. * @param uniformName Name of the variable.
  29324. * @param array array to be set.
  29325. * @returns this effect.
  29326. */
  29327. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29328. /**
  29329. * 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)
  29330. * @param uniformName Name of the variable.
  29331. * @param array array to be set.
  29332. * @returns this effect.
  29333. */
  29334. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29335. /**
  29336. * Sets an array on a uniform variable.
  29337. * @param uniformName Name of the variable.
  29338. * @param array array to be set.
  29339. * @returns this effect.
  29340. */
  29341. setArray(uniformName: string, array: number[]): Effect;
  29342. /**
  29343. * 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)
  29344. * @param uniformName Name of the variable.
  29345. * @param array array to be set.
  29346. * @returns this effect.
  29347. */
  29348. setArray2(uniformName: string, array: number[]): Effect;
  29349. /**
  29350. * 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)
  29351. * @param uniformName Name of the variable.
  29352. * @param array array to be set.
  29353. * @returns this effect.
  29354. */
  29355. setArray3(uniformName: string, array: number[]): Effect;
  29356. /**
  29357. * 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)
  29358. * @param uniformName Name of the variable.
  29359. * @param array array to be set.
  29360. * @returns this effect.
  29361. */
  29362. setArray4(uniformName: string, array: number[]): Effect;
  29363. /**
  29364. * Sets matrices on a uniform variable.
  29365. * @param uniformName Name of the variable.
  29366. * @param matrices matrices to be set.
  29367. * @returns this effect.
  29368. */
  29369. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29370. /**
  29371. * Sets matrix on a uniform variable.
  29372. * @param uniformName Name of the variable.
  29373. * @param matrix matrix to be set.
  29374. * @returns this effect.
  29375. */
  29376. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29377. /**
  29378. * 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)
  29379. * @param uniformName Name of the variable.
  29380. * @param matrix matrix to be set.
  29381. * @returns this effect.
  29382. */
  29383. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29384. /**
  29385. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29386. * @param uniformName Name of the variable.
  29387. * @param matrix matrix to be set.
  29388. * @returns this effect.
  29389. */
  29390. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29391. /**
  29392. * Sets a float on a uniform variable.
  29393. * @param uniformName Name of the variable.
  29394. * @param value value to be set.
  29395. * @returns this effect.
  29396. */
  29397. setFloat(uniformName: string, value: number): Effect;
  29398. /**
  29399. * Sets a boolean on a uniform variable.
  29400. * @param uniformName Name of the variable.
  29401. * @param bool value to be set.
  29402. * @returns this effect.
  29403. */
  29404. setBool(uniformName: string, bool: boolean): Effect;
  29405. /**
  29406. * Sets a Vector2 on a uniform variable.
  29407. * @param uniformName Name of the variable.
  29408. * @param vector2 vector2 to be set.
  29409. * @returns this effect.
  29410. */
  29411. setVector2(uniformName: string, vector2: Vector2): Effect;
  29412. /**
  29413. * Sets a float2 on a uniform variable.
  29414. * @param uniformName Name of the variable.
  29415. * @param x First float in float2.
  29416. * @param y Second float in float2.
  29417. * @returns this effect.
  29418. */
  29419. setFloat2(uniformName: string, x: number, y: number): Effect;
  29420. /**
  29421. * Sets a Vector3 on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param vector3 Value to be set.
  29424. * @returns this effect.
  29425. */
  29426. setVector3(uniformName: string, vector3: Vector3): Effect;
  29427. /**
  29428. * Sets a float3 on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param x First float in float3.
  29431. * @param y Second float in float3.
  29432. * @param z Third float in float3.
  29433. * @returns this effect.
  29434. */
  29435. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29436. /**
  29437. * Sets a Vector4 on a uniform variable.
  29438. * @param uniformName Name of the variable.
  29439. * @param vector4 Value to be set.
  29440. * @returns this effect.
  29441. */
  29442. setVector4(uniformName: string, vector4: Vector4): Effect;
  29443. /**
  29444. * Sets a float4 on a uniform variable.
  29445. * @param uniformName Name of the variable.
  29446. * @param x First float in float4.
  29447. * @param y Second float in float4.
  29448. * @param z Third float in float4.
  29449. * @param w Fourth float in float4.
  29450. * @returns this effect.
  29451. */
  29452. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29453. /**
  29454. * Sets a Color3 on a uniform variable.
  29455. * @param uniformName Name of the variable.
  29456. * @param color3 Value to be set.
  29457. * @returns this effect.
  29458. */
  29459. setColor3(uniformName: string, color3: Color3): Effect;
  29460. /**
  29461. * Sets a Color4 on a uniform variable.
  29462. * @param uniformName Name of the variable.
  29463. * @param color3 Value to be set.
  29464. * @param alpha Alpha value to be set.
  29465. * @returns this effect.
  29466. */
  29467. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29468. /**
  29469. * Sets a Color4 on a uniform variable
  29470. * @param uniformName defines the name of the variable
  29471. * @param color4 defines the value to be set
  29472. * @returns this effect.
  29473. */
  29474. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29475. /**
  29476. * This function will add a new shader to the shader store
  29477. * @param name the name of the shader
  29478. * @param pixelShader optional pixel shader content
  29479. * @param vertexShader optional vertex shader content
  29480. */
  29481. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29482. /**
  29483. * Store of each shader (The can be looked up using effect.key)
  29484. */
  29485. static ShadersStore: {
  29486. [key: string]: string;
  29487. };
  29488. /**
  29489. * Store of each included file for a shader (The can be looked up using effect.key)
  29490. */
  29491. static IncludesShadersStore: {
  29492. [key: string]: string;
  29493. };
  29494. /**
  29495. * Resets the cache of effects.
  29496. */
  29497. static ResetCache(): void;
  29498. }
  29499. }
  29500. declare module "babylonjs/Materials/colorCurves" {
  29501. import { Effect } from "babylonjs/Materials/effect";
  29502. /**
  29503. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29504. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29505. * 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;
  29506. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29507. */
  29508. export class ColorCurves {
  29509. private _dirty;
  29510. private _tempColor;
  29511. private _globalCurve;
  29512. private _highlightsCurve;
  29513. private _midtonesCurve;
  29514. private _shadowsCurve;
  29515. private _positiveCurve;
  29516. private _negativeCurve;
  29517. private _globalHue;
  29518. private _globalDensity;
  29519. private _globalSaturation;
  29520. private _globalExposure;
  29521. /**
  29522. * Gets the global Hue value.
  29523. * 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).
  29524. */
  29525. /**
  29526. * Sets the global Hue value.
  29527. * 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).
  29528. */
  29529. globalHue: number;
  29530. /**
  29531. * Gets 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. /**
  29536. * Sets the global Density value.
  29537. * 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.
  29538. * Values less than zero provide a filter of opposite hue.
  29539. */
  29540. globalDensity: number;
  29541. /**
  29542. * Gets the global Saturation value.
  29543. * 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.
  29544. */
  29545. /**
  29546. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  29548. */
  29549. globalSaturation: number;
  29550. /**
  29551. * Gets the global Exposure value.
  29552. * 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.
  29553. */
  29554. /**
  29555. * Sets the global Exposure value.
  29556. * 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.
  29557. */
  29558. globalExposure: number;
  29559. private _highlightsHue;
  29560. private _highlightsDensity;
  29561. private _highlightsSaturation;
  29562. private _highlightsExposure;
  29563. /**
  29564. * Gets the highlights Hue value.
  29565. * 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).
  29566. */
  29567. /**
  29568. * Sets the highlights Hue value.
  29569. * 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).
  29570. */
  29571. highlightsHue: number;
  29572. /**
  29573. * Gets 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. /**
  29578. * Sets the highlights Density value.
  29579. * 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.
  29580. * Values less than zero provide a filter of opposite hue.
  29581. */
  29582. highlightsDensity: number;
  29583. /**
  29584. * Gets the highlights Saturation value.
  29585. * 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.
  29586. */
  29587. /**
  29588. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  29590. */
  29591. highlightsSaturation: number;
  29592. /**
  29593. * Gets the highlights Exposure value.
  29594. * 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.
  29595. */
  29596. /**
  29597. * Sets the highlights Exposure value.
  29598. * 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.
  29599. */
  29600. highlightsExposure: number;
  29601. private _midtonesHue;
  29602. private _midtonesDensity;
  29603. private _midtonesSaturation;
  29604. private _midtonesExposure;
  29605. /**
  29606. * Gets the midtones Hue value.
  29607. * 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).
  29608. */
  29609. /**
  29610. * Sets the midtones Hue value.
  29611. * 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).
  29612. */
  29613. midtonesHue: number;
  29614. /**
  29615. * Gets 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. /**
  29620. * Sets the midtones Density value.
  29621. * 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.
  29622. * Values less than zero provide a filter of opposite hue.
  29623. */
  29624. midtonesDensity: number;
  29625. /**
  29626. * Gets the midtones Saturation value.
  29627. * 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.
  29628. */
  29629. /**
  29630. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  29632. */
  29633. midtonesSaturation: number;
  29634. /**
  29635. * Gets the midtones Exposure value.
  29636. * 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.
  29637. */
  29638. /**
  29639. * Sets the midtones Exposure value.
  29640. * 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.
  29641. */
  29642. midtonesExposure: number;
  29643. private _shadowsHue;
  29644. private _shadowsDensity;
  29645. private _shadowsSaturation;
  29646. private _shadowsExposure;
  29647. /**
  29648. * Gets the shadows Hue value.
  29649. * 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).
  29650. */
  29651. /**
  29652. * Sets the shadows Hue value.
  29653. * 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).
  29654. */
  29655. shadowsHue: number;
  29656. /**
  29657. * Gets 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. /**
  29662. * Sets the shadows Density value.
  29663. * 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.
  29664. * Values less than zero provide a filter of opposite hue.
  29665. */
  29666. shadowsDensity: number;
  29667. /**
  29668. * Gets the shadows Saturation value.
  29669. * 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.
  29670. */
  29671. /**
  29672. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  29674. */
  29675. shadowsSaturation: number;
  29676. /**
  29677. * Gets the shadows Exposure value.
  29678. * 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.
  29679. */
  29680. /**
  29681. * Sets the shadows Exposure value.
  29682. * 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.
  29683. */
  29684. shadowsExposure: number;
  29685. /**
  29686. * Returns the class name
  29687. * @returns The class name
  29688. */
  29689. getClassName(): string;
  29690. /**
  29691. * Binds the color curves to the shader.
  29692. * @param colorCurves The color curve to bind
  29693. * @param effect The effect to bind to
  29694. * @param positiveUniform The positive uniform shader parameter
  29695. * @param neutralUniform The neutral uniform shader parameter
  29696. * @param negativeUniform The negative uniform shader parameter
  29697. */
  29698. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29699. /**
  29700. * Prepare the list of uniforms associated with the ColorCurves effects.
  29701. * @param uniformsList The list of uniforms used in the effect
  29702. */
  29703. static PrepareUniforms(uniformsList: string[]): void;
  29704. /**
  29705. * Returns color grading data based on a hue, density, saturation and exposure value.
  29706. * @param filterHue The hue of the color filter.
  29707. * @param filterDensity The density of the color filter.
  29708. * @param saturation The saturation.
  29709. * @param exposure The exposure.
  29710. * @param result The result data container.
  29711. */
  29712. private getColorGradingDataToRef;
  29713. /**
  29714. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29715. * @param value The input slider value in range [-100,100].
  29716. * @returns Adjusted value.
  29717. */
  29718. private static applyColorGradingSliderNonlinear;
  29719. /**
  29720. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29721. * @param hue The hue (H) input.
  29722. * @param saturation The saturation (S) input.
  29723. * @param brightness The brightness (B) input.
  29724. * @result An RGBA color represented as Vector4.
  29725. */
  29726. private static fromHSBToRef;
  29727. /**
  29728. * Returns a value clamped between min and max
  29729. * @param value The value to clamp
  29730. * @param min The minimum of value
  29731. * @param max The maximum of value
  29732. * @returns The clamped value.
  29733. */
  29734. private static clamp;
  29735. /**
  29736. * Clones the current color curve instance.
  29737. * @return The cloned curves
  29738. */
  29739. clone(): ColorCurves;
  29740. /**
  29741. * Serializes the current color curve instance to a json representation.
  29742. * @return a JSON representation
  29743. */
  29744. serialize(): any;
  29745. /**
  29746. * Parses the color curve from a json representation.
  29747. * @param source the JSON source to parse
  29748. * @return The parsed curves
  29749. */
  29750. static Parse(source: any): ColorCurves;
  29751. }
  29752. }
  29753. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29754. import { Observable } from "babylonjs/Misc/observable";
  29755. import { Nullable } from "babylonjs/types";
  29756. import { Color4 } from "babylonjs/Maths/math";
  29757. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29758. import { Effect } from "babylonjs/Materials/effect";
  29759. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29760. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29761. /**
  29762. * Interface to follow in your material defines to integrate easily the
  29763. * Image proccessing functions.
  29764. * @hidden
  29765. */
  29766. export interface IImageProcessingConfigurationDefines {
  29767. IMAGEPROCESSING: boolean;
  29768. VIGNETTE: boolean;
  29769. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29770. VIGNETTEBLENDMODEOPAQUE: boolean;
  29771. TONEMAPPING: boolean;
  29772. TONEMAPPING_ACES: boolean;
  29773. CONTRAST: boolean;
  29774. EXPOSURE: boolean;
  29775. COLORCURVES: boolean;
  29776. COLORGRADING: boolean;
  29777. COLORGRADING3D: boolean;
  29778. SAMPLER3DGREENDEPTH: boolean;
  29779. SAMPLER3DBGRMAP: boolean;
  29780. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29781. }
  29782. /**
  29783. * @hidden
  29784. */
  29785. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29786. IMAGEPROCESSING: boolean;
  29787. VIGNETTE: boolean;
  29788. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29789. VIGNETTEBLENDMODEOPAQUE: boolean;
  29790. TONEMAPPING: boolean;
  29791. TONEMAPPING_ACES: boolean;
  29792. CONTRAST: boolean;
  29793. COLORCURVES: boolean;
  29794. COLORGRADING: boolean;
  29795. COLORGRADING3D: boolean;
  29796. SAMPLER3DGREENDEPTH: boolean;
  29797. SAMPLER3DBGRMAP: boolean;
  29798. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29799. EXPOSURE: boolean;
  29800. constructor();
  29801. }
  29802. /**
  29803. * This groups together the common properties used for image processing either in direct forward pass
  29804. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29805. * or not.
  29806. */
  29807. export class ImageProcessingConfiguration {
  29808. /**
  29809. * Default tone mapping applied in BabylonJS.
  29810. */
  29811. static readonly TONEMAPPING_STANDARD: number;
  29812. /**
  29813. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29814. * to other engines rendering to increase portability.
  29815. */
  29816. static readonly TONEMAPPING_ACES: number;
  29817. /**
  29818. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29819. */
  29820. colorCurves: Nullable<ColorCurves>;
  29821. private _colorCurvesEnabled;
  29822. /**
  29823. * Gets wether the color curves effect is enabled.
  29824. */
  29825. /**
  29826. * Sets wether the color curves effect is enabled.
  29827. */
  29828. colorCurvesEnabled: boolean;
  29829. private _colorGradingTexture;
  29830. /**
  29831. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29832. */
  29833. /**
  29834. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29835. */
  29836. colorGradingTexture: Nullable<BaseTexture>;
  29837. private _colorGradingEnabled;
  29838. /**
  29839. * Gets wether the color grading effect is enabled.
  29840. */
  29841. /**
  29842. * Sets wether the color grading effect is enabled.
  29843. */
  29844. colorGradingEnabled: boolean;
  29845. private _colorGradingWithGreenDepth;
  29846. /**
  29847. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29848. */
  29849. /**
  29850. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29851. */
  29852. colorGradingWithGreenDepth: boolean;
  29853. private _colorGradingBGR;
  29854. /**
  29855. * Gets wether the color grading texture contains BGR values.
  29856. */
  29857. /**
  29858. * Sets wether the color grading texture contains BGR values.
  29859. */
  29860. colorGradingBGR: boolean;
  29861. /** @hidden */
  29862. _exposure: number;
  29863. /**
  29864. * Gets the Exposure used in the effect.
  29865. */
  29866. /**
  29867. * Sets the Exposure used in the effect.
  29868. */
  29869. exposure: number;
  29870. private _toneMappingEnabled;
  29871. /**
  29872. * Gets wether the tone mapping effect is enabled.
  29873. */
  29874. /**
  29875. * Sets wether the tone mapping effect is enabled.
  29876. */
  29877. toneMappingEnabled: boolean;
  29878. private _toneMappingType;
  29879. /**
  29880. * Gets the type of tone mapping effect.
  29881. */
  29882. /**
  29883. * Sets the type of tone mapping effect used in BabylonJS.
  29884. */
  29885. toneMappingType: number;
  29886. protected _contrast: number;
  29887. /**
  29888. * Gets the contrast used in the effect.
  29889. */
  29890. /**
  29891. * Sets the contrast used in the effect.
  29892. */
  29893. contrast: number;
  29894. /**
  29895. * Vignette stretch size.
  29896. */
  29897. vignetteStretch: number;
  29898. /**
  29899. * Vignette centre X Offset.
  29900. */
  29901. vignetteCentreX: number;
  29902. /**
  29903. * Vignette centre Y Offset.
  29904. */
  29905. vignetteCentreY: number;
  29906. /**
  29907. * Vignette weight or intensity of the vignette effect.
  29908. */
  29909. vignetteWeight: number;
  29910. /**
  29911. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29912. * if vignetteEnabled is set to true.
  29913. */
  29914. vignetteColor: Color4;
  29915. /**
  29916. * Camera field of view used by the Vignette effect.
  29917. */
  29918. vignetteCameraFov: number;
  29919. private _vignetteBlendMode;
  29920. /**
  29921. * Gets the vignette blend mode allowing different kind of effect.
  29922. */
  29923. /**
  29924. * Sets the vignette blend mode allowing different kind of effect.
  29925. */
  29926. vignetteBlendMode: number;
  29927. private _vignetteEnabled;
  29928. /**
  29929. * Gets wether the vignette effect is enabled.
  29930. */
  29931. /**
  29932. * Sets wether the vignette effect is enabled.
  29933. */
  29934. vignetteEnabled: boolean;
  29935. private _applyByPostProcess;
  29936. /**
  29937. * Gets wether the image processing is applied through a post process or not.
  29938. */
  29939. /**
  29940. * Sets wether the image processing is applied through a post process or not.
  29941. */
  29942. applyByPostProcess: boolean;
  29943. private _isEnabled;
  29944. /**
  29945. * Gets wether the image processing is enabled or not.
  29946. */
  29947. /**
  29948. * Sets wether the image processing is enabled or not.
  29949. */
  29950. isEnabled: boolean;
  29951. /**
  29952. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29953. */
  29954. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29955. /**
  29956. * Method called each time the image processing information changes requires to recompile the effect.
  29957. */
  29958. protected _updateParameters(): void;
  29959. /**
  29960. * Gets the current class name.
  29961. * @return "ImageProcessingConfiguration"
  29962. */
  29963. getClassName(): string;
  29964. /**
  29965. * Prepare the list of uniforms associated with the Image Processing effects.
  29966. * @param uniforms The list of uniforms used in the effect
  29967. * @param defines the list of defines currently in use
  29968. */
  29969. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29970. /**
  29971. * Prepare the list of samplers associated with the Image Processing effects.
  29972. * @param samplersList The list of uniforms used in the effect
  29973. * @param defines the list of defines currently in use
  29974. */
  29975. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29976. /**
  29977. * Prepare the list of defines associated to the shader.
  29978. * @param defines the list of defines to complete
  29979. * @param forPostProcess Define if we are currently in post process mode or not
  29980. */
  29981. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29982. /**
  29983. * Returns true if all the image processing information are ready.
  29984. * @returns True if ready, otherwise, false
  29985. */
  29986. isReady(): boolean;
  29987. /**
  29988. * Binds the image processing to the shader.
  29989. * @param effect The effect to bind to
  29990. * @param aspectRatio Define the current aspect ratio of the effect
  29991. */
  29992. bind(effect: Effect, aspectRatio?: number): void;
  29993. /**
  29994. * Clones the current image processing instance.
  29995. * @return The cloned image processing
  29996. */
  29997. clone(): ImageProcessingConfiguration;
  29998. /**
  29999. * Serializes the current image processing instance to a json representation.
  30000. * @return a JSON representation
  30001. */
  30002. serialize(): any;
  30003. /**
  30004. * Parses the image processing from a json representation.
  30005. * @param source the JSON source to parse
  30006. * @return The parsed image processing
  30007. */
  30008. static Parse(source: any): ImageProcessingConfiguration;
  30009. private static _VIGNETTEMODE_MULTIPLY;
  30010. private static _VIGNETTEMODE_OPAQUE;
  30011. /**
  30012. * Used to apply the vignette as a mix with the pixel color.
  30013. */
  30014. static readonly VIGNETTEMODE_MULTIPLY: number;
  30015. /**
  30016. * Used to apply the vignette as a replacement of the pixel color.
  30017. */
  30018. static readonly VIGNETTEMODE_OPAQUE: number;
  30019. }
  30020. }
  30021. declare module "babylonjs/Materials/fresnelParameters" {
  30022. import { Color3 } from "babylonjs/Maths/math";
  30023. /**
  30024. * This represents all the required information to add a fresnel effect on a material:
  30025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30026. */
  30027. export class FresnelParameters {
  30028. private _isEnabled;
  30029. /**
  30030. * Define if the fresnel effect is enable or not.
  30031. */
  30032. isEnabled: boolean;
  30033. /**
  30034. * Define the color used on edges (grazing angle)
  30035. */
  30036. leftColor: Color3;
  30037. /**
  30038. * Define the color used on center
  30039. */
  30040. rightColor: Color3;
  30041. /**
  30042. * Define bias applied to computed fresnel term
  30043. */
  30044. bias: number;
  30045. /**
  30046. * Defined the power exponent applied to fresnel term
  30047. */
  30048. power: number;
  30049. /**
  30050. * Clones the current fresnel and its valuues
  30051. * @returns a clone fresnel configuration
  30052. */
  30053. clone(): FresnelParameters;
  30054. /**
  30055. * Serializes the current fresnel parameters to a JSON representation.
  30056. * @return the JSON serialization
  30057. */
  30058. serialize(): any;
  30059. /**
  30060. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30061. * @param parsedFresnelParameters Define the JSON representation
  30062. * @returns the parsed parameters
  30063. */
  30064. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30065. }
  30066. }
  30067. declare module "babylonjs/Misc/decorators" {
  30068. import { Nullable } from "babylonjs/types";
  30069. import { Scene } from "babylonjs/scene";
  30070. import { IAnimatable } from "babylonjs/Misc/tools";
  30071. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30072. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30073. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30074. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30075. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30076. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30077. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30078. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30079. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30080. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30081. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30082. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30083. /**
  30084. * Decorator used to define property that can be serialized as reference to a camera
  30085. * @param sourceName defines the name of the property to decorate
  30086. */
  30087. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30088. /**
  30089. * Class used to help serialization objects
  30090. */
  30091. export class SerializationHelper {
  30092. /** hidden */
  30093. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30094. /** hidden */
  30095. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30096. /** hidden */
  30097. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30098. /** hidden */
  30099. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30100. /**
  30101. * Appends the serialized animations from the source animations
  30102. * @param source Source containing the animations
  30103. * @param destination Target to store the animations
  30104. */
  30105. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30106. /**
  30107. * Static function used to serialized a specific entity
  30108. * @param entity defines the entity to serialize
  30109. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30110. * @returns a JSON compatible object representing the serialization of the entity
  30111. */
  30112. static Serialize<T>(entity: T, serializationObject?: any): any;
  30113. /**
  30114. * Creates a new entity from a serialization data object
  30115. * @param creationFunction defines a function used to instanciated the new entity
  30116. * @param source defines the source serialization data
  30117. * @param scene defines the hosting scene
  30118. * @param rootUrl defines the root url for resources
  30119. * @returns a new entity
  30120. */
  30121. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30122. /**
  30123. * Clones an object
  30124. * @param creationFunction defines the function used to instanciate the new object
  30125. * @param source defines the source object
  30126. * @returns the cloned object
  30127. */
  30128. static Clone<T>(creationFunction: () => T, source: T): T;
  30129. /**
  30130. * Instanciates a new object based on a source one (some data will be shared between both object)
  30131. * @param creationFunction defines the function used to instanciate the new object
  30132. * @param source defines the source object
  30133. * @returns the new object
  30134. */
  30135. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30136. }
  30137. }
  30138. declare module "babylonjs/Cameras/camera" {
  30139. import { SmartArray } from "babylonjs/Misc/smartArray";
  30140. import { Observable } from "babylonjs/Misc/observable";
  30141. import { Nullable } from "babylonjs/types";
  30142. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30143. import { Scene } from "babylonjs/scene";
  30144. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30145. import { Node } from "babylonjs/node";
  30146. import { Mesh } from "babylonjs/Meshes/mesh";
  30147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30148. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30149. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30150. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30151. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30152. import { Ray } from "babylonjs/Culling/ray";
  30153. /**
  30154. * This is the base class of all the camera used in the application.
  30155. * @see http://doc.babylonjs.com/features/cameras
  30156. */
  30157. export class Camera extends Node {
  30158. /** @hidden */
  30159. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30160. /**
  30161. * This is the default projection mode used by the cameras.
  30162. * It helps recreating a feeling of perspective and better appreciate depth.
  30163. * This is the best way to simulate real life cameras.
  30164. */
  30165. static readonly PERSPECTIVE_CAMERA: number;
  30166. /**
  30167. * This helps creating camera with an orthographic mode.
  30168. * 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.
  30169. */
  30170. static readonly ORTHOGRAPHIC_CAMERA: number;
  30171. /**
  30172. * This is the default FOV mode for perspective cameras.
  30173. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30174. */
  30175. static readonly FOVMODE_VERTICAL_FIXED: number;
  30176. /**
  30177. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30178. */
  30179. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30180. /**
  30181. * This specifies ther is no need for a camera rig.
  30182. * Basically only one eye is rendered corresponding to the camera.
  30183. */
  30184. static readonly RIG_MODE_NONE: number;
  30185. /**
  30186. * Simulates a camera Rig with one blue eye and one red eye.
  30187. * This can be use with 3d blue and red glasses.
  30188. */
  30189. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30190. /**
  30191. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30192. */
  30193. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30194. /**
  30195. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30196. */
  30197. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30198. /**
  30199. * Defines that both eyes of the camera will be rendered over under each other.
  30200. */
  30201. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30202. /**
  30203. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30204. */
  30205. static readonly RIG_MODE_VR: number;
  30206. /**
  30207. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30208. */
  30209. static readonly RIG_MODE_WEBVR: number;
  30210. /**
  30211. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30212. */
  30213. static readonly RIG_MODE_CUSTOM: number;
  30214. /**
  30215. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30216. */
  30217. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30218. /**
  30219. * @hidden
  30220. * Might be removed once multiview will be a thing
  30221. */
  30222. static UseAlternateWebVRRendering: boolean;
  30223. /**
  30224. * Define the input manager associated with the camera.
  30225. */
  30226. inputs: CameraInputsManager<Camera>;
  30227. /** @hidden */
  30228. _position: Vector3;
  30229. /**
  30230. * Define the current local position of the camera in the scene
  30231. */
  30232. position: Vector3;
  30233. /**
  30234. * The vector the camera should consider as up.
  30235. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30236. */
  30237. upVector: Vector3;
  30238. /**
  30239. * Define the current limit on the left side for an orthographic camera
  30240. * In scene unit
  30241. */
  30242. orthoLeft: Nullable<number>;
  30243. /**
  30244. * Define the current limit on the right side for an orthographic camera
  30245. * In scene unit
  30246. */
  30247. orthoRight: Nullable<number>;
  30248. /**
  30249. * Define the current limit on the bottom side for an orthographic camera
  30250. * In scene unit
  30251. */
  30252. orthoBottom: Nullable<number>;
  30253. /**
  30254. * Define the current limit on the top side for an orthographic camera
  30255. * In scene unit
  30256. */
  30257. orthoTop: Nullable<number>;
  30258. /**
  30259. * Field Of View is set in Radians. (default is 0.8)
  30260. */
  30261. fov: number;
  30262. /**
  30263. * Define the minimum distance the camera can see from.
  30264. * This is important to note that the depth buffer are not infinite and the closer it starts
  30265. * the more your scene might encounter depth fighting issue.
  30266. */
  30267. minZ: number;
  30268. /**
  30269. * Define the maximum distance the camera can see to.
  30270. * This is important to note that the depth buffer are not infinite and the further it end
  30271. * the more your scene might encounter depth fighting issue.
  30272. */
  30273. maxZ: number;
  30274. /**
  30275. * Define the default inertia of the camera.
  30276. * This helps giving a smooth feeling to the camera movement.
  30277. */
  30278. inertia: number;
  30279. /**
  30280. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30281. */
  30282. mode: number;
  30283. /**
  30284. * Define wether the camera is intermediate.
  30285. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30286. */
  30287. isIntermediate: boolean;
  30288. /**
  30289. * Define the viewport of the camera.
  30290. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30291. */
  30292. viewport: Viewport;
  30293. /**
  30294. * Restricts the camera to viewing objects with the same layerMask.
  30295. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30296. */
  30297. layerMask: number;
  30298. /**
  30299. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30300. */
  30301. fovMode: number;
  30302. /**
  30303. * Rig mode of the camera.
  30304. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30305. * This is normally controlled byt the camera themselves as internal use.
  30306. */
  30307. cameraRigMode: number;
  30308. /**
  30309. * Defines the distance between both "eyes" in case of a RIG
  30310. */
  30311. interaxialDistance: number;
  30312. /**
  30313. * Defines if stereoscopic rendering is done side by side or over under.
  30314. */
  30315. isStereoscopicSideBySide: boolean;
  30316. /**
  30317. * 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
  30318. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30319. * else in the scene.
  30320. */
  30321. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30322. /**
  30323. * When set, the camera will render to this render target instead of the default canvas
  30324. */
  30325. outputRenderTarget: Nullable<RenderTargetTexture>;
  30326. /**
  30327. * Observable triggered when the camera view matrix has changed.
  30328. */
  30329. onViewMatrixChangedObservable: Observable<Camera>;
  30330. /**
  30331. * Observable triggered when the camera Projection matrix has changed.
  30332. */
  30333. onProjectionMatrixChangedObservable: Observable<Camera>;
  30334. /**
  30335. * Observable triggered when the inputs have been processed.
  30336. */
  30337. onAfterCheckInputsObservable: Observable<Camera>;
  30338. /**
  30339. * Observable triggered when reset has been called and applied to the camera.
  30340. */
  30341. onRestoreStateObservable: Observable<Camera>;
  30342. /** @hidden */
  30343. _cameraRigParams: any;
  30344. /** @hidden */
  30345. _rigCameras: Camera[];
  30346. /** @hidden */
  30347. _rigPostProcess: Nullable<PostProcess>;
  30348. protected _webvrViewMatrix: Matrix;
  30349. /** @hidden */
  30350. _skipRendering: boolean;
  30351. /** @hidden */
  30352. _alternateCamera: Camera;
  30353. /** @hidden */
  30354. _projectionMatrix: Matrix;
  30355. /** @hidden */
  30356. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30357. /** @hidden */
  30358. _activeMeshes: SmartArray<AbstractMesh>;
  30359. protected _globalPosition: Vector3;
  30360. /** hidden */
  30361. _computedViewMatrix: Matrix;
  30362. private _doNotComputeProjectionMatrix;
  30363. private _transformMatrix;
  30364. private _frustumPlanes;
  30365. private _refreshFrustumPlanes;
  30366. private _storedFov;
  30367. private _stateStored;
  30368. /**
  30369. * Instantiates a new camera object.
  30370. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30371. * @see http://doc.babylonjs.com/features/cameras
  30372. * @param name Defines the name of the camera in the scene
  30373. * @param position Defines the position of the camera
  30374. * @param scene Defines the scene the camera belongs too
  30375. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30376. */
  30377. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30378. /**
  30379. * Store current camera state (fov, position, etc..)
  30380. * @returns the camera
  30381. */
  30382. storeState(): Camera;
  30383. /**
  30384. * Restores the camera state values if it has been stored. You must call storeState() first
  30385. */
  30386. protected _restoreStateValues(): boolean;
  30387. /**
  30388. * Restored camera state. You must call storeState() first.
  30389. * @returns true if restored and false otherwise
  30390. */
  30391. restoreState(): boolean;
  30392. /**
  30393. * Gets the class name of the camera.
  30394. * @returns the class name
  30395. */
  30396. getClassName(): string;
  30397. /** @hidden */
  30398. readonly _isCamera: boolean;
  30399. /**
  30400. * Gets a string representation of the camera useful for debug purpose.
  30401. * @param fullDetails Defines that a more verboe level of logging is required
  30402. * @returns the string representation
  30403. */
  30404. toString(fullDetails?: boolean): string;
  30405. /**
  30406. * Gets the current world space position of the camera.
  30407. */
  30408. readonly globalPosition: Vector3;
  30409. /**
  30410. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30411. * @returns the active meshe list
  30412. */
  30413. getActiveMeshes(): SmartArray<AbstractMesh>;
  30414. /**
  30415. * Check wether a mesh is part of the current active mesh list of the camera
  30416. * @param mesh Defines the mesh to check
  30417. * @returns true if active, false otherwise
  30418. */
  30419. isActiveMesh(mesh: Mesh): boolean;
  30420. /**
  30421. * Is this camera ready to be used/rendered
  30422. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30423. * @return true if the camera is ready
  30424. */
  30425. isReady(completeCheck?: boolean): boolean;
  30426. /** @hidden */
  30427. _initCache(): void;
  30428. /** @hidden */
  30429. _updateCache(ignoreParentClass?: boolean): void;
  30430. /** @hidden */
  30431. _isSynchronized(): boolean;
  30432. /** @hidden */
  30433. _isSynchronizedViewMatrix(): boolean;
  30434. /** @hidden */
  30435. _isSynchronizedProjectionMatrix(): boolean;
  30436. /**
  30437. * Attach the input controls to a specific dom element to get the input from.
  30438. * @param element Defines the element the controls should be listened from
  30439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30440. */
  30441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30442. /**
  30443. * Detach the current controls from the specified dom element.
  30444. * @param element Defines the element to stop listening the inputs from
  30445. */
  30446. detachControl(element: HTMLElement): void;
  30447. /**
  30448. * Update the camera state according to the different inputs gathered during the frame.
  30449. */
  30450. update(): void;
  30451. /** @hidden */
  30452. _checkInputs(): void;
  30453. /** @hidden */
  30454. readonly rigCameras: Camera[];
  30455. /**
  30456. * Gets the post process used by the rig cameras
  30457. */
  30458. readonly rigPostProcess: Nullable<PostProcess>;
  30459. /**
  30460. * Internal, gets the first post proces.
  30461. * @returns the first post process to be run on this camera.
  30462. */
  30463. _getFirstPostProcess(): Nullable<PostProcess>;
  30464. private _cascadePostProcessesToRigCams;
  30465. /**
  30466. * Attach a post process to the camera.
  30467. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30468. * @param postProcess The post process to attach to the camera
  30469. * @param insertAt The position of the post process in case several of them are in use in the scene
  30470. * @returns the position the post process has been inserted at
  30471. */
  30472. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30473. /**
  30474. * Detach a post process to the camera.
  30475. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30476. * @param postProcess The post process to detach from the camera
  30477. */
  30478. detachPostProcess(postProcess: PostProcess): void;
  30479. /**
  30480. * Gets the current world matrix of the camera
  30481. */
  30482. getWorldMatrix(): Matrix;
  30483. /** @hidden */
  30484. _getViewMatrix(): Matrix;
  30485. /**
  30486. * Gets the current view matrix of the camera.
  30487. * @param force forces the camera to recompute the matrix without looking at the cached state
  30488. * @returns the view matrix
  30489. */
  30490. getViewMatrix(force?: boolean): Matrix;
  30491. /**
  30492. * Freeze the projection matrix.
  30493. * It will prevent the cache check of the camera projection compute and can speed up perf
  30494. * if no parameter of the camera are meant to change
  30495. * @param projection Defines manually a projection if necessary
  30496. */
  30497. freezeProjectionMatrix(projection?: Matrix): void;
  30498. /**
  30499. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30500. */
  30501. unfreezeProjectionMatrix(): void;
  30502. /**
  30503. * Gets the current projection matrix of the camera.
  30504. * @param force forces the camera to recompute the matrix without looking at the cached state
  30505. * @returns the projection matrix
  30506. */
  30507. getProjectionMatrix(force?: boolean): Matrix;
  30508. /**
  30509. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30510. * @returns a Matrix
  30511. */
  30512. getTransformationMatrix(): Matrix;
  30513. private _updateFrustumPlanes;
  30514. /**
  30515. * Checks if a cullable object (mesh...) is in the camera frustum
  30516. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30517. * @param target The object to check
  30518. * @returns true if the object is in frustum otherwise false
  30519. */
  30520. isInFrustum(target: ICullable): boolean;
  30521. /**
  30522. * Checks if a cullable object (mesh...) is in the camera frustum
  30523. * Unlike isInFrustum this cheks the full bounding box
  30524. * @param target The object to check
  30525. * @returns true if the object is in frustum otherwise false
  30526. */
  30527. isCompletelyInFrustum(target: ICullable): boolean;
  30528. /**
  30529. * Gets a ray in the forward direction from the camera.
  30530. * @param length Defines the length of the ray to create
  30531. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30532. * @param origin Defines the start point of the ray which defaults to the camera position
  30533. * @returns the forward ray
  30534. */
  30535. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30536. /**
  30537. * Releases resources associated with this node.
  30538. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30539. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30540. */
  30541. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30542. /** @hidden */
  30543. _isLeftCamera: boolean;
  30544. /**
  30545. * Gets the left camera of a rig setup in case of Rigged Camera
  30546. */
  30547. readonly isLeftCamera: boolean;
  30548. /** @hidden */
  30549. _isRightCamera: boolean;
  30550. /**
  30551. * Gets the right camera of a rig setup in case of Rigged Camera
  30552. */
  30553. readonly isRightCamera: boolean;
  30554. /**
  30555. * Gets the left camera of a rig setup in case of Rigged Camera
  30556. */
  30557. readonly leftCamera: Nullable<FreeCamera>;
  30558. /**
  30559. * Gets the right camera of a rig setup in case of Rigged Camera
  30560. */
  30561. readonly rightCamera: Nullable<FreeCamera>;
  30562. /**
  30563. * Gets the left camera target of a rig setup in case of Rigged Camera
  30564. * @returns the target position
  30565. */
  30566. getLeftTarget(): Nullable<Vector3>;
  30567. /**
  30568. * Gets the right camera target of a rig setup in case of Rigged Camera
  30569. * @returns the target position
  30570. */
  30571. getRightTarget(): Nullable<Vector3>;
  30572. /**
  30573. * @hidden
  30574. */
  30575. setCameraRigMode(mode: number, rigParams: any): void;
  30576. /** @hidden */
  30577. static _setStereoscopicRigMode(camera: Camera): void;
  30578. /** @hidden */
  30579. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30580. /** @hidden */
  30581. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30582. /** @hidden */
  30583. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30584. /** @hidden */
  30585. _getVRProjectionMatrix(): Matrix;
  30586. protected _updateCameraRotationMatrix(): void;
  30587. protected _updateWebVRCameraRotationMatrix(): void;
  30588. /**
  30589. * This function MUST be overwritten by the different WebVR cameras available.
  30590. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30591. * @hidden
  30592. */
  30593. _getWebVRProjectionMatrix(): Matrix;
  30594. /**
  30595. * This function MUST be overwritten by the different WebVR cameras available.
  30596. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30597. * @hidden
  30598. */
  30599. _getWebVRViewMatrix(): Matrix;
  30600. /** @hidden */
  30601. setCameraRigParameter(name: string, value: any): void;
  30602. /**
  30603. * needs to be overridden by children so sub has required properties to be copied
  30604. * @hidden
  30605. */
  30606. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30607. /**
  30608. * May need to be overridden by children
  30609. * @hidden
  30610. */
  30611. _updateRigCameras(): void;
  30612. /** @hidden */
  30613. _setupInputs(): void;
  30614. /**
  30615. * Serialiaze the camera setup to a json represention
  30616. * @returns the JSON representation
  30617. */
  30618. serialize(): any;
  30619. /**
  30620. * Clones the current camera.
  30621. * @param name The cloned camera name
  30622. * @returns the cloned camera
  30623. */
  30624. clone(name: string): Camera;
  30625. /**
  30626. * Gets the direction of the camera relative to a given local axis.
  30627. * @param localAxis Defines the reference axis to provide a relative direction.
  30628. * @return the direction
  30629. */
  30630. getDirection(localAxis: Vector3): Vector3;
  30631. /**
  30632. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30633. * @param localAxis Defines the reference axis to provide a relative direction.
  30634. * @param result Defines the vector to store the result in
  30635. */
  30636. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30637. /**
  30638. * Gets a camera constructor for a given camera type
  30639. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30640. * @param name The name of the camera the result will be able to instantiate
  30641. * @param scene The scene the result will construct the camera in
  30642. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30643. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30644. * @returns a factory method to construc the camera
  30645. */
  30646. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30647. /**
  30648. * Compute the world matrix of the camera.
  30649. * @returns the camera workd matrix
  30650. */
  30651. computeWorldMatrix(): Matrix;
  30652. /**
  30653. * Parse a JSON and creates the camera from the parsed information
  30654. * @param parsedCamera The JSON to parse
  30655. * @param scene The scene to instantiate the camera in
  30656. * @returns the newly constructed camera
  30657. */
  30658. static Parse(parsedCamera: any, scene: Scene): Camera;
  30659. }
  30660. }
  30661. declare module "babylonjs/Misc/tools" {
  30662. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30663. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30664. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30665. import { Observable } from "babylonjs/Misc/observable";
  30666. import { DomManagement } from "babylonjs/Misc/domManagement";
  30667. import { Camera } from "babylonjs/Cameras/camera";
  30668. import { Engine } from "babylonjs/Engines/engine";
  30669. import { Animation } from "babylonjs/Animations/animation";
  30670. /**
  30671. * Interface for any object that can request an animation frame
  30672. */
  30673. export interface ICustomAnimationFrameRequester {
  30674. /**
  30675. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30676. */
  30677. renderFunction?: Function;
  30678. /**
  30679. * Called to request the next frame to render to
  30680. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30681. */
  30682. requestAnimationFrame: Function;
  30683. /**
  30684. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30685. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30686. */
  30687. requestID?: number;
  30688. }
  30689. /**
  30690. * Interface containing an array of animations
  30691. */
  30692. export interface IAnimatable {
  30693. /**
  30694. * Array of animations
  30695. */
  30696. animations: Array<Animation>;
  30697. }
  30698. /** Interface used by value gradients (color, factor, ...) */
  30699. export interface IValueGradient {
  30700. /**
  30701. * Gets or sets the gradient value (between 0 and 1)
  30702. */
  30703. gradient: number;
  30704. }
  30705. /** Class used to store color4 gradient */
  30706. export class ColorGradient implements IValueGradient {
  30707. /**
  30708. * Gets or sets the gradient value (between 0 and 1)
  30709. */
  30710. gradient: number;
  30711. /**
  30712. * Gets or sets first associated color
  30713. */
  30714. color1: Color4;
  30715. /**
  30716. * Gets or sets second associated color
  30717. */
  30718. color2?: Color4;
  30719. /**
  30720. * Will get a color picked randomly between color1 and color2.
  30721. * If color2 is undefined then color1 will be used
  30722. * @param result defines the target Color4 to store the result in
  30723. */
  30724. getColorToRef(result: Color4): void;
  30725. }
  30726. /** Class used to store color 3 gradient */
  30727. export class Color3Gradient implements IValueGradient {
  30728. /**
  30729. * Gets or sets the gradient value (between 0 and 1)
  30730. */
  30731. gradient: number;
  30732. /**
  30733. * Gets or sets the associated color
  30734. */
  30735. color: Color3;
  30736. }
  30737. /** Class used to store factor gradient */
  30738. export class FactorGradient implements IValueGradient {
  30739. /**
  30740. * Gets or sets the gradient value (between 0 and 1)
  30741. */
  30742. gradient: number;
  30743. /**
  30744. * Gets or sets first associated factor
  30745. */
  30746. factor1: number;
  30747. /**
  30748. * Gets or sets second associated factor
  30749. */
  30750. factor2?: number;
  30751. /**
  30752. * Will get a number picked randomly between factor1 and factor2.
  30753. * If factor2 is undefined then factor1 will be used
  30754. * @returns the picked number
  30755. */
  30756. getFactor(): number;
  30757. }
  30758. /**
  30759. * @ignore
  30760. * Application error to support additional information when loading a file
  30761. */
  30762. export class LoadFileError extends Error {
  30763. /** defines the optional XHR request */
  30764. request?: XMLHttpRequest | undefined;
  30765. private static _setPrototypeOf;
  30766. /**
  30767. * Creates a new LoadFileError
  30768. * @param message defines the message of the error
  30769. * @param request defines the optional XHR request
  30770. */
  30771. constructor(message: string,
  30772. /** defines the optional XHR request */
  30773. request?: XMLHttpRequest | undefined);
  30774. }
  30775. /**
  30776. * Class used to define a retry strategy when error happens while loading assets
  30777. */
  30778. export class RetryStrategy {
  30779. /**
  30780. * Function used to defines an exponential back off strategy
  30781. * @param maxRetries defines the maximum number of retries (3 by default)
  30782. * @param baseInterval defines the interval between retries
  30783. * @returns the strategy function to use
  30784. */
  30785. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30786. }
  30787. /**
  30788. * File request interface
  30789. */
  30790. export interface IFileRequest {
  30791. /**
  30792. * Raised when the request is complete (success or error).
  30793. */
  30794. onCompleteObservable: Observable<IFileRequest>;
  30795. /**
  30796. * Aborts the request for a file.
  30797. */
  30798. abort: () => void;
  30799. }
  30800. /**
  30801. * Class containing a set of static utilities functions
  30802. */
  30803. export class Tools {
  30804. /**
  30805. * Gets or sets the base URL to use to load assets
  30806. */
  30807. static BaseUrl: string;
  30808. /**
  30809. * Enable/Disable Custom HTTP Request Headers globally.
  30810. * default = false
  30811. * @see CustomRequestHeaders
  30812. */
  30813. static UseCustomRequestHeaders: boolean;
  30814. /**
  30815. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30816. * i.e. when loading files, where the server/service expects an Authorization header.
  30817. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30818. */
  30819. static CustomRequestHeaders: {
  30820. [key: string]: string;
  30821. };
  30822. /**
  30823. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30824. */
  30825. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30826. /**
  30827. * Default behaviour for cors in the application.
  30828. * It can be a string if the expected behavior is identical in the entire app.
  30829. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30830. */
  30831. static CorsBehavior: string | ((url: string | string[]) => string);
  30832. /**
  30833. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30834. * @ignorenaming
  30835. */
  30836. static UseFallbackTexture: boolean;
  30837. /**
  30838. * Use this object to register external classes like custom textures or material
  30839. * to allow the laoders to instantiate them
  30840. */
  30841. static RegisteredExternalClasses: {
  30842. [key: string]: Object;
  30843. };
  30844. /**
  30845. * Texture content used if a texture cannot loaded
  30846. * @ignorenaming
  30847. */
  30848. static fallbackTexture: string;
  30849. /**
  30850. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30851. * @param u defines the coordinate on X axis
  30852. * @param v defines the coordinate on Y axis
  30853. * @param width defines the width of the source data
  30854. * @param height defines the height of the source data
  30855. * @param pixels defines the source byte array
  30856. * @param color defines the output color
  30857. */
  30858. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30859. /**
  30860. * Interpolates between a and b via alpha
  30861. * @param a The lower value (returned when alpha = 0)
  30862. * @param b The upper value (returned when alpha = 1)
  30863. * @param alpha The interpolation-factor
  30864. * @return The mixed value
  30865. */
  30866. static Mix(a: number, b: number, alpha: number): number;
  30867. /**
  30868. * Tries to instantiate a new object from a given class name
  30869. * @param className defines the class name to instantiate
  30870. * @returns the new object or null if the system was not able to do the instantiation
  30871. */
  30872. static Instantiate(className: string): any;
  30873. /**
  30874. * Provides a slice function that will work even on IE
  30875. * @param data defines the array to slice
  30876. * @param start defines the start of the data (optional)
  30877. * @param end defines the end of the data (optional)
  30878. * @returns the new sliced array
  30879. */
  30880. static Slice<T>(data: T, start?: number, end?: number): T;
  30881. /**
  30882. * Polyfill for setImmediate
  30883. * @param action defines the action to execute after the current execution block
  30884. */
  30885. static SetImmediate(action: () => void): void;
  30886. /**
  30887. * Function indicating if a number is an exponent of 2
  30888. * @param value defines the value to test
  30889. * @returns true if the value is an exponent of 2
  30890. */
  30891. static IsExponentOfTwo(value: number): boolean;
  30892. private static _tmpFloatArray;
  30893. /**
  30894. * Returns the nearest 32-bit single precision float representation of a Number
  30895. * @param value A Number. If the parameter is of a different type, it will get converted
  30896. * to a number or to NaN if it cannot be converted
  30897. * @returns number
  30898. */
  30899. static FloatRound(value: number): number;
  30900. /**
  30901. * Find the next highest power of two.
  30902. * @param x Number to start search from.
  30903. * @return Next highest power of two.
  30904. */
  30905. static CeilingPOT(x: number): number;
  30906. /**
  30907. * Find the next lowest power of two.
  30908. * @param x Number to start search from.
  30909. * @return Next lowest power of two.
  30910. */
  30911. static FloorPOT(x: number): number;
  30912. /**
  30913. * Find the nearest power of two.
  30914. * @param x Number to start search from.
  30915. * @return Next nearest power of two.
  30916. */
  30917. static NearestPOT(x: number): number;
  30918. /**
  30919. * Get the closest exponent of two
  30920. * @param value defines the value to approximate
  30921. * @param max defines the maximum value to return
  30922. * @param mode defines how to define the closest value
  30923. * @returns closest exponent of two of the given value
  30924. */
  30925. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30926. /**
  30927. * Extracts the filename from a path
  30928. * @param path defines the path to use
  30929. * @returns the filename
  30930. */
  30931. static GetFilename(path: string): string;
  30932. /**
  30933. * Extracts the "folder" part of a path (everything before the filename).
  30934. * @param uri The URI to extract the info from
  30935. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30936. * @returns The "folder" part of the path
  30937. */
  30938. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30939. /**
  30940. * Extracts text content from a DOM element hierarchy
  30941. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30942. */
  30943. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30944. /**
  30945. * Convert an angle in radians to degrees
  30946. * @param angle defines the angle to convert
  30947. * @returns the angle in degrees
  30948. */
  30949. static ToDegrees(angle: number): number;
  30950. /**
  30951. * Convert an angle in degrees to radians
  30952. * @param angle defines the angle to convert
  30953. * @returns the angle in radians
  30954. */
  30955. static ToRadians(angle: number): number;
  30956. /**
  30957. * Encode a buffer to a base64 string
  30958. * @param buffer defines the buffer to encode
  30959. * @returns the encoded string
  30960. */
  30961. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30962. /**
  30963. * Extracts minimum and maximum values from a list of indexed positions
  30964. * @param positions defines the positions to use
  30965. * @param indices defines the indices to the positions
  30966. * @param indexStart defines the start index
  30967. * @param indexCount defines the end index
  30968. * @param bias defines bias value to add to the result
  30969. * @return minimum and maximum values
  30970. */
  30971. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30972. minimum: Vector3;
  30973. maximum: Vector3;
  30974. };
  30975. /**
  30976. * Extracts minimum and maximum values from a list of positions
  30977. * @param positions defines the positions to use
  30978. * @param start defines the start index in the positions array
  30979. * @param count defines the number of positions to handle
  30980. * @param bias defines bias value to add to the result
  30981. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30982. * @return minimum and maximum values
  30983. */
  30984. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30985. minimum: Vector3;
  30986. maximum: Vector3;
  30987. };
  30988. /**
  30989. * Returns an array if obj is not an array
  30990. * @param obj defines the object to evaluate as an array
  30991. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30992. * @returns either obj directly if obj is an array or a new array containing obj
  30993. */
  30994. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30995. /**
  30996. * Gets the pointer prefix to use
  30997. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30998. */
  30999. static GetPointerPrefix(): string;
  31000. /**
  31001. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31002. * @param func - the function to be called
  31003. * @param requester - the object that will request the next frame. Falls back to window.
  31004. * @returns frame number
  31005. */
  31006. static QueueNewFrame(func: () => void, requester?: any): number;
  31007. /**
  31008. * Ask the browser to promote the current element to fullscreen rendering mode
  31009. * @param element defines the DOM element to promote
  31010. */
  31011. static RequestFullscreen(element: HTMLElement): void;
  31012. /**
  31013. * Asks the browser to exit fullscreen mode
  31014. */
  31015. static ExitFullscreen(): void;
  31016. /**
  31017. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31018. * @param url define the url we are trying
  31019. * @param element define the dom element where to configure the cors policy
  31020. */
  31021. static SetCorsBehavior(url: string | string[], element: {
  31022. crossOrigin: string | null;
  31023. }): void;
  31024. /**
  31025. * Removes unwanted characters from an url
  31026. * @param url defines the url to clean
  31027. * @returns the cleaned url
  31028. */
  31029. static CleanUrl(url: string): string;
  31030. /**
  31031. * Gets or sets a function used to pre-process url before using them to load assets
  31032. */
  31033. static PreprocessUrl: (url: string) => string;
  31034. /**
  31035. * Loads an image as an HTMLImageElement.
  31036. * @param input url string, ArrayBuffer, or Blob to load
  31037. * @param onLoad callback called when the image successfully loads
  31038. * @param onError callback called when the image fails to load
  31039. * @param offlineProvider offline provider for caching
  31040. * @returns the HTMLImageElement of the loaded image
  31041. */
  31042. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31043. /**
  31044. * Loads a file
  31045. * @param url url string, ArrayBuffer, or Blob to load
  31046. * @param onSuccess callback called when the file successfully loads
  31047. * @param onProgress callback called while file is loading (if the server supports this mode)
  31048. * @param offlineProvider defines the offline provider for caching
  31049. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31050. * @param onError callback called when the file fails to load
  31051. * @returns a file request object
  31052. */
  31053. 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;
  31054. /**
  31055. * Load a script (identified by an url). When the url returns, the
  31056. * content of this file is added into a new script element, attached to the DOM (body element)
  31057. * @param scriptUrl defines the url of the script to laod
  31058. * @param onSuccess defines the callback called when the script is loaded
  31059. * @param onError defines the callback to call if an error occurs
  31060. */
  31061. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31062. /**
  31063. * Loads a file from a blob
  31064. * @param fileToLoad defines the blob to use
  31065. * @param callback defines the callback to call when data is loaded
  31066. * @param progressCallback defines the callback to call during loading process
  31067. * @returns a file request object
  31068. */
  31069. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31070. /**
  31071. * Loads a file
  31072. * @param fileToLoad defines the file to load
  31073. * @param callback defines the callback to call when data is loaded
  31074. * @param progressCallBack defines the callback to call during loading process
  31075. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31076. * @returns a file request object
  31077. */
  31078. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31079. /**
  31080. * Creates a data url from a given string content
  31081. * @param content defines the content to convert
  31082. * @returns the new data url link
  31083. */
  31084. static FileAsURL(content: string): string;
  31085. /**
  31086. * Format the given number to a specific decimal format
  31087. * @param value defines the number to format
  31088. * @param decimals defines the number of decimals to use
  31089. * @returns the formatted string
  31090. */
  31091. static Format(value: number, decimals?: number): string;
  31092. /**
  31093. * Checks if a given vector is inside a specific range
  31094. * @param v defines the vector to test
  31095. * @param min defines the minimum range
  31096. * @param max defines the maximum range
  31097. */
  31098. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31099. /**
  31100. * Tries to copy an object by duplicating every property
  31101. * @param source defines the source object
  31102. * @param destination defines the target object
  31103. * @param doNotCopyList defines a list of properties to avoid
  31104. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31105. */
  31106. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31107. /**
  31108. * Gets a boolean indicating if the given object has no own property
  31109. * @param obj defines the object to test
  31110. * @returns true if object has no own property
  31111. */
  31112. static IsEmpty(obj: any): boolean;
  31113. /**
  31114. * Function used to register events at window level
  31115. * @param events defines the events to register
  31116. */
  31117. static RegisterTopRootEvents(events: {
  31118. name: string;
  31119. handler: Nullable<(e: FocusEvent) => any>;
  31120. }[]): void;
  31121. /**
  31122. * Function used to unregister events from window level
  31123. * @param events defines the events to unregister
  31124. */
  31125. static UnregisterTopRootEvents(events: {
  31126. name: string;
  31127. handler: Nullable<(e: FocusEvent) => any>;
  31128. }[]): void;
  31129. /**
  31130. * @ignore
  31131. */
  31132. static _ScreenshotCanvas: HTMLCanvasElement;
  31133. /**
  31134. * Dumps the current bound framebuffer
  31135. * @param width defines the rendering width
  31136. * @param height defines the rendering height
  31137. * @param engine defines the hosting engine
  31138. * @param successCallback defines the callback triggered once the data are available
  31139. * @param mimeType defines the mime type of the result
  31140. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31141. */
  31142. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31143. /**
  31144. * Converts the canvas data to blob.
  31145. * This acts as a polyfill for browsers not supporting the to blob function.
  31146. * @param canvas Defines the canvas to extract the data from
  31147. * @param successCallback Defines the callback triggered once the data are available
  31148. * @param mimeType Defines the mime type of the result
  31149. */
  31150. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31151. /**
  31152. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31153. * @param successCallback defines the callback triggered once the data are available
  31154. * @param mimeType defines the mime type of the result
  31155. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31156. */
  31157. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31158. /**
  31159. * Downloads a blob in the browser
  31160. * @param blob defines the blob to download
  31161. * @param fileName defines the name of the downloaded file
  31162. */
  31163. static Download(blob: Blob, fileName: string): void;
  31164. /**
  31165. * Captures a screenshot of the current rendering
  31166. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31167. * @param engine defines the rendering engine
  31168. * @param camera defines the source camera
  31169. * @param size This parameter can be set to a single number or to an object with the
  31170. * following (optional) properties: precision, width, height. If a single number is passed,
  31171. * it will be used for both width and height. If an object is passed, the screenshot size
  31172. * will be derived from the parameters. The precision property is a multiplier allowing
  31173. * rendering at a higher or lower resolution
  31174. * @param successCallback defines the callback receives a single parameter which contains the
  31175. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31176. * src parameter of an <img> to display it
  31177. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31178. * Check your browser for supported MIME types
  31179. */
  31180. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31181. /**
  31182. * Generates an image screenshot from the specified camera.
  31183. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31184. * @param engine The engine to use for rendering
  31185. * @param camera The camera to use for rendering
  31186. * @param size This parameter can be set to a single number or to an object with the
  31187. * following (optional) properties: precision, width, height. If a single number is passed,
  31188. * it will be used for both width and height. If an object is passed, the screenshot size
  31189. * will be derived from the parameters. The precision property is a multiplier allowing
  31190. * rendering at a higher or lower resolution
  31191. * @param successCallback The callback receives a single parameter which contains the
  31192. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31193. * src parameter of an <img> to display it
  31194. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31195. * Check your browser for supported MIME types
  31196. * @param samples Texture samples (default: 1)
  31197. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31198. * @param fileName A name for for the downloaded file.
  31199. */
  31200. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31201. /**
  31202. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31203. * Be aware Math.random() could cause collisions, but:
  31204. * "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"
  31205. * @returns a pseudo random id
  31206. */
  31207. static RandomId(): string;
  31208. /**
  31209. * Test if the given uri is a base64 string
  31210. * @param uri The uri to test
  31211. * @return True if the uri is a base64 string or false otherwise
  31212. */
  31213. static IsBase64(uri: string): boolean;
  31214. /**
  31215. * Decode the given base64 uri.
  31216. * @param uri The uri to decode
  31217. * @return The decoded base64 data.
  31218. */
  31219. static DecodeBase64(uri: string): ArrayBuffer;
  31220. /**
  31221. * No log
  31222. */
  31223. static readonly NoneLogLevel: number;
  31224. /**
  31225. * Only message logs
  31226. */
  31227. static readonly MessageLogLevel: number;
  31228. /**
  31229. * Only warning logs
  31230. */
  31231. static readonly WarningLogLevel: number;
  31232. /**
  31233. * Only error logs
  31234. */
  31235. static readonly ErrorLogLevel: number;
  31236. /**
  31237. * All logs
  31238. */
  31239. static readonly AllLogLevel: number;
  31240. /**
  31241. * Gets a value indicating the number of loading errors
  31242. * @ignorenaming
  31243. */
  31244. static readonly errorsCount: number;
  31245. /**
  31246. * Callback called when a new log is added
  31247. */
  31248. static OnNewCacheEntry: (entry: string) => void;
  31249. /**
  31250. * Log a message to the console
  31251. * @param message defines the message to log
  31252. */
  31253. static Log(message: string): void;
  31254. /**
  31255. * Write a warning message to the console
  31256. * @param message defines the message to log
  31257. */
  31258. static Warn(message: string): void;
  31259. /**
  31260. * Write an error message to the console
  31261. * @param message defines the message to log
  31262. */
  31263. static Error(message: string): void;
  31264. /**
  31265. * Gets current log cache (list of logs)
  31266. */
  31267. static readonly LogCache: string;
  31268. /**
  31269. * Clears the log cache
  31270. */
  31271. static ClearLogCache(): void;
  31272. /**
  31273. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31274. */
  31275. static LogLevels: number;
  31276. /**
  31277. * Checks if the loaded document was accessed via `file:`-Protocol.
  31278. * @returns boolean
  31279. */
  31280. static IsFileURL(): boolean;
  31281. /**
  31282. * Checks if the window object exists
  31283. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31284. */
  31285. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31286. /**
  31287. * No performance log
  31288. */
  31289. static readonly PerformanceNoneLogLevel: number;
  31290. /**
  31291. * Use user marks to log performance
  31292. */
  31293. static readonly PerformanceUserMarkLogLevel: number;
  31294. /**
  31295. * Log performance to the console
  31296. */
  31297. static readonly PerformanceConsoleLogLevel: number;
  31298. private static _performance;
  31299. /**
  31300. * Sets the current performance log level
  31301. */
  31302. static PerformanceLogLevel: number;
  31303. private static _StartPerformanceCounterDisabled;
  31304. private static _EndPerformanceCounterDisabled;
  31305. private static _StartUserMark;
  31306. private static _EndUserMark;
  31307. private static _StartPerformanceConsole;
  31308. private static _EndPerformanceConsole;
  31309. /**
  31310. * Injects the @see CustomRequestHeaders into the given request
  31311. * @param request the request that should be used for injection
  31312. */
  31313. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31314. /**
  31315. * Starts a performance counter
  31316. */
  31317. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31318. /**
  31319. * Ends a specific performance coutner
  31320. */
  31321. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31322. /**
  31323. * Gets either window.performance.now() if supported or Date.now() else
  31324. */
  31325. static readonly Now: number;
  31326. /**
  31327. * This method will return the name of the class used to create the instance of the given object.
  31328. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31329. * @param object the object to get the class name from
  31330. * @param isType defines if the object is actually a type
  31331. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31332. */
  31333. static GetClassName(object: any, isType?: boolean): string;
  31334. /**
  31335. * Gets the first element of an array satisfying a given predicate
  31336. * @param array defines the array to browse
  31337. * @param predicate defines the predicate to use
  31338. * @returns null if not found or the element
  31339. */
  31340. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31341. /**
  31342. * This method will return the name of the full name of the class, including its owning module (if any).
  31343. * 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).
  31344. * @param object the object to get the class name from
  31345. * @param isType defines if the object is actually a type
  31346. * @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.
  31347. * @ignorenaming
  31348. */
  31349. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31350. /**
  31351. * Returns a promise that resolves after the given amount of time.
  31352. * @param delay Number of milliseconds to delay
  31353. * @returns Promise that resolves after the given amount of time
  31354. */
  31355. static DelayAsync(delay: number): Promise<void>;
  31356. /**
  31357. * Gets the current gradient from an array of IValueGradient
  31358. * @param ratio defines the current ratio to get
  31359. * @param gradients defines the array of IValueGradient
  31360. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31361. */
  31362. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31363. }
  31364. /**
  31365. * This class is used to track a performance counter which is number based.
  31366. * The user has access to many properties which give statistics of different nature.
  31367. *
  31368. * The implementer can track two kinds of Performance Counter: time and count.
  31369. * 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.
  31370. * 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.
  31371. */
  31372. export class PerfCounter {
  31373. /**
  31374. * Gets or sets a global boolean to turn on and off all the counters
  31375. */
  31376. static Enabled: boolean;
  31377. /**
  31378. * Returns the smallest value ever
  31379. */
  31380. readonly min: number;
  31381. /**
  31382. * Returns the biggest value ever
  31383. */
  31384. readonly max: number;
  31385. /**
  31386. * Returns the average value since the performance counter is running
  31387. */
  31388. readonly average: number;
  31389. /**
  31390. * Returns the average value of the last second the counter was monitored
  31391. */
  31392. readonly lastSecAverage: number;
  31393. /**
  31394. * Returns the current value
  31395. */
  31396. readonly current: number;
  31397. /**
  31398. * Gets the accumulated total
  31399. */
  31400. readonly total: number;
  31401. /**
  31402. * Gets the total value count
  31403. */
  31404. readonly count: number;
  31405. /**
  31406. * Creates a new counter
  31407. */
  31408. constructor();
  31409. /**
  31410. * Call this method to start monitoring a new frame.
  31411. * 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.
  31412. */
  31413. fetchNewFrame(): void;
  31414. /**
  31415. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31416. * @param newCount the count value to add to the monitored count
  31417. * @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.
  31418. */
  31419. addCount(newCount: number, fetchResult: boolean): void;
  31420. /**
  31421. * Start monitoring this performance counter
  31422. */
  31423. beginMonitoring(): void;
  31424. /**
  31425. * Compute the time lapsed since the previous beginMonitoring() call.
  31426. * @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
  31427. */
  31428. endMonitoring(newFrame?: boolean): void;
  31429. private _fetchResult;
  31430. private _startMonitoringTime;
  31431. private _min;
  31432. private _max;
  31433. private _average;
  31434. private _current;
  31435. private _totalValueCount;
  31436. private _totalAccumulated;
  31437. private _lastSecAverage;
  31438. private _lastSecAccumulated;
  31439. private _lastSecTime;
  31440. private _lastSecValueCount;
  31441. }
  31442. /**
  31443. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31444. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31445. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31446. * @param name The name of the class, case should be preserved
  31447. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31448. */
  31449. export function className(name: string, module?: string): (target: Object) => void;
  31450. /**
  31451. * An implementation of a loop for asynchronous functions.
  31452. */
  31453. export class AsyncLoop {
  31454. /**
  31455. * Defines the number of iterations for the loop
  31456. */
  31457. iterations: number;
  31458. /**
  31459. * Defines the current index of the loop.
  31460. */
  31461. index: number;
  31462. private _done;
  31463. private _fn;
  31464. private _successCallback;
  31465. /**
  31466. * Constructor.
  31467. * @param iterations the number of iterations.
  31468. * @param func the function to run each iteration
  31469. * @param successCallback the callback that will be called upon succesful execution
  31470. * @param offset starting offset.
  31471. */
  31472. constructor(
  31473. /**
  31474. * Defines the number of iterations for the loop
  31475. */
  31476. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31477. /**
  31478. * Execute the next iteration. Must be called after the last iteration was finished.
  31479. */
  31480. executeNext(): void;
  31481. /**
  31482. * Break the loop and run the success callback.
  31483. */
  31484. breakLoop(): void;
  31485. /**
  31486. * Create and run an async loop.
  31487. * @param iterations the number of iterations.
  31488. * @param fn the function to run each iteration
  31489. * @param successCallback the callback that will be called upon succesful execution
  31490. * @param offset starting offset.
  31491. * @returns the created async loop object
  31492. */
  31493. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31494. /**
  31495. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31496. * @param iterations total number of iterations
  31497. * @param syncedIterations number of synchronous iterations in each async iteration.
  31498. * @param fn the function to call each iteration.
  31499. * @param callback a success call back that will be called when iterating stops.
  31500. * @param breakFunction a break condition (optional)
  31501. * @param timeout timeout settings for the setTimeout function. default - 0.
  31502. * @returns the created async loop object
  31503. */
  31504. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31505. }
  31506. }
  31507. declare module "babylonjs/Collisions/collisionCoordinator" {
  31508. import { Nullable } from "babylonjs/types";
  31509. import { Scene } from "babylonjs/scene";
  31510. import { Vector3 } from "babylonjs/Maths/math";
  31511. import { Collider } from "babylonjs/Collisions/collider";
  31512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31513. /** @hidden */
  31514. export interface ICollisionCoordinator {
  31515. createCollider(): Collider;
  31516. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31517. init(scene: Scene): void;
  31518. }
  31519. /** @hidden */
  31520. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31521. private _scene;
  31522. private _scaledPosition;
  31523. private _scaledVelocity;
  31524. private _finalPosition;
  31525. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31526. createCollider(): Collider;
  31527. init(scene: Scene): void;
  31528. private _collideWithWorld;
  31529. }
  31530. }
  31531. declare module "babylonjs/Animations/animationGroup" {
  31532. import { Animatable } from "babylonjs/Animations/animatable";
  31533. import { Animation } from "babylonjs/Animations/animation";
  31534. import { Scene, IDisposable } from "babylonjs/scene";
  31535. import { Observable } from "babylonjs/Misc/observable";
  31536. import { Nullable } from "babylonjs/types";
  31537. /**
  31538. * This class defines the direct association between an animation and a target
  31539. */
  31540. export class TargetedAnimation {
  31541. /**
  31542. * Animation to perform
  31543. */
  31544. animation: Animation;
  31545. /**
  31546. * Target to animate
  31547. */
  31548. target: any;
  31549. }
  31550. /**
  31551. * Use this class to create coordinated animations on multiple targets
  31552. */
  31553. export class AnimationGroup implements IDisposable {
  31554. /** The name of the animation group */
  31555. name: string;
  31556. private _scene;
  31557. private _targetedAnimations;
  31558. private _animatables;
  31559. private _from;
  31560. private _to;
  31561. private _isStarted;
  31562. private _isPaused;
  31563. private _speedRatio;
  31564. /**
  31565. * Gets or sets the unique id of the node
  31566. */
  31567. uniqueId: number;
  31568. /**
  31569. * This observable will notify when one animation have ended
  31570. */
  31571. onAnimationEndObservable: Observable<TargetedAnimation>;
  31572. /**
  31573. * Observer raised when one animation loops
  31574. */
  31575. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31576. /**
  31577. * This observable will notify when all animations have ended.
  31578. */
  31579. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31580. /**
  31581. * This observable will notify when all animations have paused.
  31582. */
  31583. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31584. /**
  31585. * This observable will notify when all animations are playing.
  31586. */
  31587. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31588. /**
  31589. * Gets the first frame
  31590. */
  31591. readonly from: number;
  31592. /**
  31593. * Gets the last frame
  31594. */
  31595. readonly to: number;
  31596. /**
  31597. * Define if the animations are started
  31598. */
  31599. readonly isStarted: boolean;
  31600. /**
  31601. * Gets a value indicating that the current group is playing
  31602. */
  31603. readonly isPlaying: boolean;
  31604. /**
  31605. * Gets or sets the speed ratio to use for all animations
  31606. */
  31607. /**
  31608. * Gets or sets the speed ratio to use for all animations
  31609. */
  31610. speedRatio: number;
  31611. /**
  31612. * Gets the targeted animations for this animation group
  31613. */
  31614. readonly targetedAnimations: Array<TargetedAnimation>;
  31615. /**
  31616. * returning the list of animatables controlled by this animation group.
  31617. */
  31618. readonly animatables: Array<Animatable>;
  31619. /**
  31620. * Instantiates a new Animation Group.
  31621. * This helps managing several animations at once.
  31622. * @see http://doc.babylonjs.com/how_to/group
  31623. * @param name Defines the name of the group
  31624. * @param scene Defines the scene the group belongs to
  31625. */
  31626. constructor(
  31627. /** The name of the animation group */
  31628. name: string, scene?: Nullable<Scene>);
  31629. /**
  31630. * Add an animation (with its target) in the group
  31631. * @param animation defines the animation we want to add
  31632. * @param target defines the target of the animation
  31633. * @returns the TargetedAnimation object
  31634. */
  31635. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31636. /**
  31637. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31638. * It can add constant keys at begin or end
  31639. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31640. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31641. * @returns the animation group
  31642. */
  31643. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31644. /**
  31645. * Start all animations on given targets
  31646. * @param loop defines if animations must loop
  31647. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31648. * @param from defines the from key (optional)
  31649. * @param to defines the to key (optional)
  31650. * @returns the current animation group
  31651. */
  31652. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31653. /**
  31654. * Pause all animations
  31655. * @returns the animation group
  31656. */
  31657. pause(): AnimationGroup;
  31658. /**
  31659. * Play all animations to initial state
  31660. * This function will start() the animations if they were not started or will restart() them if they were paused
  31661. * @param loop defines if animations must loop
  31662. * @returns the animation group
  31663. */
  31664. play(loop?: boolean): AnimationGroup;
  31665. /**
  31666. * Reset all animations to initial state
  31667. * @returns the animation group
  31668. */
  31669. reset(): AnimationGroup;
  31670. /**
  31671. * Restart animations from key 0
  31672. * @returns the animation group
  31673. */
  31674. restart(): AnimationGroup;
  31675. /**
  31676. * Stop all animations
  31677. * @returns the animation group
  31678. */
  31679. stop(): AnimationGroup;
  31680. /**
  31681. * Set animation weight for all animatables
  31682. * @param weight defines the weight to use
  31683. * @return the animationGroup
  31684. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31685. */
  31686. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31687. /**
  31688. * Synchronize and normalize all animatables with a source animatable
  31689. * @param root defines the root animatable to synchronize with
  31690. * @return the animationGroup
  31691. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31692. */
  31693. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31694. /**
  31695. * Goes to a specific frame in this animation group
  31696. * @param frame the frame number to go to
  31697. * @return the animationGroup
  31698. */
  31699. goToFrame(frame: number): AnimationGroup;
  31700. /**
  31701. * Dispose all associated resources
  31702. */
  31703. dispose(): void;
  31704. private _checkAnimationGroupEnded;
  31705. /**
  31706. * Clone the current animation group and returns a copy
  31707. * @param newName defines the name of the new group
  31708. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31709. * @returns the new aniamtion group
  31710. */
  31711. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31712. /**
  31713. * Returns a new AnimationGroup object parsed from the source provided.
  31714. * @param parsedAnimationGroup defines the source
  31715. * @param scene defines the scene that will receive the animationGroup
  31716. * @returns a new AnimationGroup
  31717. */
  31718. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31719. /**
  31720. * Returns the string "AnimationGroup"
  31721. * @returns "AnimationGroup"
  31722. */
  31723. getClassName(): string;
  31724. /**
  31725. * Creates a detailled string about the object
  31726. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31727. * @returns a string representing the object
  31728. */
  31729. toString(fullDetails?: boolean): string;
  31730. }
  31731. }
  31732. declare module "babylonjs/scene" {
  31733. import { Nullable } from "babylonjs/types";
  31734. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31735. import { Observable } from "babylonjs/Misc/observable";
  31736. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31737. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31738. import { Geometry } from "babylonjs/Meshes/geometry";
  31739. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31740. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31742. import { Mesh } from "babylonjs/Meshes/mesh";
  31743. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31744. import { Bone } from "babylonjs/Bones/bone";
  31745. import { Skeleton } from "babylonjs/Bones/skeleton";
  31746. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31747. import { Camera } from "babylonjs/Cameras/camera";
  31748. import { AbstractScene } from "babylonjs/abstractScene";
  31749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31750. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31751. import { Material } from "babylonjs/Materials/material";
  31752. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31753. import { Effect } from "babylonjs/Materials/effect";
  31754. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31755. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31756. import { Light } from "babylonjs/Lights/light";
  31757. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31758. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31759. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31760. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31761. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31762. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31763. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31764. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31765. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31766. import { Engine } from "babylonjs/Engines/engine";
  31767. import { Node } from "babylonjs/node";
  31768. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31769. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31770. import { Ray } from "babylonjs/Culling/ray";
  31771. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31772. import { Animation } from "babylonjs/Animations/animation";
  31773. import { Animatable } from "babylonjs/Animations/animatable";
  31774. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31775. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31776. import { Collider } from "babylonjs/Collisions/collider";
  31777. /**
  31778. * Define an interface for all classes that will hold resources
  31779. */
  31780. export interface IDisposable {
  31781. /**
  31782. * Releases all held resources
  31783. */
  31784. dispose(): void;
  31785. }
  31786. /** Interface defining initialization parameters for Scene class */
  31787. export interface SceneOptions {
  31788. /**
  31789. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31790. * It will improve performance when the number of geometries becomes important.
  31791. */
  31792. useGeometryUniqueIdsMap?: boolean;
  31793. /**
  31794. * Defines that each material of the scene should keep up-to-date a map of referencing 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. useMaterialMeshMap?: boolean;
  31798. /**
  31799. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31800. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31801. */
  31802. useClonedMeshhMap?: boolean;
  31803. }
  31804. /**
  31805. * Represents a scene to be rendered by the engine.
  31806. * @see http://doc.babylonjs.com/features/scene
  31807. */
  31808. export class Scene extends AbstractScene implements IAnimatable {
  31809. private static _uniqueIdCounter;
  31810. /** The fog is deactivated */
  31811. static readonly FOGMODE_NONE: number;
  31812. /** The fog density is following an exponential function */
  31813. static readonly FOGMODE_EXP: number;
  31814. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31815. static readonly FOGMODE_EXP2: number;
  31816. /** The fog density is following a linear function. */
  31817. static readonly FOGMODE_LINEAR: number;
  31818. /**
  31819. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31820. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31821. */
  31822. static MinDeltaTime: number;
  31823. /**
  31824. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31825. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31826. */
  31827. static MaxDeltaTime: number;
  31828. /**
  31829. * Factory used to create the default material.
  31830. * @param name The name of the material to create
  31831. * @param scene The scene to create the material for
  31832. * @returns The default material
  31833. */
  31834. static DefaultMaterialFactory(scene: Scene): Material;
  31835. /**
  31836. * Factory used to create the a collision coordinator.
  31837. * @returns The collision coordinator
  31838. */
  31839. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31840. /** @hidden */
  31841. readonly _isScene: boolean;
  31842. /**
  31843. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31844. */
  31845. autoClear: boolean;
  31846. /**
  31847. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31848. */
  31849. autoClearDepthAndStencil: boolean;
  31850. /**
  31851. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31852. */
  31853. clearColor: Color4;
  31854. /**
  31855. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31856. */
  31857. ambientColor: Color3;
  31858. /** @hidden */
  31859. _environmentBRDFTexture: BaseTexture;
  31860. /** @hidden */
  31861. protected _environmentTexture: Nullable<BaseTexture>;
  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 reference from here than from all the materials.
  31866. */
  31867. /**
  31868. * Texture used in all pbr material as the reflection texture.
  31869. * As in the majority of the scene they are the same (exception for multi room and so on),
  31870. * this is easier to set here than in all the materials.
  31871. */
  31872. environmentTexture: Nullable<BaseTexture>;
  31873. /** @hidden */
  31874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31875. /**
  31876. * Default image processing configuration used either in the rendering
  31877. * Forward main pass or through the imageProcessingPostProcess if present.
  31878. * As in the majority of the scene they are the same (exception for multi camera),
  31879. * this is easier to reference from here than from all the materials and post process.
  31880. *
  31881. * No setter as we it is a shared configuration, you can set the values instead.
  31882. */
  31883. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31884. private _forceWireframe;
  31885. /**
  31886. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31887. */
  31888. forceWireframe: boolean;
  31889. private _forcePointsCloud;
  31890. /**
  31891. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31892. */
  31893. forcePointsCloud: boolean;
  31894. /**
  31895. * Gets or sets the active clipplane 1
  31896. */
  31897. clipPlane: Nullable<Plane>;
  31898. /**
  31899. * Gets or sets the active clipplane 2
  31900. */
  31901. clipPlane2: Nullable<Plane>;
  31902. /**
  31903. * Gets or sets the active clipplane 3
  31904. */
  31905. clipPlane3: Nullable<Plane>;
  31906. /**
  31907. * Gets or sets the active clipplane 4
  31908. */
  31909. clipPlane4: Nullable<Plane>;
  31910. /**
  31911. * Gets or sets a boolean indicating if animations are enabled
  31912. */
  31913. animationsEnabled: boolean;
  31914. private _animationPropertiesOverride;
  31915. /**
  31916. * Gets or sets the animation properties override
  31917. */
  31918. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31919. /**
  31920. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31921. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31922. */
  31923. useConstantAnimationDeltaTime: boolean;
  31924. /**
  31925. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31926. * Please note that it requires to run a ray cast through the scene on every frame
  31927. */
  31928. constantlyUpdateMeshUnderPointer: boolean;
  31929. /**
  31930. * Defines the HTML cursor to use when hovering over interactive elements
  31931. */
  31932. hoverCursor: string;
  31933. /**
  31934. * Defines the HTML default cursor to use (empty by default)
  31935. */
  31936. defaultCursor: string;
  31937. /**
  31938. * This is used to call preventDefault() on pointer down
  31939. * in order to block unwanted artifacts like system double clicks
  31940. */
  31941. preventDefaultOnPointerDown: boolean;
  31942. /**
  31943. * This is used to call preventDefault() on pointer up
  31944. * in order to block unwanted artifacts like system double clicks
  31945. */
  31946. preventDefaultOnPointerUp: boolean;
  31947. /**
  31948. * Gets or sets user defined metadata
  31949. */
  31950. metadata: any;
  31951. /**
  31952. * For internal use only. Please do not use.
  31953. */
  31954. reservedDataStore: any;
  31955. /**
  31956. * Gets the name of the plugin used to load this scene (null by default)
  31957. */
  31958. loadingPluginName: string;
  31959. /**
  31960. * Use this array to add regular expressions used to disable offline support for specific urls
  31961. */
  31962. disableOfflineSupportExceptionRules: RegExp[];
  31963. /**
  31964. * An event triggered when the scene is disposed.
  31965. */
  31966. onDisposeObservable: Observable<Scene>;
  31967. private _onDisposeObserver;
  31968. /** Sets a function to be executed when this scene is disposed. */
  31969. onDispose: () => void;
  31970. /**
  31971. * An event triggered before rendering the scene (right after animations and physics)
  31972. */
  31973. onBeforeRenderObservable: Observable<Scene>;
  31974. private _onBeforeRenderObserver;
  31975. /** Sets a function to be executed before rendering this scene */
  31976. beforeRender: Nullable<() => void>;
  31977. /**
  31978. * An event triggered after rendering the scene
  31979. */
  31980. onAfterRenderObservable: Observable<Scene>;
  31981. private _onAfterRenderObserver;
  31982. /** Sets a function to be executed after rendering this scene */
  31983. afterRender: Nullable<() => void>;
  31984. /**
  31985. * An event triggered before animating the scene
  31986. */
  31987. onBeforeAnimationsObservable: Observable<Scene>;
  31988. /**
  31989. * An event triggered after animations processing
  31990. */
  31991. onAfterAnimationsObservable: Observable<Scene>;
  31992. /**
  31993. * An event triggered before draw calls are ready to be sent
  31994. */
  31995. onBeforeDrawPhaseObservable: Observable<Scene>;
  31996. /**
  31997. * An event triggered after draw calls have been sent
  31998. */
  31999. onAfterDrawPhaseObservable: Observable<Scene>;
  32000. /**
  32001. * An event triggered when the scene is ready
  32002. */
  32003. onReadyObservable: Observable<Scene>;
  32004. /**
  32005. * An event triggered before rendering a camera
  32006. */
  32007. onBeforeCameraRenderObservable: Observable<Camera>;
  32008. private _onBeforeCameraRenderObserver;
  32009. /** Sets a function to be executed before rendering a camera*/
  32010. beforeCameraRender: () => void;
  32011. /**
  32012. * An event triggered after rendering a camera
  32013. */
  32014. onAfterCameraRenderObservable: Observable<Camera>;
  32015. private _onAfterCameraRenderObserver;
  32016. /** Sets a function to be executed after rendering a camera*/
  32017. afterCameraRender: () => void;
  32018. /**
  32019. * An event triggered when active meshes evaluation is about to start
  32020. */
  32021. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32022. /**
  32023. * An event triggered when active meshes evaluation is done
  32024. */
  32025. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32026. /**
  32027. * An event triggered when particles rendering is about to start
  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. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32031. /**
  32032. * An event triggered when particles rendering is done
  32033. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32034. */
  32035. onAfterParticlesRenderingObservable: Observable<Scene>;
  32036. /**
  32037. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32038. */
  32039. onDataLoadedObservable: Observable<Scene>;
  32040. /**
  32041. * An event triggered when a camera is created
  32042. */
  32043. onNewCameraAddedObservable: Observable<Camera>;
  32044. /**
  32045. * An event triggered when a camera is removed
  32046. */
  32047. onCameraRemovedObservable: Observable<Camera>;
  32048. /**
  32049. * An event triggered when a light is created
  32050. */
  32051. onNewLightAddedObservable: Observable<Light>;
  32052. /**
  32053. * An event triggered when a light is removed
  32054. */
  32055. onLightRemovedObservable: Observable<Light>;
  32056. /**
  32057. * An event triggered when a geometry is created
  32058. */
  32059. onNewGeometryAddedObservable: Observable<Geometry>;
  32060. /**
  32061. * An event triggered when a geometry is removed
  32062. */
  32063. onGeometryRemovedObservable: Observable<Geometry>;
  32064. /**
  32065. * An event triggered when a transform node is created
  32066. */
  32067. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32068. /**
  32069. * An event triggered when a transform node is removed
  32070. */
  32071. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32072. /**
  32073. * An event triggered when a mesh is created
  32074. */
  32075. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32076. /**
  32077. * An event triggered when a mesh is removed
  32078. */
  32079. onMeshRemovedObservable: Observable<AbstractMesh>;
  32080. /**
  32081. * An event triggered when a material is created
  32082. */
  32083. onNewMaterialAddedObservable: Observable<Material>;
  32084. /**
  32085. * An event triggered when a material is removed
  32086. */
  32087. onMaterialRemovedObservable: Observable<Material>;
  32088. /**
  32089. * An event triggered when a texture is created
  32090. */
  32091. onNewTextureAddedObservable: Observable<BaseTexture>;
  32092. /**
  32093. * An event triggered when a texture is removed
  32094. */
  32095. onTextureRemovedObservable: Observable<BaseTexture>;
  32096. /**
  32097. * An event triggered when render targets are about to be rendered
  32098. * Can happen multiple times per frame.
  32099. */
  32100. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32101. /**
  32102. * An event triggered when render targets were rendered.
  32103. * Can happen multiple times per frame.
  32104. */
  32105. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32106. /**
  32107. * An event triggered before calculating deterministic simulation step
  32108. */
  32109. onBeforeStepObservable: Observable<Scene>;
  32110. /**
  32111. * An event triggered after calculating deterministic simulation step
  32112. */
  32113. onAfterStepObservable: Observable<Scene>;
  32114. /**
  32115. * An event triggered when the activeCamera property is updated
  32116. */
  32117. onActiveCameraChanged: Observable<Scene>;
  32118. /**
  32119. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32120. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32121. * 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)
  32122. */
  32123. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32124. /**
  32125. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32126. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32127. * 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)
  32128. */
  32129. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32130. /**
  32131. * This Observable will when a mesh has been imported into the scene.
  32132. */
  32133. onMeshImportedObservable: Observable<AbstractMesh>;
  32134. /**
  32135. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32136. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32137. */
  32138. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32139. /** @hidden */
  32140. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32141. /**
  32142. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32143. */
  32144. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32145. /**
  32146. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32147. */
  32148. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32149. /**
  32150. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32151. */
  32152. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32153. private _onPointerMove;
  32154. private _onPointerDown;
  32155. private _onPointerUp;
  32156. /** Callback called when a pointer move is detected */
  32157. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32158. /** Callback called when a pointer down is detected */
  32159. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32160. /** Callback called when a pointer up is detected */
  32161. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32162. /** Callback called when a pointer pick is detected */
  32163. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32164. /**
  32165. * 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).
  32166. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32167. */
  32168. onPrePointerObservable: Observable<PointerInfoPre>;
  32169. /**
  32170. * Observable event triggered each time an input event is received from the rendering canvas
  32171. */
  32172. onPointerObservable: Observable<PointerInfo>;
  32173. /**
  32174. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32175. */
  32176. readonly unTranslatedPointer: Vector2;
  32177. /** The distance in pixel that you have to move to prevent some events */
  32178. static DragMovementThreshold: number;
  32179. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32180. static LongPressDelay: number;
  32181. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32182. static DoubleClickDelay: number;
  32183. /** If you need to check double click without raising a single click at first click, enable this flag */
  32184. static ExclusiveDoubleClickMode: boolean;
  32185. private _initClickEvent;
  32186. private _initActionManager;
  32187. private _delayedSimpleClick;
  32188. private _delayedSimpleClickTimeout;
  32189. private _previousDelayedSimpleClickTimeout;
  32190. private _meshPickProceed;
  32191. private _previousButtonPressed;
  32192. private _currentPickResult;
  32193. private _previousPickResult;
  32194. private _totalPointersPressed;
  32195. private _doubleClickOccured;
  32196. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32197. cameraToUseForPointers: Nullable<Camera>;
  32198. private _pointerX;
  32199. private _pointerY;
  32200. private _unTranslatedPointerX;
  32201. private _unTranslatedPointerY;
  32202. private _startingPointerPosition;
  32203. private _previousStartingPointerPosition;
  32204. private _startingPointerTime;
  32205. private _previousStartingPointerTime;
  32206. private _pointerCaptures;
  32207. private _timeAccumulator;
  32208. private _currentStepId;
  32209. private _currentInternalStep;
  32210. /** @hidden */
  32211. _mirroredCameraPosition: Nullable<Vector3>;
  32212. /**
  32213. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32214. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32215. */
  32216. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32217. /**
  32218. * Observable event triggered each time an keyboard event is received from the hosting window
  32219. */
  32220. onKeyboardObservable: Observable<KeyboardInfo>;
  32221. private _onKeyDown;
  32222. private _onKeyUp;
  32223. private _onCanvasFocusObserver;
  32224. private _onCanvasBlurObserver;
  32225. private _useRightHandedSystem;
  32226. /**
  32227. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32228. */
  32229. useRightHandedSystem: boolean;
  32230. /**
  32231. * Sets the step Id used by deterministic lock step
  32232. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32233. * @param newStepId defines the step Id
  32234. */
  32235. setStepId(newStepId: number): void;
  32236. /**
  32237. * Gets the step Id used by deterministic lock step
  32238. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32239. * @returns the step Id
  32240. */
  32241. getStepId(): number;
  32242. /**
  32243. * Gets the internal step used by deterministic lock step
  32244. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32245. * @returns the internal step
  32246. */
  32247. getInternalStep(): number;
  32248. private _fogEnabled;
  32249. /**
  32250. * Gets or sets a boolean indicating if fog is enabled on this scene
  32251. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32252. * (Default is true)
  32253. */
  32254. fogEnabled: boolean;
  32255. private _fogMode;
  32256. /**
  32257. * Gets or sets the fog mode to use
  32258. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32259. * | mode | value |
  32260. * | --- | --- |
  32261. * | FOGMODE_NONE | 0 |
  32262. * | FOGMODE_EXP | 1 |
  32263. * | FOGMODE_EXP2 | 2 |
  32264. * | FOGMODE_LINEAR | 3 |
  32265. */
  32266. fogMode: number;
  32267. /**
  32268. * Gets or sets the fog color to use
  32269. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32270. * (Default is Color3(0.2, 0.2, 0.3))
  32271. */
  32272. fogColor: Color3;
  32273. /**
  32274. * Gets or sets the fog density to use
  32275. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32276. * (Default is 0.1)
  32277. */
  32278. fogDensity: number;
  32279. /**
  32280. * Gets or sets the fog start distance to use
  32281. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32282. * (Default is 0)
  32283. */
  32284. fogStart: number;
  32285. /**
  32286. * Gets or sets the fog end distance to use
  32287. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32288. * (Default is 1000)
  32289. */
  32290. fogEnd: number;
  32291. private _shadowsEnabled;
  32292. /**
  32293. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32294. */
  32295. shadowsEnabled: boolean;
  32296. private _lightsEnabled;
  32297. /**
  32298. * Gets or sets a boolean indicating if lights are enabled on this scene
  32299. */
  32300. lightsEnabled: boolean;
  32301. /** All of the active cameras added to this scene. */
  32302. activeCameras: Camera[];
  32303. private _activeCamera;
  32304. /** Gets or sets the current active camera */
  32305. activeCamera: Nullable<Camera>;
  32306. private _defaultMaterial;
  32307. /** The default material used on meshes when no material is affected */
  32308. /** The default material used on meshes when no material is affected */
  32309. defaultMaterial: Material;
  32310. private _texturesEnabled;
  32311. /**
  32312. * Gets or sets a boolean indicating if textures are enabled on this scene
  32313. */
  32314. texturesEnabled: boolean;
  32315. /**
  32316. * Gets or sets a boolean indicating if particles are enabled on this scene
  32317. */
  32318. particlesEnabled: boolean;
  32319. /**
  32320. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32321. */
  32322. spritesEnabled: boolean;
  32323. private _skeletonsEnabled;
  32324. /**
  32325. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32326. */
  32327. skeletonsEnabled: boolean;
  32328. /**
  32329. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32330. */
  32331. lensFlaresEnabled: boolean;
  32332. /**
  32333. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32335. */
  32336. collisionsEnabled: boolean;
  32337. private _collisionCoordinator;
  32338. /** @hidden */
  32339. readonly collisionCoordinator: ICollisionCoordinator;
  32340. /**
  32341. * Defines the gravity applied to this scene (used only for collisions)
  32342. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32343. */
  32344. gravity: Vector3;
  32345. /**
  32346. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32347. */
  32348. postProcessesEnabled: boolean;
  32349. /**
  32350. * The list of postprocesses added to the scene
  32351. */
  32352. postProcesses: PostProcess[];
  32353. /**
  32354. * Gets the current postprocess manager
  32355. */
  32356. postProcessManager: PostProcessManager;
  32357. /**
  32358. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32359. */
  32360. renderTargetsEnabled: boolean;
  32361. /**
  32362. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32363. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32364. */
  32365. dumpNextRenderTargets: boolean;
  32366. /**
  32367. * The list of user defined render targets added to the scene
  32368. */
  32369. customRenderTargets: RenderTargetTexture[];
  32370. /**
  32371. * Defines if texture loading must be delayed
  32372. * If true, textures will only be loaded when they need to be rendered
  32373. */
  32374. useDelayedTextureLoading: boolean;
  32375. /**
  32376. * Gets the list of meshes imported to the scene through SceneLoader
  32377. */
  32378. importedMeshesFiles: String[];
  32379. /**
  32380. * Gets or sets a boolean indicating if probes are enabled on this scene
  32381. */
  32382. probesEnabled: boolean;
  32383. /**
  32384. * Gets or sets the current offline provider to use to store scene data
  32385. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32386. */
  32387. offlineProvider: IOfflineProvider;
  32388. /**
  32389. * Gets or sets the action manager associated with the scene
  32390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32391. */
  32392. actionManager: AbstractActionManager;
  32393. private _meshesForIntersections;
  32394. /**
  32395. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32396. */
  32397. proceduralTexturesEnabled: boolean;
  32398. private _engine;
  32399. private _totalVertices;
  32400. /** @hidden */
  32401. _activeIndices: PerfCounter;
  32402. /** @hidden */
  32403. _activeParticles: PerfCounter;
  32404. /** @hidden */
  32405. _activeBones: PerfCounter;
  32406. private _animationRatio;
  32407. /** @hidden */
  32408. _animationTimeLast: number;
  32409. /** @hidden */
  32410. _animationTime: number;
  32411. /**
  32412. * Gets or sets a general scale for animation speed
  32413. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32414. */
  32415. animationTimeScale: number;
  32416. /** @hidden */
  32417. _cachedMaterial: Nullable<Material>;
  32418. /** @hidden */
  32419. _cachedEffect: Nullable<Effect>;
  32420. /** @hidden */
  32421. _cachedVisibility: Nullable<number>;
  32422. private _renderId;
  32423. private _frameId;
  32424. private _executeWhenReadyTimeoutId;
  32425. private _intermediateRendering;
  32426. private _viewUpdateFlag;
  32427. private _projectionUpdateFlag;
  32428. private _alternateViewUpdateFlag;
  32429. private _alternateProjectionUpdateFlag;
  32430. /** @hidden */
  32431. _toBeDisposed: Nullable<IDisposable>[];
  32432. private _activeRequests;
  32433. /** @hidden */
  32434. _pendingData: any[];
  32435. private _isDisposed;
  32436. /**
  32437. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32438. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32439. */
  32440. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32441. private _activeMeshes;
  32442. private _processedMaterials;
  32443. private _renderTargets;
  32444. /** @hidden */
  32445. _activeParticleSystems: SmartArray<IParticleSystem>;
  32446. private _activeSkeletons;
  32447. private _softwareSkinnedMeshes;
  32448. private _renderingManager;
  32449. /** @hidden */
  32450. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32451. private _transformMatrix;
  32452. private _sceneUbo;
  32453. private _alternateSceneUbo;
  32454. private _viewMatrix;
  32455. private _projectionMatrix;
  32456. private _alternateViewMatrix;
  32457. private _alternateProjectionMatrix;
  32458. private _alternateTransformMatrix;
  32459. private _useAlternateCameraConfiguration;
  32460. private _alternateRendering;
  32461. private _wheelEventName;
  32462. /** @hidden */
  32463. _forcedViewPosition: Nullable<Vector3>;
  32464. /** @hidden */
  32465. readonly _isAlternateRenderingEnabled: boolean;
  32466. private _frustumPlanes;
  32467. /**
  32468. * Gets the list of frustum planes (built from the active camera)
  32469. */
  32470. readonly frustumPlanes: Plane[];
  32471. /**
  32472. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32473. * This is useful if there are more lights that the maximum simulteanous authorized
  32474. */
  32475. requireLightSorting: boolean;
  32476. /** @hidden */
  32477. readonly useMaterialMeshMap: boolean;
  32478. /** @hidden */
  32479. readonly useClonedMeshhMap: boolean;
  32480. private _pointerOverMesh;
  32481. private _pickedDownMesh;
  32482. private _pickedUpMesh;
  32483. private _externalData;
  32484. private _uid;
  32485. /**
  32486. * @hidden
  32487. * Backing store of defined scene components.
  32488. */
  32489. _components: ISceneComponent[];
  32490. /**
  32491. * @hidden
  32492. * Backing store of defined scene components.
  32493. */
  32494. _serializableComponents: ISceneSerializableComponent[];
  32495. /**
  32496. * List of components to register on the next registration step.
  32497. */
  32498. private _transientComponents;
  32499. /**
  32500. * Registers the transient components if needed.
  32501. */
  32502. private _registerTransientComponents;
  32503. /**
  32504. * @hidden
  32505. * Add a component to the scene.
  32506. * Note that the ccomponent could be registered on th next frame if this is called after
  32507. * the register component stage.
  32508. * @param component Defines the component to add to the scene
  32509. */
  32510. _addComponent(component: ISceneComponent): void;
  32511. /**
  32512. * @hidden
  32513. * Gets a component from the scene.
  32514. * @param name defines the name of the component to retrieve
  32515. * @returns the component or null if not present
  32516. */
  32517. _getComponent(name: string): Nullable<ISceneComponent>;
  32518. /**
  32519. * @hidden
  32520. * Defines the actions happening before camera updates.
  32521. */
  32522. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32523. /**
  32524. * @hidden
  32525. * Defines the actions happening before clear the canvas.
  32526. */
  32527. _beforeClearStage: Stage<SimpleStageAction>;
  32528. /**
  32529. * @hidden
  32530. * Defines the actions when collecting render targets for the frame.
  32531. */
  32532. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32533. /**
  32534. * @hidden
  32535. * Defines the actions happening for one camera in the frame.
  32536. */
  32537. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32538. /**
  32539. * @hidden
  32540. * Defines the actions happening during the per mesh ready checks.
  32541. */
  32542. _isReadyForMeshStage: Stage<MeshStageAction>;
  32543. /**
  32544. * @hidden
  32545. * Defines the actions happening before evaluate active mesh checks.
  32546. */
  32547. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32548. /**
  32549. * @hidden
  32550. * Defines the actions happening during the evaluate sub mesh checks.
  32551. */
  32552. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32553. /**
  32554. * @hidden
  32555. * Defines the actions happening during the active mesh stage.
  32556. */
  32557. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32558. /**
  32559. * @hidden
  32560. * Defines the actions happening during the per camera render target step.
  32561. */
  32562. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32563. /**
  32564. * @hidden
  32565. * Defines the actions happening just before the active camera is drawing.
  32566. */
  32567. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32568. /**
  32569. * @hidden
  32570. * Defines the actions happening just before a render target is drawing.
  32571. */
  32572. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32573. /**
  32574. * @hidden
  32575. * Defines the actions happening just before a rendering group is drawing.
  32576. */
  32577. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32578. /**
  32579. * @hidden
  32580. * Defines the actions happening just before a mesh is drawing.
  32581. */
  32582. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32583. /**
  32584. * @hidden
  32585. * Defines the actions happening just after a mesh has been drawn.
  32586. */
  32587. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32588. /**
  32589. * @hidden
  32590. * Defines the actions happening just after a rendering group has been drawn.
  32591. */
  32592. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32593. /**
  32594. * @hidden
  32595. * Defines the actions happening just after the active camera has been drawn.
  32596. */
  32597. _afterCameraDrawStage: Stage<CameraStageAction>;
  32598. /**
  32599. * @hidden
  32600. * Defines the actions happening just after a render target has been drawn.
  32601. */
  32602. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32603. /**
  32604. * @hidden
  32605. * Defines the actions happening just after rendering all cameras and computing intersections.
  32606. */
  32607. _afterRenderStage: Stage<SimpleStageAction>;
  32608. /**
  32609. * @hidden
  32610. * Defines the actions happening when a pointer move event happens.
  32611. */
  32612. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32613. /**
  32614. * @hidden
  32615. * Defines the actions happening when a pointer down event happens.
  32616. */
  32617. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32618. /**
  32619. * @hidden
  32620. * Defines the actions happening when a pointer up event happens.
  32621. */
  32622. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32623. /**
  32624. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32625. */
  32626. private geometriesByUniqueId;
  32627. /**
  32628. * Creates a new Scene
  32629. * @param engine defines the engine to use to render this scene
  32630. * @param options defines the scene options
  32631. */
  32632. constructor(engine: Engine, options?: SceneOptions);
  32633. private _defaultMeshCandidates;
  32634. /**
  32635. * @hidden
  32636. */
  32637. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32638. private _defaultSubMeshCandidates;
  32639. /**
  32640. * @hidden
  32641. */
  32642. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32643. /**
  32644. * Sets the default candidate providers for the scene.
  32645. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32646. * and getCollidingSubMeshCandidates to their default function
  32647. */
  32648. setDefaultCandidateProviders(): void;
  32649. /**
  32650. * Gets the mesh that is currently under the pointer
  32651. */
  32652. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32653. /**
  32654. * Gets or sets the current on-screen X position of the pointer
  32655. */
  32656. pointerX: number;
  32657. /**
  32658. * Gets or sets the current on-screen Y position of the pointer
  32659. */
  32660. pointerY: number;
  32661. /**
  32662. * Gets the cached material (ie. the latest rendered one)
  32663. * @returns the cached material
  32664. */
  32665. getCachedMaterial(): Nullable<Material>;
  32666. /**
  32667. * Gets the cached effect (ie. the latest rendered one)
  32668. * @returns the cached effect
  32669. */
  32670. getCachedEffect(): Nullable<Effect>;
  32671. /**
  32672. * Gets the cached visibility state (ie. the latest rendered one)
  32673. * @returns the cached visibility state
  32674. */
  32675. getCachedVisibility(): Nullable<number>;
  32676. /**
  32677. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32678. * @param material defines the current material
  32679. * @param effect defines the current effect
  32680. * @param visibility defines the current visibility state
  32681. * @returns true if one parameter is not cached
  32682. */
  32683. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32684. /**
  32685. * Gets the engine associated with the scene
  32686. * @returns an Engine
  32687. */
  32688. getEngine(): Engine;
  32689. /**
  32690. * Gets the total number of vertices rendered per frame
  32691. * @returns the total number of vertices rendered per frame
  32692. */
  32693. getTotalVertices(): number;
  32694. /**
  32695. * Gets the performance counter for total vertices
  32696. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32697. */
  32698. readonly totalVerticesPerfCounter: PerfCounter;
  32699. /**
  32700. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32701. * @returns the total number of active indices rendered per frame
  32702. */
  32703. getActiveIndices(): number;
  32704. /**
  32705. * Gets the performance counter for active indices
  32706. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32707. */
  32708. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32709. /**
  32710. * Gets the total number of active particles rendered per frame
  32711. * @returns the total number of active particles rendered per frame
  32712. */
  32713. getActiveParticles(): number;
  32714. /**
  32715. * Gets the performance counter for active particles
  32716. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32717. */
  32718. readonly activeParticlesPerfCounter: PerfCounter;
  32719. /**
  32720. * Gets the total number of active bones rendered per frame
  32721. * @returns the total number of active bones rendered per frame
  32722. */
  32723. getActiveBones(): number;
  32724. /**
  32725. * Gets the performance counter for active bones
  32726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32727. */
  32728. readonly activeBonesPerfCounter: PerfCounter;
  32729. /**
  32730. * Gets the array of active meshes
  32731. * @returns an array of AbstractMesh
  32732. */
  32733. getActiveMeshes(): SmartArray<AbstractMesh>;
  32734. /**
  32735. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32736. * @returns a number
  32737. */
  32738. getAnimationRatio(): number;
  32739. /**
  32740. * Gets an unique Id for the current render phase
  32741. * @returns a number
  32742. */
  32743. getRenderId(): number;
  32744. /**
  32745. * Gets an unique Id for the current frame
  32746. * @returns a number
  32747. */
  32748. getFrameId(): number;
  32749. /** Call this function if you want to manually increment the render Id*/
  32750. incrementRenderId(): void;
  32751. private _updatePointerPosition;
  32752. private _createUbo;
  32753. private _createAlternateUbo;
  32754. private _setRayOnPointerInfo;
  32755. /**
  32756. * Use this method to simulate a pointer move on a mesh
  32757. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32758. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32759. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32760. * @returns the current scene
  32761. */
  32762. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32763. private _processPointerMove;
  32764. private _checkPrePointerObservable;
  32765. /**
  32766. * Use this method to simulate a pointer down on a mesh
  32767. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32768. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32769. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32770. * @returns the current scene
  32771. */
  32772. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32773. private _processPointerDown;
  32774. /**
  32775. * Use this method to simulate a pointer up on a mesh
  32776. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32777. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32778. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32779. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32780. * @returns the current scene
  32781. */
  32782. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32783. private _processPointerUp;
  32784. /**
  32785. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32786. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32787. * @returns true if the pointer was captured
  32788. */
  32789. isPointerCaptured(pointerId?: number): boolean;
  32790. /** @hidden */
  32791. _isPointerSwiping(): boolean;
  32792. /**
  32793. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32794. * @param attachUp defines if you want to attach events to pointerup
  32795. * @param attachDown defines if you want to attach events to pointerdown
  32796. * @param attachMove defines if you want to attach events to pointermove
  32797. */
  32798. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32799. /** Detaches all event handlers*/
  32800. detachControl(): void;
  32801. /**
  32802. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32803. * Delay loaded resources are not taking in account
  32804. * @return true if all required resources are ready
  32805. */
  32806. isReady(): boolean;
  32807. /** Resets all cached information relative to material (including effect and visibility) */
  32808. resetCachedMaterial(): void;
  32809. /**
  32810. * Registers a function to be called before every frame render
  32811. * @param func defines the function to register
  32812. */
  32813. registerBeforeRender(func: () => void): void;
  32814. /**
  32815. * Unregisters a function called before every frame render
  32816. * @param func defines the function to unregister
  32817. */
  32818. unregisterBeforeRender(func: () => void): void;
  32819. /**
  32820. * Registers a function to be called after every frame render
  32821. * @param func defines the function to register
  32822. */
  32823. registerAfterRender(func: () => void): void;
  32824. /**
  32825. * Unregisters a function called after every frame render
  32826. * @param func defines the function to unregister
  32827. */
  32828. unregisterAfterRender(func: () => void): void;
  32829. private _executeOnceBeforeRender;
  32830. /**
  32831. * The provided function will run before render once and will be disposed afterwards.
  32832. * A timeout delay can be provided so that the function will be executed in N ms.
  32833. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32834. * @param func The function to be executed.
  32835. * @param timeout optional delay in ms
  32836. */
  32837. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32838. /** @hidden */
  32839. _addPendingData(data: any): void;
  32840. /** @hidden */
  32841. _removePendingData(data: any): void;
  32842. /**
  32843. * Returns the number of items waiting to be loaded
  32844. * @returns the number of items waiting to be loaded
  32845. */
  32846. getWaitingItemsCount(): number;
  32847. /**
  32848. * Returns a boolean indicating if the scene is still loading data
  32849. */
  32850. readonly isLoading: boolean;
  32851. /**
  32852. * Registers a function to be executed when the scene is ready
  32853. * @param {Function} func - the function to be executed
  32854. */
  32855. executeWhenReady(func: () => void): void;
  32856. /**
  32857. * Returns a promise that resolves when the scene is ready
  32858. * @returns A promise that resolves when the scene is ready
  32859. */
  32860. whenReadyAsync(): Promise<void>;
  32861. /** @hidden */
  32862. _checkIsReady(): void;
  32863. /**
  32864. * Gets all animatable attached to the scene
  32865. */
  32866. readonly animatables: Animatable[];
  32867. /**
  32868. * Resets the last animation time frame.
  32869. * Useful to override when animations start running when loading a scene for the first time.
  32870. */
  32871. resetLastAnimationTimeFrame(): void;
  32872. /** @hidden */
  32873. _switchToAlternateCameraConfiguration(active: boolean): void;
  32874. /**
  32875. * Gets the current view matrix
  32876. * @returns a Matrix
  32877. */
  32878. getViewMatrix(): Matrix;
  32879. /**
  32880. * Gets the current projection matrix
  32881. * @returns a Matrix
  32882. */
  32883. getProjectionMatrix(): Matrix;
  32884. /**
  32885. * Gets the current transform matrix
  32886. * @returns a Matrix made of View * Projection
  32887. */
  32888. getTransformMatrix(): Matrix;
  32889. /**
  32890. * Sets the current transform matrix
  32891. * @param view defines the View matrix to use
  32892. * @param projection defines the Projection matrix to use
  32893. */
  32894. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32895. /** @hidden */
  32896. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32897. /**
  32898. * Gets the uniform buffer used to store scene data
  32899. * @returns a UniformBuffer
  32900. */
  32901. getSceneUniformBuffer(): UniformBuffer;
  32902. /**
  32903. * Gets an unique (relatively to the current scene) Id
  32904. * @returns an unique number for the scene
  32905. */
  32906. getUniqueId(): number;
  32907. /**
  32908. * Add a mesh to the list of scene's meshes
  32909. * @param newMesh defines the mesh to add
  32910. * @param recursive if all child meshes should also be added to the scene
  32911. */
  32912. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32913. /**
  32914. * Remove a mesh for the list of scene's meshes
  32915. * @param toRemove defines the mesh to remove
  32916. * @param recursive if all child meshes should also be removed from the scene
  32917. * @returns the index where the mesh was in the mesh list
  32918. */
  32919. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32920. /**
  32921. * Add a transform node to the list of scene's transform nodes
  32922. * @param newTransformNode defines the transform node to add
  32923. */
  32924. addTransformNode(newTransformNode: TransformNode): void;
  32925. /**
  32926. * Remove a transform node for the list of scene's transform nodes
  32927. * @param toRemove defines the transform node to remove
  32928. * @returns the index where the transform node was in the transform node list
  32929. */
  32930. removeTransformNode(toRemove: TransformNode): number;
  32931. /**
  32932. * Remove a skeleton for the list of scene's skeletons
  32933. * @param toRemove defines the skeleton to remove
  32934. * @returns the index where the skeleton was in the skeleton list
  32935. */
  32936. removeSkeleton(toRemove: Skeleton): number;
  32937. /**
  32938. * Remove a morph target for the list of scene's morph targets
  32939. * @param toRemove defines the morph target to remove
  32940. * @returns the index where the morph target was in the morph target list
  32941. */
  32942. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32943. /**
  32944. * Remove a light for the list of scene's lights
  32945. * @param toRemove defines the light to remove
  32946. * @returns the index where the light was in the light list
  32947. */
  32948. removeLight(toRemove: Light): number;
  32949. /**
  32950. * Remove a camera for the list of scene's cameras
  32951. * @param toRemove defines the camera to remove
  32952. * @returns the index where the camera was in the camera list
  32953. */
  32954. removeCamera(toRemove: Camera): number;
  32955. /**
  32956. * Remove a particle system for the list of scene's particle systems
  32957. * @param toRemove defines the particle system to remove
  32958. * @returns the index where the particle system was in the particle system list
  32959. */
  32960. removeParticleSystem(toRemove: IParticleSystem): number;
  32961. /**
  32962. * Remove a animation for the list of scene's animations
  32963. * @param toRemove defines the animation to remove
  32964. * @returns the index where the animation was in the animation list
  32965. */
  32966. removeAnimation(toRemove: Animation): number;
  32967. /**
  32968. * Removes the given animation group from this scene.
  32969. * @param toRemove The animation group to remove
  32970. * @returns The index of the removed animation group
  32971. */
  32972. removeAnimationGroup(toRemove: AnimationGroup): number;
  32973. /**
  32974. * Removes the given multi-material from this scene.
  32975. * @param toRemove The multi-material to remove
  32976. * @returns The index of the removed multi-material
  32977. */
  32978. removeMultiMaterial(toRemove: MultiMaterial): number;
  32979. /**
  32980. * Removes the given material from this scene.
  32981. * @param toRemove The material to remove
  32982. * @returns The index of the removed material
  32983. */
  32984. removeMaterial(toRemove: Material): number;
  32985. /**
  32986. * Removes the given action manager from this scene.
  32987. * @param toRemove The action manager to remove
  32988. * @returns The index of the removed action manager
  32989. */
  32990. removeActionManager(toRemove: AbstractActionManager): number;
  32991. /**
  32992. * Removes the given texture from this scene.
  32993. * @param toRemove The texture to remove
  32994. * @returns The index of the removed texture
  32995. */
  32996. removeTexture(toRemove: BaseTexture): number;
  32997. /**
  32998. * Adds the given light to this scene
  32999. * @param newLight The light to add
  33000. */
  33001. addLight(newLight: Light): void;
  33002. /**
  33003. * Sorts the list list based on light priorities
  33004. */
  33005. sortLightsByPriority(): void;
  33006. /**
  33007. * Adds the given camera to this scene
  33008. * @param newCamera The camera to add
  33009. */
  33010. addCamera(newCamera: Camera): void;
  33011. /**
  33012. * Adds the given skeleton to this scene
  33013. * @param newSkeleton The skeleton to add
  33014. */
  33015. addSkeleton(newSkeleton: Skeleton): void;
  33016. /**
  33017. * Adds the given particle system to this scene
  33018. * @param newParticleSystem The particle system to add
  33019. */
  33020. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33021. /**
  33022. * Adds the given animation to this scene
  33023. * @param newAnimation The animation to add
  33024. */
  33025. addAnimation(newAnimation: Animation): void;
  33026. /**
  33027. * Adds the given animation group to this scene.
  33028. * @param newAnimationGroup The animation group to add
  33029. */
  33030. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33031. /**
  33032. * Adds the given multi-material to this scene
  33033. * @param newMultiMaterial The multi-material to add
  33034. */
  33035. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33036. /**
  33037. * Adds the given material to this scene
  33038. * @param newMaterial The material to add
  33039. */
  33040. addMaterial(newMaterial: Material): void;
  33041. /**
  33042. * Adds the given morph target to this scene
  33043. * @param newMorphTargetManager The morph target to add
  33044. */
  33045. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33046. /**
  33047. * Adds the given geometry to this scene
  33048. * @param newGeometry The geometry to add
  33049. */
  33050. addGeometry(newGeometry: Geometry): void;
  33051. /**
  33052. * Adds the given action manager to this scene
  33053. * @param newActionManager The action manager to add
  33054. */
  33055. addActionManager(newActionManager: AbstractActionManager): void;
  33056. /**
  33057. * Adds the given texture to this scene.
  33058. * @param newTexture The texture to add
  33059. */
  33060. addTexture(newTexture: BaseTexture): void;
  33061. /**
  33062. * Switch active camera
  33063. * @param newCamera defines the new active camera
  33064. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33065. */
  33066. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33067. /**
  33068. * sets the active camera of the scene using its ID
  33069. * @param id defines the camera's ID
  33070. * @return the new active camera or null if none found.
  33071. */
  33072. setActiveCameraByID(id: string): Nullable<Camera>;
  33073. /**
  33074. * sets the active camera of the scene using its name
  33075. * @param name defines the camera's name
  33076. * @returns the new active camera or null if none found.
  33077. */
  33078. setActiveCameraByName(name: string): Nullable<Camera>;
  33079. /**
  33080. * get an animation group using its name
  33081. * @param name defines the material's name
  33082. * @return the animation group or null if none found.
  33083. */
  33084. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33085. /**
  33086. * get a material using its id
  33087. * @param id defines the material's ID
  33088. * @return the material or null if none found.
  33089. */
  33090. getMaterialByID(id: string): Nullable<Material>;
  33091. /**
  33092. * Gets a material using its name
  33093. * @param name defines the material's name
  33094. * @return the material or null if none found.
  33095. */
  33096. getMaterialByName(name: string): Nullable<Material>;
  33097. /**
  33098. * Gets a camera using its id
  33099. * @param id defines the id to look for
  33100. * @returns the camera or null if not found
  33101. */
  33102. getCameraByID(id: string): Nullable<Camera>;
  33103. /**
  33104. * Gets a camera using its unique id
  33105. * @param uniqueId defines the unique id to look for
  33106. * @returns the camera or null if not found
  33107. */
  33108. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33109. /**
  33110. * Gets a camera using its name
  33111. * @param name defines the camera's name
  33112. * @return the camera or null if none found.
  33113. */
  33114. getCameraByName(name: string): Nullable<Camera>;
  33115. /**
  33116. * Gets a bone using its id
  33117. * @param id defines the bone's id
  33118. * @return the bone or null if not found
  33119. */
  33120. getBoneByID(id: string): Nullable<Bone>;
  33121. /**
  33122. * Gets a bone using its id
  33123. * @param name defines the bone's name
  33124. * @return the bone or null if not found
  33125. */
  33126. getBoneByName(name: string): Nullable<Bone>;
  33127. /**
  33128. * Gets a light node using its name
  33129. * @param name defines the the light's name
  33130. * @return the light or null if none found.
  33131. */
  33132. getLightByName(name: string): Nullable<Light>;
  33133. /**
  33134. * Gets a light node using its id
  33135. * @param id defines the light's id
  33136. * @return the light or null if none found.
  33137. */
  33138. getLightByID(id: string): Nullable<Light>;
  33139. /**
  33140. * Gets a light node using its scene-generated unique ID
  33141. * @param uniqueId defines the light's unique id
  33142. * @return the light or null if none found.
  33143. */
  33144. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33145. /**
  33146. * Gets a particle system by id
  33147. * @param id defines the particle system id
  33148. * @return the corresponding system or null if none found
  33149. */
  33150. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33151. /**
  33152. * Gets a geometry using its ID
  33153. * @param id defines the geometry's id
  33154. * @return the geometry or null if none found.
  33155. */
  33156. getGeometryByID(id: string): Nullable<Geometry>;
  33157. private _getGeometryByUniqueID;
  33158. /**
  33159. * Add a new geometry to this scene
  33160. * @param geometry defines the geometry to be added to the scene.
  33161. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33162. * @return a boolean defining if the geometry was added or not
  33163. */
  33164. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33165. /**
  33166. * Removes an existing geometry
  33167. * @param geometry defines the geometry to be removed from the scene
  33168. * @return a boolean defining if the geometry was removed or not
  33169. */
  33170. removeGeometry(geometry: Geometry): boolean;
  33171. /**
  33172. * Gets the list of geometries attached to the scene
  33173. * @returns an array of Geometry
  33174. */
  33175. getGeometries(): Geometry[];
  33176. /**
  33177. * Gets the first added mesh found of a given ID
  33178. * @param id defines the id to search for
  33179. * @return the mesh found or null if not found at all
  33180. */
  33181. getMeshByID(id: string): Nullable<AbstractMesh>;
  33182. /**
  33183. * Gets a list of meshes using their id
  33184. * @param id defines the id to search for
  33185. * @returns a list of meshes
  33186. */
  33187. getMeshesByID(id: string): Array<AbstractMesh>;
  33188. /**
  33189. * Gets the first added transform node found of a given ID
  33190. * @param id defines the id to search for
  33191. * @return the found transform node or null if not found at all.
  33192. */
  33193. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33194. /**
  33195. * Gets a list of transform nodes using their id
  33196. * @param id defines the id to search for
  33197. * @returns a list of transform nodes
  33198. */
  33199. getTransformNodesByID(id: string): Array<TransformNode>;
  33200. /**
  33201. * Gets a mesh with its auto-generated unique id
  33202. * @param uniqueId defines the unique id to search for
  33203. * @return the found mesh or null if not found at all.
  33204. */
  33205. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33206. /**
  33207. * Gets a the last added mesh using a given id
  33208. * @param id defines the id to search for
  33209. * @return the found mesh or null if not found at all.
  33210. */
  33211. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33212. /**
  33213. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33214. * @param id defines the id to search for
  33215. * @return the found node or null if not found at all
  33216. */
  33217. getLastEntryByID(id: string): Nullable<Node>;
  33218. /**
  33219. * Gets a node (Mesh, Camera, Light) using a given id
  33220. * @param id defines the id to search for
  33221. * @return the found node or null if not found at all
  33222. */
  33223. getNodeByID(id: string): Nullable<Node>;
  33224. /**
  33225. * Gets a node (Mesh, Camera, Light) using a given name
  33226. * @param name defines the name to search for
  33227. * @return the found node or null if not found at all.
  33228. */
  33229. getNodeByName(name: string): Nullable<Node>;
  33230. /**
  33231. * Gets a mesh using a given name
  33232. * @param name defines the name to search for
  33233. * @return the found mesh or null if not found at all.
  33234. */
  33235. getMeshByName(name: string): Nullable<AbstractMesh>;
  33236. /**
  33237. * Gets a transform node using a given name
  33238. * @param name defines the name to search for
  33239. * @return the found transform node or null if not found at all.
  33240. */
  33241. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33242. /**
  33243. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33244. * @param id defines the id to search for
  33245. * @return the found skeleton or null if not found at all.
  33246. */
  33247. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33248. /**
  33249. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33250. * @param id defines the id to search for
  33251. * @return the found skeleton or null if not found at all.
  33252. */
  33253. getSkeletonById(id: string): Nullable<Skeleton>;
  33254. /**
  33255. * Gets a skeleton using a given name
  33256. * @param name defines the name to search for
  33257. * @return the found skeleton or null if not found at all.
  33258. */
  33259. getSkeletonByName(name: string): Nullable<Skeleton>;
  33260. /**
  33261. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33262. * @param id defines the id to search for
  33263. * @return the found morph target manager or null if not found at all.
  33264. */
  33265. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33266. /**
  33267. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33268. * @param id defines the id to search for
  33269. * @return the found morph target or null if not found at all.
  33270. */
  33271. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33272. /**
  33273. * Gets a boolean indicating if the given mesh is active
  33274. * @param mesh defines the mesh to look for
  33275. * @returns true if the mesh is in the active list
  33276. */
  33277. isActiveMesh(mesh: AbstractMesh): boolean;
  33278. /**
  33279. * Return a unique id as a string which can serve as an identifier for the scene
  33280. */
  33281. readonly uid: string;
  33282. /**
  33283. * Add an externaly attached data from its key.
  33284. * This method call will fail and return false, if such key already exists.
  33285. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33286. * @param key the unique key that identifies the data
  33287. * @param data the data object to associate to the key for this Engine instance
  33288. * @return true if no such key were already present and the data was added successfully, false otherwise
  33289. */
  33290. addExternalData<T>(key: string, data: T): boolean;
  33291. /**
  33292. * Get an externaly attached data from its key
  33293. * @param key the unique key that identifies the data
  33294. * @return the associated data, if present (can be null), or undefined if not present
  33295. */
  33296. getExternalData<T>(key: string): Nullable<T>;
  33297. /**
  33298. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33299. * @param key the unique key that identifies the data
  33300. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33301. * @return the associated data, can be null if the factory returned null.
  33302. */
  33303. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33304. /**
  33305. * Remove an externaly attached data from the Engine instance
  33306. * @param key the unique key that identifies the data
  33307. * @return true if the data was successfully removed, false if it doesn't exist
  33308. */
  33309. removeExternalData(key: string): boolean;
  33310. private _evaluateSubMesh;
  33311. /**
  33312. * Clear the processed materials smart array preventing retention point in material dispose.
  33313. */
  33314. freeProcessedMaterials(): void;
  33315. private _preventFreeActiveMeshesAndRenderingGroups;
  33316. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33317. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33318. * when disposing several meshes in a row or a hierarchy of meshes.
  33319. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33320. */
  33321. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33322. /**
  33323. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33324. */
  33325. freeActiveMeshes(): void;
  33326. /**
  33327. * Clear the info related to rendering groups preventing retention points during dispose.
  33328. */
  33329. freeRenderingGroups(): void;
  33330. /** @hidden */
  33331. _isInIntermediateRendering(): boolean;
  33332. /**
  33333. * Lambda returning the list of potentially active meshes.
  33334. */
  33335. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33336. /**
  33337. * Lambda returning the list of potentially active sub meshes.
  33338. */
  33339. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33340. /**
  33341. * Lambda returning the list of potentially intersecting sub meshes.
  33342. */
  33343. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33344. /**
  33345. * Lambda returning the list of potentially colliding sub meshes.
  33346. */
  33347. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33348. private _activeMeshesFrozen;
  33349. /**
  33350. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33351. * @returns the current scene
  33352. */
  33353. freezeActiveMeshes(): Scene;
  33354. /**
  33355. * Use this function to restart evaluating active meshes on every frame
  33356. * @returns the current scene
  33357. */
  33358. unfreezeActiveMeshes(): Scene;
  33359. private _evaluateActiveMeshes;
  33360. private _activeMesh;
  33361. /**
  33362. * Update the transform matrix to update from the current active camera
  33363. * @param force defines a boolean used to force the update even if cache is up to date
  33364. */
  33365. updateTransformMatrix(force?: boolean): void;
  33366. /**
  33367. * 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)
  33368. * @param alternateCamera defines the camera to use
  33369. */
  33370. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33371. /** @hidden */
  33372. _allowPostProcessClearColor: boolean;
  33373. private _renderForCamera;
  33374. private _processSubCameras;
  33375. private _checkIntersections;
  33376. /** @hidden */
  33377. _advancePhysicsEngineStep(step: number): void;
  33378. /**
  33379. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33380. */
  33381. getDeterministicFrameTime: () => number;
  33382. /** @hidden */
  33383. _animate(): void;
  33384. /**
  33385. * Render the scene
  33386. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33387. */
  33388. render(updateCameras?: boolean): void;
  33389. /**
  33390. * Freeze all materials
  33391. * A frozen material will not be updatable but should be faster to render
  33392. */
  33393. freezeMaterials(): void;
  33394. /**
  33395. * Unfreeze all materials
  33396. * A frozen material will not be updatable but should be faster to render
  33397. */
  33398. unfreezeMaterials(): void;
  33399. /**
  33400. * Releases all held ressources
  33401. */
  33402. dispose(): void;
  33403. /**
  33404. * Gets if the scene is already disposed
  33405. */
  33406. readonly isDisposed: boolean;
  33407. /**
  33408. * Call this function to reduce memory footprint of the scene.
  33409. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33410. */
  33411. clearCachedVertexData(): void;
  33412. /**
  33413. * This function will remove the local cached buffer data from texture.
  33414. * It will save memory but will prevent the texture from being rebuilt
  33415. */
  33416. cleanCachedTextureBuffer(): void;
  33417. /**
  33418. * Get the world extend vectors with an optional filter
  33419. *
  33420. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33421. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33422. */
  33423. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33424. min: Vector3;
  33425. max: Vector3;
  33426. };
  33427. /**
  33428. * Creates a ray that can be used to pick in the scene
  33429. * @param x defines the x coordinate of the origin (on-screen)
  33430. * @param y defines the y coordinate of the origin (on-screen)
  33431. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33432. * @param camera defines the camera to use for the picking
  33433. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33434. * @returns a Ray
  33435. */
  33436. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33437. /**
  33438. * Creates a ray that can be used to pick in the scene
  33439. * @param x defines the x coordinate of the origin (on-screen)
  33440. * @param y defines the y coordinate of the origin (on-screen)
  33441. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33442. * @param result defines the ray where to store the picking ray
  33443. * @param camera defines the camera to use for the picking
  33444. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33445. * @returns the current scene
  33446. */
  33447. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33448. /**
  33449. * Creates a ray that can be used to pick in the scene
  33450. * @param x defines the x coordinate of the origin (on-screen)
  33451. * @param y defines the y coordinate of the origin (on-screen)
  33452. * @param camera defines the camera to use for the picking
  33453. * @returns a Ray
  33454. */
  33455. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33456. /**
  33457. * Creates a ray that can be used to pick in the scene
  33458. * @param x defines the x coordinate of the origin (on-screen)
  33459. * @param y defines the y coordinate of the origin (on-screen)
  33460. * @param result defines the ray where to store the picking ray
  33461. * @param camera defines the camera to use for the picking
  33462. * @returns the current scene
  33463. */
  33464. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33465. /** Launch a ray to try to pick a mesh in the scene
  33466. * @param x position on screen
  33467. * @param y position on screen
  33468. * @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
  33469. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33470. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33471. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33472. * @returns a PickingInfo
  33473. */
  33474. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33475. /** Use the given ray to pick a mesh in the scene
  33476. * @param ray The ray to use to pick meshes
  33477. * @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
  33478. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33479. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33480. * @returns a PickingInfo
  33481. */
  33482. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33483. /**
  33484. * Launch a ray to try to pick a mesh in the scene
  33485. * @param x X position on screen
  33486. * @param y Y position on screen
  33487. * @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
  33488. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33489. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33490. * @returns an array of PickingInfo
  33491. */
  33492. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33493. /**
  33494. * Launch a ray to try to pick a mesh in the scene
  33495. * @param ray Ray to use
  33496. * @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
  33497. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33498. * @returns an array of PickingInfo
  33499. */
  33500. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33501. /**
  33502. * Force the value of meshUnderPointer
  33503. * @param mesh defines the mesh to use
  33504. */
  33505. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33506. /**
  33507. * Gets the mesh under the pointer
  33508. * @returns a Mesh or null if no mesh is under the pointer
  33509. */
  33510. getPointerOverMesh(): Nullable<AbstractMesh>;
  33511. /** @hidden */
  33512. _rebuildGeometries(): void;
  33513. /** @hidden */
  33514. _rebuildTextures(): void;
  33515. private _getByTags;
  33516. /**
  33517. * Get a list of meshes by tags
  33518. * @param tagsQuery defines the tags query to use
  33519. * @param forEach defines a predicate used to filter results
  33520. * @returns an array of Mesh
  33521. */
  33522. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33523. /**
  33524. * Get a list of cameras by tags
  33525. * @param tagsQuery defines the tags query to use
  33526. * @param forEach defines a predicate used to filter results
  33527. * @returns an array of Camera
  33528. */
  33529. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33530. /**
  33531. * Get a list of lights by tags
  33532. * @param tagsQuery defines the tags query to use
  33533. * @param forEach defines a predicate used to filter results
  33534. * @returns an array of Light
  33535. */
  33536. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33537. /**
  33538. * Get a list of materials by tags
  33539. * @param tagsQuery defines the tags query to use
  33540. * @param forEach defines a predicate used to filter results
  33541. * @returns an array of Material
  33542. */
  33543. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33544. /**
  33545. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33546. * This allowed control for front to back rendering or reversly depending of the special needs.
  33547. *
  33548. * @param renderingGroupId The rendering group id corresponding to its index
  33549. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33550. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33551. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33552. */
  33553. 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;
  33554. /**
  33555. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33556. *
  33557. * @param renderingGroupId The rendering group id corresponding to its index
  33558. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33559. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33560. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33561. */
  33562. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33563. /**
  33564. * Gets the current auto clear configuration for one rendering group of the rendering
  33565. * manager.
  33566. * @param index the rendering group index to get the information for
  33567. * @returns The auto clear setup for the requested rendering group
  33568. */
  33569. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33570. private _blockMaterialDirtyMechanism;
  33571. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33572. blockMaterialDirtyMechanism: boolean;
  33573. /**
  33574. * Will flag all materials as dirty to trigger new shader compilation
  33575. * @param flag defines the flag used to specify which material part must be marked as dirty
  33576. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33577. */
  33578. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33579. /** @hidden */
  33580. _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;
  33581. /** @hidden */
  33582. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33583. }
  33584. }
  33585. declare module "babylonjs/assetContainer" {
  33586. import { AbstractScene } from "babylonjs/abstractScene";
  33587. import { Scene } from "babylonjs/scene";
  33588. import { Mesh } from "babylonjs/Meshes/mesh";
  33589. /**
  33590. * Set of assets to keep when moving a scene into an asset container.
  33591. */
  33592. export class KeepAssets extends AbstractScene {
  33593. }
  33594. /**
  33595. * Container with a set of assets that can be added or removed from a scene.
  33596. */
  33597. export class AssetContainer extends AbstractScene {
  33598. /**
  33599. * The scene the AssetContainer belongs to.
  33600. */
  33601. scene: Scene;
  33602. /**
  33603. * Instantiates an AssetContainer.
  33604. * @param scene The scene the AssetContainer belongs to.
  33605. */
  33606. constructor(scene: Scene);
  33607. /**
  33608. * Adds all the assets from the container to the scene.
  33609. */
  33610. addAllToScene(): void;
  33611. /**
  33612. * Removes all the assets in the container from the scene
  33613. */
  33614. removeAllFromScene(): void;
  33615. /**
  33616. * Disposes all the assets in the container
  33617. */
  33618. dispose(): void;
  33619. private _moveAssets;
  33620. /**
  33621. * Removes all the assets contained in the scene and adds them to the container.
  33622. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33623. */
  33624. moveAllFromScene(keepAssets?: KeepAssets): void;
  33625. /**
  33626. * 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.
  33627. * @returns the root mesh
  33628. */
  33629. createRootMesh(): Mesh;
  33630. }
  33631. }
  33632. declare module "babylonjs/abstractScene" {
  33633. import { Scene } from "babylonjs/scene";
  33634. import { Nullable } from "babylonjs/types";
  33635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33636. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33637. import { Geometry } from "babylonjs/Meshes/geometry";
  33638. import { Skeleton } from "babylonjs/Bones/skeleton";
  33639. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33640. import { AssetContainer } from "babylonjs/assetContainer";
  33641. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33642. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33644. import { Material } from "babylonjs/Materials/material";
  33645. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33646. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33647. import { Camera } from "babylonjs/Cameras/camera";
  33648. import { Light } from "babylonjs/Lights/light";
  33649. import { Node } from "babylonjs/node";
  33650. import { Animation } from "babylonjs/Animations/animation";
  33651. /**
  33652. * Defines how the parser contract is defined.
  33653. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33654. */
  33655. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33656. /**
  33657. * Defines how the individual parser contract is defined.
  33658. * These parser can parse an individual asset
  33659. */
  33660. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33661. /**
  33662. * Base class of the scene acting as a container for the different elements composing a scene.
  33663. * This class is dynamically extended by the different components of the scene increasing
  33664. * flexibility and reducing coupling
  33665. */
  33666. export abstract class AbstractScene {
  33667. /**
  33668. * Stores the list of available parsers in the application.
  33669. */
  33670. private static _BabylonFileParsers;
  33671. /**
  33672. * Stores the list of available individual parsers in the application.
  33673. */
  33674. private static _IndividualBabylonFileParsers;
  33675. /**
  33676. * Adds a parser in the list of available ones
  33677. * @param name Defines the name of the parser
  33678. * @param parser Defines the parser to add
  33679. */
  33680. static AddParser(name: string, parser: BabylonFileParser): void;
  33681. /**
  33682. * Gets a general parser from the list of avaialble ones
  33683. * @param name Defines the name of the parser
  33684. * @returns the requested parser or null
  33685. */
  33686. static GetParser(name: string): Nullable<BabylonFileParser>;
  33687. /**
  33688. * Adds n individual parser in the list of available ones
  33689. * @param name Defines the name of the parser
  33690. * @param parser Defines the parser to add
  33691. */
  33692. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33693. /**
  33694. * Gets an individual parser from the list of avaialble ones
  33695. * @param name Defines the name of the parser
  33696. * @returns the requested parser or null
  33697. */
  33698. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33699. /**
  33700. * Parser json data and populate both a scene and its associated container object
  33701. * @param jsonData Defines the data to parse
  33702. * @param scene Defines the scene to parse the data for
  33703. * @param container Defines the container attached to the parsing sequence
  33704. * @param rootUrl Defines the root url of the data
  33705. */
  33706. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33707. /**
  33708. * Gets the list of root nodes (ie. nodes with no parent)
  33709. */
  33710. rootNodes: Node[];
  33711. /** All of the cameras added to this scene
  33712. * @see http://doc.babylonjs.com/babylon101/cameras
  33713. */
  33714. cameras: Camera[];
  33715. /**
  33716. * All of the lights added to this scene
  33717. * @see http://doc.babylonjs.com/babylon101/lights
  33718. */
  33719. lights: Light[];
  33720. /**
  33721. * All of the (abstract) meshes added to this scene
  33722. */
  33723. meshes: AbstractMesh[];
  33724. /**
  33725. * The list of skeletons added to the scene
  33726. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33727. */
  33728. skeletons: Skeleton[];
  33729. /**
  33730. * All of the particle systems added to this scene
  33731. * @see http://doc.babylonjs.com/babylon101/particles
  33732. */
  33733. particleSystems: IParticleSystem[];
  33734. /**
  33735. * Gets a list of Animations associated with the scene
  33736. */
  33737. animations: Animation[];
  33738. /**
  33739. * All of the animation groups added to this scene
  33740. * @see http://doc.babylonjs.com/how_to/group
  33741. */
  33742. animationGroups: AnimationGroup[];
  33743. /**
  33744. * All of the multi-materials added to this scene
  33745. * @see http://doc.babylonjs.com/how_to/multi_materials
  33746. */
  33747. multiMaterials: MultiMaterial[];
  33748. /**
  33749. * All of the materials added to this scene
  33750. * In the context of a Scene, it is not supposed to be modified manually.
  33751. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33752. * Note also that the order of the Material wihin the array is not significant and might change.
  33753. * @see http://doc.babylonjs.com/babylon101/materials
  33754. */
  33755. materials: Material[];
  33756. /**
  33757. * The list of morph target managers added to the scene
  33758. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33759. */
  33760. morphTargetManagers: MorphTargetManager[];
  33761. /**
  33762. * The list of geometries used in the scene.
  33763. */
  33764. geometries: Geometry[];
  33765. /**
  33766. * All of the tranform nodes added to this scene
  33767. * In the context of a Scene, it is not supposed to be modified manually.
  33768. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33769. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33770. * @see http://doc.babylonjs.com/how_to/transformnode
  33771. */
  33772. transformNodes: TransformNode[];
  33773. /**
  33774. * ActionManagers available on the scene.
  33775. */
  33776. actionManagers: AbstractActionManager[];
  33777. /**
  33778. * Textures to keep.
  33779. */
  33780. textures: BaseTexture[];
  33781. }
  33782. }
  33783. declare module "babylonjs/Audio/sound" {
  33784. import { Observable } from "babylonjs/Misc/observable";
  33785. import { Vector3 } from "babylonjs/Maths/math";
  33786. import { Nullable } from "babylonjs/types";
  33787. import { Scene } from "babylonjs/scene";
  33788. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33789. /**
  33790. * Defines a sound that can be played in the application.
  33791. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33793. */
  33794. export class Sound {
  33795. /**
  33796. * The name of the sound in the scene.
  33797. */
  33798. name: string;
  33799. /**
  33800. * Does the sound autoplay once loaded.
  33801. */
  33802. autoplay: boolean;
  33803. /**
  33804. * Does the sound loop after it finishes playing once.
  33805. */
  33806. loop: boolean;
  33807. /**
  33808. * Does the sound use a custom attenuation curve to simulate the falloff
  33809. * happening when the source gets further away from the camera.
  33810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33811. */
  33812. useCustomAttenuation: boolean;
  33813. /**
  33814. * The sound track id this sound belongs to.
  33815. */
  33816. soundTrackId: number;
  33817. /**
  33818. * Is this sound currently played.
  33819. */
  33820. isPlaying: boolean;
  33821. /**
  33822. * Is this sound currently paused.
  33823. */
  33824. isPaused: boolean;
  33825. /**
  33826. * Does this sound enables spatial sound.
  33827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33828. */
  33829. spatialSound: boolean;
  33830. /**
  33831. * Define the reference distance the sound should be heard perfectly.
  33832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33833. */
  33834. refDistance: number;
  33835. /**
  33836. * Define the roll off factor of spatial sounds.
  33837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33838. */
  33839. rolloffFactor: number;
  33840. /**
  33841. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33843. */
  33844. maxDistance: number;
  33845. /**
  33846. * Define the distance attenuation model the sound will follow.
  33847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33848. */
  33849. distanceModel: string;
  33850. /**
  33851. * @hidden
  33852. * Back Compat
  33853. **/
  33854. onended: () => any;
  33855. /**
  33856. * Observable event when the current playing sound finishes.
  33857. */
  33858. onEndedObservable: Observable<Sound>;
  33859. private _panningModel;
  33860. private _playbackRate;
  33861. private _streaming;
  33862. private _startTime;
  33863. private _startOffset;
  33864. private _position;
  33865. /** @hidden */
  33866. _positionInEmitterSpace: boolean;
  33867. private _localDirection;
  33868. private _volume;
  33869. private _isReadyToPlay;
  33870. private _isDirectional;
  33871. private _readyToPlayCallback;
  33872. private _audioBuffer;
  33873. private _soundSource;
  33874. private _streamingSource;
  33875. private _soundPanner;
  33876. private _soundGain;
  33877. private _inputAudioNode;
  33878. private _outputAudioNode;
  33879. private _coneInnerAngle;
  33880. private _coneOuterAngle;
  33881. private _coneOuterGain;
  33882. private _scene;
  33883. private _connectedTransformNode;
  33884. private _customAttenuationFunction;
  33885. private _registerFunc;
  33886. private _isOutputConnected;
  33887. private _htmlAudioElement;
  33888. private _urlType;
  33889. /** @hidden */
  33890. static _SceneComponentInitialization: (scene: Scene) => void;
  33891. /**
  33892. * Create a sound and attach it to a scene
  33893. * @param name Name of your sound
  33894. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33895. * @param scene defines the scene the sound belongs to
  33896. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33897. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33898. */
  33899. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33900. /**
  33901. * Release the sound and its associated resources
  33902. */
  33903. dispose(): void;
  33904. /**
  33905. * Gets if the sounds is ready to be played or not.
  33906. * @returns true if ready, otherwise false
  33907. */
  33908. isReady(): boolean;
  33909. private _soundLoaded;
  33910. /**
  33911. * Sets the data of the sound from an audiobuffer
  33912. * @param audioBuffer The audioBuffer containing the data
  33913. */
  33914. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33915. /**
  33916. * Updates the current sounds options such as maxdistance, loop...
  33917. * @param options A JSON object containing values named as the object properties
  33918. */
  33919. updateOptions(options: any): void;
  33920. private _createSpatialParameters;
  33921. private _updateSpatialParameters;
  33922. /**
  33923. * Switch the panning model to HRTF:
  33924. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33926. */
  33927. switchPanningModelToHRTF(): void;
  33928. /**
  33929. * Switch the panning model to Equal Power:
  33930. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33932. */
  33933. switchPanningModelToEqualPower(): void;
  33934. private _switchPanningModel;
  33935. /**
  33936. * Connect this sound to a sound track audio node like gain...
  33937. * @param soundTrackAudioNode the sound track audio node to connect to
  33938. */
  33939. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33940. /**
  33941. * Transform this sound into a directional source
  33942. * @param coneInnerAngle Size of the inner cone in degree
  33943. * @param coneOuterAngle Size of the outer cone in degree
  33944. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33945. */
  33946. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33947. /**
  33948. * Gets or sets the inner angle for the directional cone.
  33949. */
  33950. /**
  33951. * Gets or sets the inner angle for the directional cone.
  33952. */
  33953. directionalConeInnerAngle: number;
  33954. /**
  33955. * Gets or sets the outer angle for the directional cone.
  33956. */
  33957. /**
  33958. * Gets or sets the outer angle for the directional cone.
  33959. */
  33960. directionalConeOuterAngle: number;
  33961. /**
  33962. * Sets the position of the emitter if spatial sound is enabled
  33963. * @param newPosition Defines the new posisiton
  33964. */
  33965. setPosition(newPosition: Vector3): void;
  33966. /**
  33967. * Sets the local direction of the emitter if spatial sound is enabled
  33968. * @param newLocalDirection Defines the new local direction
  33969. */
  33970. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33971. private _updateDirection;
  33972. /** @hidden */
  33973. updateDistanceFromListener(): void;
  33974. /**
  33975. * Sets a new custom attenuation function for the sound.
  33976. * @param callback Defines the function used for the attenuation
  33977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33978. */
  33979. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33980. /**
  33981. * Play the sound
  33982. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33983. * @param offset (optional) Start the sound setting it at a specific time
  33984. */
  33985. play(time?: number, offset?: number): void;
  33986. private _onended;
  33987. /**
  33988. * Stop the sound
  33989. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33990. */
  33991. stop(time?: number): void;
  33992. /**
  33993. * Put the sound in pause
  33994. */
  33995. pause(): void;
  33996. /**
  33997. * Sets a dedicated volume for this sounds
  33998. * @param newVolume Define the new volume of the sound
  33999. * @param time Define in how long the sound should be at this value
  34000. */
  34001. setVolume(newVolume: number, time?: number): void;
  34002. /**
  34003. * Set the sound play back rate
  34004. * @param newPlaybackRate Define the playback rate the sound should be played at
  34005. */
  34006. setPlaybackRate(newPlaybackRate: number): void;
  34007. /**
  34008. * Gets the volume of the sound.
  34009. * @returns the volume of the sound
  34010. */
  34011. getVolume(): number;
  34012. /**
  34013. * Attach the sound to a dedicated mesh
  34014. * @param transformNode The transform node to connect the sound with
  34015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34016. */
  34017. attachToMesh(transformNode: TransformNode): void;
  34018. /**
  34019. * Detach the sound from the previously attached mesh
  34020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34021. */
  34022. detachFromMesh(): void;
  34023. private _onRegisterAfterWorldMatrixUpdate;
  34024. /**
  34025. * Clone the current sound in the scene.
  34026. * @returns the new sound clone
  34027. */
  34028. clone(): Nullable<Sound>;
  34029. /**
  34030. * Gets the current underlying audio buffer containing the data
  34031. * @returns the audio buffer
  34032. */
  34033. getAudioBuffer(): Nullable<AudioBuffer>;
  34034. /**
  34035. * Serializes the Sound in a JSON representation
  34036. * @returns the JSON representation of the sound
  34037. */
  34038. serialize(): any;
  34039. /**
  34040. * Parse a JSON representation of a sound to innstantiate in a given scene
  34041. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34042. * @param scene Define the scene the new parsed sound should be created in
  34043. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34044. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34045. * @returns the newly parsed sound
  34046. */
  34047. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34048. }
  34049. }
  34050. declare module "babylonjs/Actions/directAudioActions" {
  34051. import { Action } from "babylonjs/Actions/action";
  34052. import { Condition } from "babylonjs/Actions/condition";
  34053. import { Sound } from "babylonjs/Audio/sound";
  34054. /**
  34055. * This defines an action helpful to play a defined sound on a triggered action.
  34056. */
  34057. export class PlaySoundAction extends Action {
  34058. private _sound;
  34059. /**
  34060. * Instantiate the action
  34061. * @param triggerOptions defines the trigger options
  34062. * @param sound defines the sound to play
  34063. * @param condition defines the trigger related conditions
  34064. */
  34065. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34066. /** @hidden */
  34067. _prepare(): void;
  34068. /**
  34069. * Execute the action and play the sound.
  34070. */
  34071. execute(): void;
  34072. /**
  34073. * Serializes the actions and its related information.
  34074. * @param parent defines the object to serialize in
  34075. * @returns the serialized object
  34076. */
  34077. serialize(parent: any): any;
  34078. }
  34079. /**
  34080. * This defines an action helpful to stop a defined sound on a triggered action.
  34081. */
  34082. export class StopSoundAction extends Action {
  34083. private _sound;
  34084. /**
  34085. * Instantiate the action
  34086. * @param triggerOptions defines the trigger options
  34087. * @param sound defines the sound to stop
  34088. * @param condition defines the trigger related conditions
  34089. */
  34090. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34091. /** @hidden */
  34092. _prepare(): void;
  34093. /**
  34094. * Execute the action and stop the sound.
  34095. */
  34096. execute(): void;
  34097. /**
  34098. * Serializes the actions and its related information.
  34099. * @param parent defines the object to serialize in
  34100. * @returns the serialized object
  34101. */
  34102. serialize(parent: any): any;
  34103. }
  34104. }
  34105. declare module "babylonjs/Actions/interpolateValueAction" {
  34106. import { Action } from "babylonjs/Actions/action";
  34107. import { Condition } from "babylonjs/Actions/condition";
  34108. import { Observable } from "babylonjs/Misc/observable";
  34109. /**
  34110. * This defines an action responsible to change the value of a property
  34111. * by interpolating between its current value and the newly set one once triggered.
  34112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34113. */
  34114. export class InterpolateValueAction extends Action {
  34115. /**
  34116. * Defines the path of the property where the value should be interpolated
  34117. */
  34118. propertyPath: string;
  34119. /**
  34120. * Defines the target value at the end of the interpolation.
  34121. */
  34122. value: any;
  34123. /**
  34124. * Defines the time it will take for the property to interpolate to the value.
  34125. */
  34126. duration: number;
  34127. /**
  34128. * Defines if the other scene animations should be stopped when the action has been triggered
  34129. */
  34130. stopOtherAnimations?: boolean;
  34131. /**
  34132. * Defines a callback raised once the interpolation animation has been done.
  34133. */
  34134. onInterpolationDone?: () => void;
  34135. /**
  34136. * Observable triggered once the interpolation animation has been done.
  34137. */
  34138. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34139. private _target;
  34140. private _effectiveTarget;
  34141. private _property;
  34142. /**
  34143. * Instantiate the action
  34144. * @param triggerOptions defines the trigger options
  34145. * @param target defines the object containing the value to interpolate
  34146. * @param propertyPath defines the path to the property in the target object
  34147. * @param value defines the target value at the end of the interpolation
  34148. * @param duration deines the time it will take for the property to interpolate to the value.
  34149. * @param condition defines the trigger related conditions
  34150. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34151. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34152. */
  34153. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34154. /** @hidden */
  34155. _prepare(): void;
  34156. /**
  34157. * Execute the action starts the value interpolation.
  34158. */
  34159. execute(): void;
  34160. /**
  34161. * Serializes the actions and its related information.
  34162. * @param parent defines the object to serialize in
  34163. * @returns the serialized object
  34164. */
  34165. serialize(parent: any): any;
  34166. }
  34167. }
  34168. declare module "babylonjs/Actions/index" {
  34169. export * from "babylonjs/Actions/action";
  34170. export * from "babylonjs/Actions/actionEvent";
  34171. export * from "babylonjs/Actions/actionManager";
  34172. export * from "babylonjs/Actions/condition";
  34173. export * from "babylonjs/Actions/directActions";
  34174. export * from "babylonjs/Actions/directAudioActions";
  34175. export * from "babylonjs/Actions/interpolateValueAction";
  34176. }
  34177. declare module "babylonjs/Animations/index" {
  34178. export * from "babylonjs/Animations/animatable";
  34179. export * from "babylonjs/Animations/animation";
  34180. export * from "babylonjs/Animations/animationGroup";
  34181. export * from "babylonjs/Animations/animationPropertiesOverride";
  34182. export * from "babylonjs/Animations/easing";
  34183. export * from "babylonjs/Animations/runtimeAnimation";
  34184. export * from "babylonjs/Animations/animationEvent";
  34185. export * from "babylonjs/Animations/animationGroup";
  34186. export * from "babylonjs/Animations/animationKey";
  34187. export * from "babylonjs/Animations/animationRange";
  34188. }
  34189. declare module "babylonjs/Audio/soundTrack" {
  34190. import { Sound } from "babylonjs/Audio/sound";
  34191. import { Analyser } from "babylonjs/Audio/analyser";
  34192. import { Scene } from "babylonjs/scene";
  34193. /**
  34194. * Options allowed during the creation of a sound track.
  34195. */
  34196. export interface ISoundTrackOptions {
  34197. /**
  34198. * The volume the sound track should take during creation
  34199. */
  34200. volume?: number;
  34201. /**
  34202. * Define if the sound track is the main sound track of the scene
  34203. */
  34204. mainTrack?: boolean;
  34205. }
  34206. /**
  34207. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34208. * It will be also used in a future release to apply effects on a specific track.
  34209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34210. */
  34211. export class SoundTrack {
  34212. /**
  34213. * The unique identifier of the sound track in the scene.
  34214. */
  34215. id: number;
  34216. /**
  34217. * The list of sounds included in the sound track.
  34218. */
  34219. soundCollection: Array<Sound>;
  34220. private _outputAudioNode;
  34221. private _scene;
  34222. private _isMainTrack;
  34223. private _connectedAnalyser;
  34224. private _options;
  34225. private _isInitialized;
  34226. /**
  34227. * Creates a new sound track.
  34228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34229. * @param scene Define the scene the sound track belongs to
  34230. * @param options
  34231. */
  34232. constructor(scene: Scene, options?: ISoundTrackOptions);
  34233. private _initializeSoundTrackAudioGraph;
  34234. /**
  34235. * Release the sound track and its associated resources
  34236. */
  34237. dispose(): void;
  34238. /**
  34239. * Adds a sound to this sound track
  34240. * @param sound define the cound to add
  34241. * @ignoreNaming
  34242. */
  34243. AddSound(sound: Sound): void;
  34244. /**
  34245. * Removes a sound to this sound track
  34246. * @param sound define the cound to remove
  34247. * @ignoreNaming
  34248. */
  34249. RemoveSound(sound: Sound): void;
  34250. /**
  34251. * Set a global volume for the full sound track.
  34252. * @param newVolume Define the new volume of the sound track
  34253. */
  34254. setVolume(newVolume: number): void;
  34255. /**
  34256. * Switch the panning model to HRTF:
  34257. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34259. */
  34260. switchPanningModelToHRTF(): void;
  34261. /**
  34262. * Switch the panning model to Equal Power:
  34263. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34265. */
  34266. switchPanningModelToEqualPower(): void;
  34267. /**
  34268. * Connect the sound track to an audio analyser allowing some amazing
  34269. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34271. * @param analyser The analyser to connect to the engine
  34272. */
  34273. connectToAnalyser(analyser: Analyser): void;
  34274. }
  34275. }
  34276. declare module "babylonjs/Audio/audioSceneComponent" {
  34277. import { Sound } from "babylonjs/Audio/sound";
  34278. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34279. import { Nullable } from "babylonjs/types";
  34280. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34281. import { Scene } from "babylonjs/scene";
  34282. import { AbstractScene } from "babylonjs/abstractScene";
  34283. module "babylonjs/abstractScene" {
  34284. interface AbstractScene {
  34285. /**
  34286. * The list of sounds used in the scene.
  34287. */
  34288. sounds: Nullable<Array<Sound>>;
  34289. }
  34290. }
  34291. module "babylonjs/scene" {
  34292. interface Scene {
  34293. /**
  34294. * @hidden
  34295. * Backing field
  34296. */
  34297. _mainSoundTrack: SoundTrack;
  34298. /**
  34299. * The main sound track played by the scene.
  34300. * It cotains your primary collection of sounds.
  34301. */
  34302. mainSoundTrack: SoundTrack;
  34303. /**
  34304. * The list of sound tracks added to the scene
  34305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34306. */
  34307. soundTracks: Nullable<Array<SoundTrack>>;
  34308. /**
  34309. * Gets a sound using a given name
  34310. * @param name defines the name to search for
  34311. * @return the found sound or null if not found at all.
  34312. */
  34313. getSoundByName(name: string): Nullable<Sound>;
  34314. /**
  34315. * Gets or sets if audio support is enabled
  34316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34317. */
  34318. audioEnabled: boolean;
  34319. /**
  34320. * Gets or sets if audio will be output to headphones
  34321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34322. */
  34323. headphone: boolean;
  34324. }
  34325. }
  34326. /**
  34327. * Defines the sound scene component responsible to manage any sounds
  34328. * in a given scene.
  34329. */
  34330. export class AudioSceneComponent implements ISceneSerializableComponent {
  34331. /**
  34332. * The component name helpfull to identify the component in the list of scene components.
  34333. */
  34334. readonly name: string;
  34335. /**
  34336. * The scene the component belongs to.
  34337. */
  34338. scene: Scene;
  34339. private _audioEnabled;
  34340. /**
  34341. * Gets whether audio is enabled or not.
  34342. * Please use related enable/disable method to switch state.
  34343. */
  34344. readonly audioEnabled: boolean;
  34345. private _headphone;
  34346. /**
  34347. * Gets whether audio is outputing to headphone or not.
  34348. * Please use the according Switch methods to change output.
  34349. */
  34350. readonly headphone: boolean;
  34351. /**
  34352. * Creates a new instance of the component for the given scene
  34353. * @param scene Defines the scene to register the component in
  34354. */
  34355. constructor(scene: Scene);
  34356. /**
  34357. * Registers the component in a given scene
  34358. */
  34359. register(): void;
  34360. /**
  34361. * Rebuilds the elements related to this component in case of
  34362. * context lost for instance.
  34363. */
  34364. rebuild(): void;
  34365. /**
  34366. * Serializes the component data to the specified json object
  34367. * @param serializationObject The object to serialize to
  34368. */
  34369. serialize(serializationObject: any): void;
  34370. /**
  34371. * Adds all the element from the container to the scene
  34372. * @param container the container holding the elements
  34373. */
  34374. addFromContainer(container: AbstractScene): void;
  34375. /**
  34376. * Removes all the elements in the container from the scene
  34377. * @param container contains the elements to remove
  34378. */
  34379. removeFromContainer(container: AbstractScene): void;
  34380. /**
  34381. * Disposes the component and the associated ressources.
  34382. */
  34383. dispose(): void;
  34384. /**
  34385. * Disables audio in the associated scene.
  34386. */
  34387. disableAudio(): void;
  34388. /**
  34389. * Enables audio in the associated scene.
  34390. */
  34391. enableAudio(): void;
  34392. /**
  34393. * Switch audio to headphone output.
  34394. */
  34395. switchAudioModeForHeadphones(): void;
  34396. /**
  34397. * Switch audio to normal speakers.
  34398. */
  34399. switchAudioModeForNormalSpeakers(): void;
  34400. private _afterRender;
  34401. }
  34402. }
  34403. declare module "babylonjs/Audio/weightedsound" {
  34404. import { Sound } from "babylonjs/Audio/sound";
  34405. /**
  34406. * Wraps one or more Sound objects and selects one with random weight for playback.
  34407. */
  34408. export class WeightedSound {
  34409. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34410. loop: boolean;
  34411. private _coneInnerAngle;
  34412. private _coneOuterAngle;
  34413. private _volume;
  34414. /** A Sound is currently playing. */
  34415. isPlaying: boolean;
  34416. /** A Sound is currently paused. */
  34417. isPaused: boolean;
  34418. private _sounds;
  34419. private _weights;
  34420. private _currentIndex?;
  34421. /**
  34422. * Creates a new WeightedSound from the list of sounds given.
  34423. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34424. * @param sounds Array of Sounds that will be selected from.
  34425. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34426. */
  34427. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34428. /**
  34429. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34430. */
  34431. /**
  34432. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34433. */
  34434. directionalConeInnerAngle: number;
  34435. /**
  34436. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34437. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34438. */
  34439. /**
  34440. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34441. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34442. */
  34443. directionalConeOuterAngle: number;
  34444. /**
  34445. * Playback volume.
  34446. */
  34447. /**
  34448. * Playback volume.
  34449. */
  34450. volume: number;
  34451. private _onended;
  34452. /**
  34453. * Suspend playback
  34454. */
  34455. pause(): void;
  34456. /**
  34457. * Stop playback
  34458. */
  34459. stop(): void;
  34460. /**
  34461. * Start playback.
  34462. * @param startOffset Position the clip head at a specific time in seconds.
  34463. */
  34464. play(startOffset?: number): void;
  34465. }
  34466. }
  34467. declare module "babylonjs/Audio/index" {
  34468. export * from "babylonjs/Audio/analyser";
  34469. export * from "babylonjs/Audio/audioEngine";
  34470. export * from "babylonjs/Audio/audioSceneComponent";
  34471. export * from "babylonjs/Audio/sound";
  34472. export * from "babylonjs/Audio/soundTrack";
  34473. export * from "babylonjs/Audio/weightedsound";
  34474. }
  34475. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34476. import { Behavior } from "babylonjs/Behaviors/behavior";
  34477. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34478. import { BackEase } from "babylonjs/Animations/easing";
  34479. /**
  34480. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34481. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34482. */
  34483. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34484. /**
  34485. * Gets the name of the behavior.
  34486. */
  34487. readonly name: string;
  34488. /**
  34489. * The easing function used by animations
  34490. */
  34491. static EasingFunction: BackEase;
  34492. /**
  34493. * The easing mode used by animations
  34494. */
  34495. static EasingMode: number;
  34496. /**
  34497. * The duration of the animation, in milliseconds
  34498. */
  34499. transitionDuration: number;
  34500. /**
  34501. * Length of the distance animated by the transition when lower radius is reached
  34502. */
  34503. lowerRadiusTransitionRange: number;
  34504. /**
  34505. * Length of the distance animated by the transition when upper radius is reached
  34506. */
  34507. upperRadiusTransitionRange: number;
  34508. private _autoTransitionRange;
  34509. /**
  34510. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34511. */
  34512. /**
  34513. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34514. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34515. */
  34516. autoTransitionRange: boolean;
  34517. private _attachedCamera;
  34518. private _onAfterCheckInputsObserver;
  34519. private _onMeshTargetChangedObserver;
  34520. /**
  34521. * Initializes the behavior.
  34522. */
  34523. init(): void;
  34524. /**
  34525. * Attaches the behavior to its arc rotate camera.
  34526. * @param camera Defines the camera to attach the behavior to
  34527. */
  34528. attach(camera: ArcRotateCamera): void;
  34529. /**
  34530. * Detaches the behavior from its current arc rotate camera.
  34531. */
  34532. detach(): void;
  34533. private _radiusIsAnimating;
  34534. private _radiusBounceTransition;
  34535. private _animatables;
  34536. private _cachedWheelPrecision;
  34537. /**
  34538. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34539. * @param radiusLimit The limit to check against.
  34540. * @return Bool to indicate if at limit.
  34541. */
  34542. private _isRadiusAtLimit;
  34543. /**
  34544. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34545. * @param radiusDelta The delta by which to animate to. Can be negative.
  34546. */
  34547. private _applyBoundRadiusAnimation;
  34548. /**
  34549. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34550. */
  34551. protected _clearAnimationLocks(): void;
  34552. /**
  34553. * Stops and removes all animations that have been applied to the camera
  34554. */
  34555. stopAllAnimations(): void;
  34556. }
  34557. }
  34558. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34559. import { Behavior } from "babylonjs/Behaviors/behavior";
  34560. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34561. import { ExponentialEase } from "babylonjs/Animations/easing";
  34562. import { Nullable } from "babylonjs/types";
  34563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34564. import { Vector3 } from "babylonjs/Maths/math";
  34565. /**
  34566. * 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.
  34567. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34568. */
  34569. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34570. /**
  34571. * Gets the name of the behavior.
  34572. */
  34573. readonly name: string;
  34574. private _mode;
  34575. private _radiusScale;
  34576. private _positionScale;
  34577. private _defaultElevation;
  34578. private _elevationReturnTime;
  34579. private _elevationReturnWaitTime;
  34580. private _zoomStopsAnimation;
  34581. private _framingTime;
  34582. /**
  34583. * The easing function used by animations
  34584. */
  34585. static EasingFunction: ExponentialEase;
  34586. /**
  34587. * The easing mode used by animations
  34588. */
  34589. static EasingMode: number;
  34590. /**
  34591. * Sets the current mode used by the behavior
  34592. */
  34593. /**
  34594. * Gets current mode used by the behavior.
  34595. */
  34596. mode: number;
  34597. /**
  34598. * Sets the scale applied to the radius (1 by default)
  34599. */
  34600. /**
  34601. * Gets the scale applied to the radius
  34602. */
  34603. radiusScale: number;
  34604. /**
  34605. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34606. */
  34607. /**
  34608. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34609. */
  34610. positionScale: number;
  34611. /**
  34612. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34613. * behaviour is triggered, in radians.
  34614. */
  34615. /**
  34616. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34617. * behaviour is triggered, in radians.
  34618. */
  34619. defaultElevation: number;
  34620. /**
  34621. * Sets the time (in milliseconds) taken to return to the default beta position.
  34622. * Negative value indicates camera should not return to default.
  34623. */
  34624. /**
  34625. * Gets the time (in milliseconds) taken to return to the default beta position.
  34626. * Negative value indicates camera should not return to default.
  34627. */
  34628. elevationReturnTime: number;
  34629. /**
  34630. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34631. */
  34632. /**
  34633. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34634. */
  34635. elevationReturnWaitTime: number;
  34636. /**
  34637. * Sets the flag that indicates if user zooming should stop animation.
  34638. */
  34639. /**
  34640. * Gets the flag that indicates if user zooming should stop animation.
  34641. */
  34642. zoomStopsAnimation: boolean;
  34643. /**
  34644. * Sets the transition time when framing the mesh, in milliseconds
  34645. */
  34646. /**
  34647. * Gets the transition time when framing the mesh, in milliseconds
  34648. */
  34649. framingTime: number;
  34650. /**
  34651. * Define if the behavior should automatically change the configured
  34652. * camera limits and sensibilities.
  34653. */
  34654. autoCorrectCameraLimitsAndSensibility: boolean;
  34655. private _onPrePointerObservableObserver;
  34656. private _onAfterCheckInputsObserver;
  34657. private _onMeshTargetChangedObserver;
  34658. private _attachedCamera;
  34659. private _isPointerDown;
  34660. private _lastInteractionTime;
  34661. /**
  34662. * Initializes the behavior.
  34663. */
  34664. init(): void;
  34665. /**
  34666. * Attaches the behavior to its arc rotate camera.
  34667. * @param camera Defines the camera to attach the behavior to
  34668. */
  34669. attach(camera: ArcRotateCamera): void;
  34670. /**
  34671. * Detaches the behavior from its current arc rotate camera.
  34672. */
  34673. detach(): void;
  34674. private _animatables;
  34675. private _betaIsAnimating;
  34676. private _betaTransition;
  34677. private _radiusTransition;
  34678. private _vectorTransition;
  34679. /**
  34680. * Targets the given mesh and updates zoom level accordingly.
  34681. * @param mesh The mesh to target.
  34682. * @param radius Optional. If a cached radius position already exists, overrides default.
  34683. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34684. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34685. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34686. */
  34687. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34688. /**
  34689. * Targets the given mesh with its children and updates zoom level accordingly.
  34690. * @param mesh The mesh to target.
  34691. * @param radius Optional. If a cached radius position already exists, overrides default.
  34692. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34693. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34694. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34695. */
  34696. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34697. /**
  34698. * Targets the given meshes with their children and updates zoom level accordingly.
  34699. * @param meshes The mesh to target.
  34700. * @param radius Optional. If a cached radius position already exists, overrides default.
  34701. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34702. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34703. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34704. */
  34705. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34706. /**
  34707. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34708. * @param minimumWorld Determines the smaller position of the bounding box extend
  34709. * @param maximumWorld Determines the bigger position of the bounding box extend
  34710. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34711. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34712. */
  34713. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34714. /**
  34715. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34716. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34717. * frustum width.
  34718. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34719. * to fully enclose the mesh in the viewing frustum.
  34720. */
  34721. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34722. /**
  34723. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34724. * is automatically returned to its default position (expected to be above ground plane).
  34725. */
  34726. private _maintainCameraAboveGround;
  34727. /**
  34728. * Returns the frustum slope based on the canvas ratio and camera FOV
  34729. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34730. */
  34731. private _getFrustumSlope;
  34732. /**
  34733. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34734. */
  34735. private _clearAnimationLocks;
  34736. /**
  34737. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34738. */
  34739. private _applyUserInteraction;
  34740. /**
  34741. * Stops and removes all animations that have been applied to the camera
  34742. */
  34743. stopAllAnimations(): void;
  34744. /**
  34745. * Gets a value indicating if the user is moving the camera
  34746. */
  34747. readonly isUserIsMoving: boolean;
  34748. /**
  34749. * The camera can move all the way towards the mesh.
  34750. */
  34751. static IgnoreBoundsSizeMode: number;
  34752. /**
  34753. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34754. */
  34755. static FitFrustumSidesMode: number;
  34756. }
  34757. }
  34758. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34759. import { Nullable } from "babylonjs/types";
  34760. import { Camera } from "babylonjs/Cameras/camera";
  34761. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34762. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34763. /**
  34764. * Base class for Camera Pointer Inputs.
  34765. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34766. * for example usage.
  34767. */
  34768. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34769. /**
  34770. * Defines the camera the input is attached to.
  34771. */
  34772. abstract camera: Camera;
  34773. /**
  34774. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34775. */
  34776. protected _altKey: boolean;
  34777. protected _ctrlKey: boolean;
  34778. protected _metaKey: boolean;
  34779. protected _shiftKey: boolean;
  34780. /**
  34781. * Which mouse buttons were pressed at time of last mouse event.
  34782. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34783. */
  34784. protected _buttonsPressed: number;
  34785. /**
  34786. * Defines the buttons associated with the input to handle camera move.
  34787. */
  34788. buttons: number[];
  34789. /**
  34790. * Attach the input controls to a specific dom element to get the input from.
  34791. * @param element Defines the element the controls should be listened from
  34792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34793. */
  34794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34795. /**
  34796. * Detach the current controls from the specified dom element.
  34797. * @param element Defines the element to stop listening the inputs from
  34798. */
  34799. detachControl(element: Nullable<HTMLElement>): void;
  34800. /**
  34801. * Gets the class name of the current input.
  34802. * @returns the class name
  34803. */
  34804. getClassName(): string;
  34805. /**
  34806. * Get the friendly name associated with the input class.
  34807. * @returns the input friendly name
  34808. */
  34809. getSimpleName(): string;
  34810. /**
  34811. * Called on pointer POINTERDOUBLETAP event.
  34812. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34813. */
  34814. protected onDoubleTap(type: string): void;
  34815. /**
  34816. * Called on pointer POINTERMOVE event if only a single touch is active.
  34817. * Override this method to provide functionality.
  34818. */
  34819. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34820. /**
  34821. * Called on pointer POINTERMOVE event if multiple touches are active.
  34822. * Override this method to provide functionality.
  34823. */
  34824. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34825. /**
  34826. * Called on JS contextmenu event.
  34827. * Override this method to provide functionality.
  34828. */
  34829. protected onContextMenu(evt: PointerEvent): void;
  34830. /**
  34831. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34832. * press.
  34833. * Override this method to provide functionality.
  34834. */
  34835. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34836. /**
  34837. * Called each time a new POINTERUP event occurs. Ie, for each button
  34838. * release.
  34839. * Override this method to provide functionality.
  34840. */
  34841. protected onButtonUp(evt: PointerEvent): void;
  34842. /**
  34843. * Called when window becomes inactive.
  34844. * Override this method to provide functionality.
  34845. */
  34846. protected onLostFocus(): void;
  34847. private _pointerInput;
  34848. private _observer;
  34849. private _onLostFocus;
  34850. }
  34851. }
  34852. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34853. import { Nullable } from "babylonjs/types";
  34854. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34855. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34856. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34857. /**
  34858. * Manage the pointers inputs to control an arc rotate camera.
  34859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34860. */
  34861. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34862. /**
  34863. * Defines the camera the input is attached to.
  34864. */
  34865. camera: ArcRotateCamera;
  34866. /**
  34867. * Gets the class name of the current input.
  34868. * @returns the class name
  34869. */
  34870. getClassName(): string;
  34871. /**
  34872. * Defines the buttons associated with the input to handle camera move.
  34873. */
  34874. buttons: number[];
  34875. /**
  34876. * Defines the pointer angular sensibility along the X axis or how fast is
  34877. * the camera rotating.
  34878. */
  34879. angularSensibilityX: number;
  34880. /**
  34881. * Defines the pointer angular sensibility along the Y axis or how fast is
  34882. * the camera rotating.
  34883. */
  34884. angularSensibilityY: number;
  34885. /**
  34886. * Defines the pointer pinch precision or how fast is the camera zooming.
  34887. */
  34888. pinchPrecision: number;
  34889. /**
  34890. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34891. * from 0.
  34892. * It defines the percentage of current camera.radius to use as delta when
  34893. * pinch zoom is used.
  34894. */
  34895. pinchDeltaPercentage: number;
  34896. /**
  34897. * Defines the pointer panning sensibility or how fast is the camera moving.
  34898. */
  34899. panningSensibility: number;
  34900. /**
  34901. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34902. */
  34903. multiTouchPanning: boolean;
  34904. /**
  34905. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34906. * zoom (pinch) through multitouch.
  34907. */
  34908. multiTouchPanAndZoom: boolean;
  34909. /**
  34910. * Revers pinch action direction.
  34911. */
  34912. pinchInwards: boolean;
  34913. private _isPanClick;
  34914. private _twoFingerActivityCount;
  34915. private _isPinching;
  34916. /**
  34917. * Called on pointer POINTERMOVE event if only a single touch is active.
  34918. */
  34919. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34920. /**
  34921. * Called on pointer POINTERDOUBLETAP event.
  34922. */
  34923. protected onDoubleTap(type: string): void;
  34924. /**
  34925. * Called on pointer POINTERMOVE event if multiple touches are active.
  34926. */
  34927. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34928. /**
  34929. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34930. * press.
  34931. */
  34932. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34933. /**
  34934. * Called each time a new POINTERUP event occurs. Ie, for each button
  34935. * release.
  34936. */
  34937. protected onButtonUp(evt: PointerEvent): void;
  34938. /**
  34939. * Called when window becomes inactive.
  34940. */
  34941. protected onLostFocus(): void;
  34942. }
  34943. }
  34944. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34945. import { Nullable } from "babylonjs/types";
  34946. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34947. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34948. /**
  34949. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34951. */
  34952. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34953. /**
  34954. * Defines the camera the input is attached to.
  34955. */
  34956. camera: ArcRotateCamera;
  34957. /**
  34958. * Defines the list of key codes associated with the up action (increase alpha)
  34959. */
  34960. keysUp: number[];
  34961. /**
  34962. * Defines the list of key codes associated with the down action (decrease alpha)
  34963. */
  34964. keysDown: number[];
  34965. /**
  34966. * Defines the list of key codes associated with the left action (increase beta)
  34967. */
  34968. keysLeft: number[];
  34969. /**
  34970. * Defines the list of key codes associated with the right action (decrease beta)
  34971. */
  34972. keysRight: number[];
  34973. /**
  34974. * Defines the list of key codes associated with the reset action.
  34975. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34976. */
  34977. keysReset: number[];
  34978. /**
  34979. * Defines the panning sensibility of the inputs.
  34980. * (How fast is the camera paning)
  34981. */
  34982. panningSensibility: number;
  34983. /**
  34984. * Defines the zooming sensibility of the inputs.
  34985. * (How fast is the camera zooming)
  34986. */
  34987. zoomingSensibility: number;
  34988. /**
  34989. * Defines wether maintaining the alt key down switch the movement mode from
  34990. * orientation to zoom.
  34991. */
  34992. useAltToZoom: boolean;
  34993. /**
  34994. * Rotation speed of the camera
  34995. */
  34996. angularSpeed: number;
  34997. private _keys;
  34998. private _ctrlPressed;
  34999. private _altPressed;
  35000. private _onCanvasBlurObserver;
  35001. private _onKeyboardObserver;
  35002. private _engine;
  35003. private _scene;
  35004. /**
  35005. * Attach the input controls to a specific dom element to get the input from.
  35006. * @param element Defines the element the controls should be listened from
  35007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35008. */
  35009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35010. /**
  35011. * Detach the current controls from the specified dom element.
  35012. * @param element Defines the element to stop listening the inputs from
  35013. */
  35014. detachControl(element: Nullable<HTMLElement>): void;
  35015. /**
  35016. * Update the current camera state depending on the inputs that have been used this frame.
  35017. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35018. */
  35019. checkInputs(): void;
  35020. /**
  35021. * Gets the class name of the current intput.
  35022. * @returns the class name
  35023. */
  35024. getClassName(): string;
  35025. /**
  35026. * Get the friendly name associated with the input class.
  35027. * @returns the input friendly name
  35028. */
  35029. getSimpleName(): string;
  35030. }
  35031. }
  35032. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35033. import { Nullable } from "babylonjs/types";
  35034. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35035. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35036. /**
  35037. * Manage the mouse wheel inputs to control an arc rotate camera.
  35038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35039. */
  35040. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35041. /**
  35042. * Defines the camera the input is attached to.
  35043. */
  35044. camera: ArcRotateCamera;
  35045. /**
  35046. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35047. */
  35048. wheelPrecision: number;
  35049. /**
  35050. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35051. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35052. */
  35053. wheelDeltaPercentage: number;
  35054. private _wheel;
  35055. private _observer;
  35056. /**
  35057. * Attach the input controls to a specific dom element to get the input from.
  35058. * @param element Defines the element the controls should be listened from
  35059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35060. */
  35061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35062. /**
  35063. * Detach the current controls from the specified dom element.
  35064. * @param element Defines the element to stop listening the inputs from
  35065. */
  35066. detachControl(element: Nullable<HTMLElement>): void;
  35067. /**
  35068. * Gets the class name of the current intput.
  35069. * @returns the class name
  35070. */
  35071. getClassName(): string;
  35072. /**
  35073. * Get the friendly name associated with the input class.
  35074. * @returns the input friendly name
  35075. */
  35076. getSimpleName(): string;
  35077. }
  35078. }
  35079. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35080. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35081. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35082. /**
  35083. * Default Inputs manager for the ArcRotateCamera.
  35084. * It groups all the default supported inputs for ease of use.
  35085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35086. */
  35087. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35088. /**
  35089. * Instantiates a new ArcRotateCameraInputsManager.
  35090. * @param camera Defines the camera the inputs belong to
  35091. */
  35092. constructor(camera: ArcRotateCamera);
  35093. /**
  35094. * Add mouse wheel input support to the input manager.
  35095. * @returns the current input manager
  35096. */
  35097. addMouseWheel(): ArcRotateCameraInputsManager;
  35098. /**
  35099. * Add pointers input support to the input manager.
  35100. * @returns the current input manager
  35101. */
  35102. addPointers(): ArcRotateCameraInputsManager;
  35103. /**
  35104. * Add keyboard input support to the input manager.
  35105. * @returns the current input manager
  35106. */
  35107. addKeyboard(): ArcRotateCameraInputsManager;
  35108. }
  35109. }
  35110. declare module "babylonjs/Cameras/arcRotateCamera" {
  35111. import { Observable } from "babylonjs/Misc/observable";
  35112. import { Nullable } from "babylonjs/types";
  35113. import { Scene } from "babylonjs/scene";
  35114. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35116. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35117. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35118. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35119. import { Camera } from "babylonjs/Cameras/camera";
  35120. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35121. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35122. import { Collider } from "babylonjs/Collisions/collider";
  35123. /**
  35124. * This represents an orbital type of camera.
  35125. *
  35126. * 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.
  35127. * 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.
  35128. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35129. */
  35130. export class ArcRotateCamera extends TargetCamera {
  35131. /**
  35132. * Defines the rotation angle of the camera along the longitudinal axis.
  35133. */
  35134. alpha: number;
  35135. /**
  35136. * Defines the rotation angle of the camera along the latitudinal axis.
  35137. */
  35138. beta: number;
  35139. /**
  35140. * Defines the radius of the camera from it s target point.
  35141. */
  35142. radius: number;
  35143. protected _target: Vector3;
  35144. protected _targetHost: Nullable<AbstractMesh>;
  35145. /**
  35146. * Defines the target point of the camera.
  35147. * The camera looks towards it form the radius distance.
  35148. */
  35149. target: Vector3;
  35150. /**
  35151. * Define the current local position of the camera in the scene
  35152. */
  35153. position: Vector3;
  35154. /**
  35155. * Current inertia value on the longitudinal axis.
  35156. * The bigger this number the longer it will take for the camera to stop.
  35157. */
  35158. inertialAlphaOffset: number;
  35159. /**
  35160. * Current inertia value on the latitudinal axis.
  35161. * The bigger this number the longer it will take for the camera to stop.
  35162. */
  35163. inertialBetaOffset: number;
  35164. /**
  35165. * Current inertia value on the radius axis.
  35166. * The bigger this number the longer it will take for the camera to stop.
  35167. */
  35168. inertialRadiusOffset: number;
  35169. /**
  35170. * Minimum allowed angle on the longitudinal axis.
  35171. * This can help limiting how the Camera is able to move in the scene.
  35172. */
  35173. lowerAlphaLimit: Nullable<number>;
  35174. /**
  35175. * Maximum allowed angle on the longitudinal axis.
  35176. * This can help limiting how the Camera is able to move in the scene.
  35177. */
  35178. upperAlphaLimit: Nullable<number>;
  35179. /**
  35180. * Minimum allowed angle on the latitudinal axis.
  35181. * This can help limiting how the Camera is able to move in the scene.
  35182. */
  35183. lowerBetaLimit: number;
  35184. /**
  35185. * Maximum allowed angle on the latitudinal axis.
  35186. * This can help limiting how the Camera is able to move in the scene.
  35187. */
  35188. upperBetaLimit: number;
  35189. /**
  35190. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35191. * This can help limiting how the Camera is able to move in the scene.
  35192. */
  35193. lowerRadiusLimit: Nullable<number>;
  35194. /**
  35195. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35196. * This can help limiting how the Camera is able to move in the scene.
  35197. */
  35198. upperRadiusLimit: Nullable<number>;
  35199. /**
  35200. * Defines the current inertia value used during panning of the camera along the X axis.
  35201. */
  35202. inertialPanningX: number;
  35203. /**
  35204. * Defines the current inertia value used during panning of the camera along the Y axis.
  35205. */
  35206. inertialPanningY: number;
  35207. /**
  35208. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35209. * Basically if your fingers moves away from more than this distance you will be considered
  35210. * in pinch mode.
  35211. */
  35212. pinchToPanMaxDistance: number;
  35213. /**
  35214. * Defines the maximum distance the camera can pan.
  35215. * This could help keeping the cammera always in your scene.
  35216. */
  35217. panningDistanceLimit: Nullable<number>;
  35218. /**
  35219. * Defines the target of the camera before paning.
  35220. */
  35221. panningOriginTarget: Vector3;
  35222. /**
  35223. * Defines the value of the inertia used during panning.
  35224. * 0 would mean stop inertia and one would mean no decelleration at all.
  35225. */
  35226. panningInertia: number;
  35227. /**
  35228. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35229. */
  35230. angularSensibilityX: number;
  35231. /**
  35232. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35233. */
  35234. angularSensibilityY: number;
  35235. /**
  35236. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35237. */
  35238. pinchPrecision: number;
  35239. /**
  35240. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35241. * It will be used instead of pinchDeltaPrecision if different from 0.
  35242. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35243. */
  35244. pinchDeltaPercentage: number;
  35245. /**
  35246. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35247. */
  35248. panningSensibility: number;
  35249. /**
  35250. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35251. */
  35252. keysUp: number[];
  35253. /**
  35254. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35255. */
  35256. keysDown: number[];
  35257. /**
  35258. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35259. */
  35260. keysLeft: number[];
  35261. /**
  35262. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35263. */
  35264. keysRight: number[];
  35265. /**
  35266. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35267. */
  35268. wheelPrecision: number;
  35269. /**
  35270. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35271. * It will be used instead of pinchDeltaPrecision if different from 0.
  35272. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35273. */
  35274. wheelDeltaPercentage: number;
  35275. /**
  35276. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35277. */
  35278. zoomOnFactor: number;
  35279. /**
  35280. * Defines a screen offset for the camera position.
  35281. */
  35282. targetScreenOffset: Vector2;
  35283. /**
  35284. * Allows the camera to be completely reversed.
  35285. * If false the camera can not arrive upside down.
  35286. */
  35287. allowUpsideDown: boolean;
  35288. /**
  35289. * Define if double tap/click is used to restore the previously saved state of the camera.
  35290. */
  35291. useInputToRestoreState: boolean;
  35292. /** @hidden */
  35293. _viewMatrix: Matrix;
  35294. /** @hidden */
  35295. _useCtrlForPanning: boolean;
  35296. /** @hidden */
  35297. _panningMouseButton: number;
  35298. /**
  35299. * Defines the input associated to the camera.
  35300. */
  35301. inputs: ArcRotateCameraInputsManager;
  35302. /** @hidden */
  35303. _reset: () => void;
  35304. /**
  35305. * Defines the allowed panning axis.
  35306. */
  35307. panningAxis: Vector3;
  35308. protected _localDirection: Vector3;
  35309. protected _transformedDirection: Vector3;
  35310. private _bouncingBehavior;
  35311. /**
  35312. * Gets the bouncing behavior of the camera if it has been enabled.
  35313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35314. */
  35315. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35316. /**
  35317. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35318. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35319. */
  35320. useBouncingBehavior: boolean;
  35321. private _framingBehavior;
  35322. /**
  35323. * Gets the framing behavior of the camera if it has been enabled.
  35324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35325. */
  35326. readonly framingBehavior: Nullable<FramingBehavior>;
  35327. /**
  35328. * Defines if the framing behavior of the camera is enabled on the camera.
  35329. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35330. */
  35331. useFramingBehavior: boolean;
  35332. private _autoRotationBehavior;
  35333. /**
  35334. * Gets the auto rotation behavior of the camera if it has been enabled.
  35335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35336. */
  35337. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35338. /**
  35339. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35340. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35341. */
  35342. useAutoRotationBehavior: boolean;
  35343. /**
  35344. * Observable triggered when the mesh target has been changed on the camera.
  35345. */
  35346. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35347. /**
  35348. * Event raised when the camera is colliding with a mesh.
  35349. */
  35350. onCollide: (collidedMesh: AbstractMesh) => void;
  35351. /**
  35352. * Defines whether the camera should check collision with the objects oh the scene.
  35353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35354. */
  35355. checkCollisions: boolean;
  35356. /**
  35357. * Defines the collision radius of the camera.
  35358. * This simulates a sphere around the camera.
  35359. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35360. */
  35361. collisionRadius: Vector3;
  35362. protected _collider: Collider;
  35363. protected _previousPosition: Vector3;
  35364. protected _collisionVelocity: Vector3;
  35365. protected _newPosition: Vector3;
  35366. protected _previousAlpha: number;
  35367. protected _previousBeta: number;
  35368. protected _previousRadius: number;
  35369. protected _collisionTriggered: boolean;
  35370. protected _targetBoundingCenter: Nullable<Vector3>;
  35371. private _computationVector;
  35372. private _tempAxisVector;
  35373. private _tempAxisRotationMatrix;
  35374. /**
  35375. * Instantiates a new ArcRotateCamera in a given scene
  35376. * @param name Defines the name of the camera
  35377. * @param alpha Defines the camera rotation along the logitudinal axis
  35378. * @param beta Defines the camera rotation along the latitudinal axis
  35379. * @param radius Defines the camera distance from its target
  35380. * @param target Defines the camera target
  35381. * @param scene Defines the scene the camera belongs to
  35382. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35383. */
  35384. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35385. /** @hidden */
  35386. _initCache(): void;
  35387. /** @hidden */
  35388. _updateCache(ignoreParentClass?: boolean): void;
  35389. protected _getTargetPosition(): Vector3;
  35390. private _storedAlpha;
  35391. private _storedBeta;
  35392. private _storedRadius;
  35393. private _storedTarget;
  35394. /**
  35395. * Stores the current state of the camera (alpha, beta, radius and target)
  35396. * @returns the camera itself
  35397. */
  35398. storeState(): Camera;
  35399. /**
  35400. * @hidden
  35401. * Restored camera state. You must call storeState() first
  35402. */
  35403. _restoreStateValues(): boolean;
  35404. /** @hidden */
  35405. _isSynchronizedViewMatrix(): boolean;
  35406. /**
  35407. * Attached controls to the current camera.
  35408. * @param element Defines the element the controls should be listened from
  35409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35410. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35411. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35412. */
  35413. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35414. /**
  35415. * Detach the current controls from the camera.
  35416. * The camera will stop reacting to inputs.
  35417. * @param element Defines the element to stop listening the inputs from
  35418. */
  35419. detachControl(element: HTMLElement): void;
  35420. /** @hidden */
  35421. _checkInputs(): void;
  35422. protected _checkLimits(): void;
  35423. /**
  35424. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35425. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35426. */
  35427. rebuildAnglesAndRadius(updateView?: boolean): void;
  35428. /**
  35429. * Use a position to define the current camera related information like aplha, beta and radius
  35430. * @param position Defines the position to set the camera at
  35431. */
  35432. setPosition(position: Vector3): void;
  35433. /**
  35434. * Defines the target the camera should look at.
  35435. * This will automatically adapt alpha beta and radius to fit within the new target.
  35436. * @param target Defines the new target as a Vector or a mesh
  35437. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35438. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35439. */
  35440. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35441. /** @hidden */
  35442. _getViewMatrix(): Matrix;
  35443. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35444. /**
  35445. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35446. * @param meshes Defines the mesh to zoom on
  35447. * @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)
  35448. */
  35449. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35450. /**
  35451. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35452. * The target will be changed but the radius
  35453. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35454. * @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)
  35455. */
  35456. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35457. min: Vector3;
  35458. max: Vector3;
  35459. distance: number;
  35460. }, doNotUpdateMaxZ?: boolean): void;
  35461. /**
  35462. * @override
  35463. * Override Camera.createRigCamera
  35464. */
  35465. createRigCamera(name: string, cameraIndex: number): Camera;
  35466. /**
  35467. * @hidden
  35468. * @override
  35469. * Override Camera._updateRigCameras
  35470. */
  35471. _updateRigCameras(): void;
  35472. /**
  35473. * Destroy the camera and release the current resources hold by it.
  35474. */
  35475. dispose(): void;
  35476. /**
  35477. * Gets the current object class name.
  35478. * @return the class name
  35479. */
  35480. getClassName(): string;
  35481. }
  35482. }
  35483. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35484. import { Behavior } from "babylonjs/Behaviors/behavior";
  35485. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35486. /**
  35487. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35488. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35489. */
  35490. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35491. /**
  35492. * Gets the name of the behavior.
  35493. */
  35494. readonly name: string;
  35495. private _zoomStopsAnimation;
  35496. private _idleRotationSpeed;
  35497. private _idleRotationWaitTime;
  35498. private _idleRotationSpinupTime;
  35499. /**
  35500. * Sets the flag that indicates if user zooming should stop animation.
  35501. */
  35502. /**
  35503. * Gets the flag that indicates if user zooming should stop animation.
  35504. */
  35505. zoomStopsAnimation: boolean;
  35506. /**
  35507. * Sets the default speed at which the camera rotates around the model.
  35508. */
  35509. /**
  35510. * Gets the default speed at which the camera rotates around the model.
  35511. */
  35512. idleRotationSpeed: number;
  35513. /**
  35514. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35515. */
  35516. /**
  35517. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35518. */
  35519. idleRotationWaitTime: number;
  35520. /**
  35521. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35522. */
  35523. /**
  35524. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35525. */
  35526. idleRotationSpinupTime: number;
  35527. /**
  35528. * Gets a value indicating if the camera is currently rotating because of this behavior
  35529. */
  35530. readonly rotationInProgress: boolean;
  35531. private _onPrePointerObservableObserver;
  35532. private _onAfterCheckInputsObserver;
  35533. private _attachedCamera;
  35534. private _isPointerDown;
  35535. private _lastFrameTime;
  35536. private _lastInteractionTime;
  35537. private _cameraRotationSpeed;
  35538. /**
  35539. * Initializes the behavior.
  35540. */
  35541. init(): void;
  35542. /**
  35543. * Attaches the behavior to its arc rotate camera.
  35544. * @param camera Defines the camera to attach the behavior to
  35545. */
  35546. attach(camera: ArcRotateCamera): void;
  35547. /**
  35548. * Detaches the behavior from its current arc rotate camera.
  35549. */
  35550. detach(): void;
  35551. /**
  35552. * Returns true if user is scrolling.
  35553. * @return true if user is scrolling.
  35554. */
  35555. private _userIsZooming;
  35556. private _lastFrameRadius;
  35557. private _shouldAnimationStopForInteraction;
  35558. /**
  35559. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35560. */
  35561. private _applyUserInteraction;
  35562. private _userIsMoving;
  35563. }
  35564. }
  35565. declare module "babylonjs/Behaviors/Cameras/index" {
  35566. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35567. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35568. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35569. }
  35570. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35571. import { Mesh } from "babylonjs/Meshes/mesh";
  35572. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35573. import { Behavior } from "babylonjs/Behaviors/behavior";
  35574. /**
  35575. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35576. */
  35577. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35578. private ui;
  35579. /**
  35580. * The name of the behavior
  35581. */
  35582. name: string;
  35583. /**
  35584. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35585. */
  35586. distanceAwayFromFace: number;
  35587. /**
  35588. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35589. */
  35590. distanceAwayFromBottomOfFace: number;
  35591. private _faceVectors;
  35592. private _target;
  35593. private _scene;
  35594. private _onRenderObserver;
  35595. private _tmpMatrix;
  35596. private _tmpVector;
  35597. /**
  35598. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35599. * @param ui The transform node that should be attched to the mesh
  35600. */
  35601. constructor(ui: TransformNode);
  35602. /**
  35603. * Initializes the behavior
  35604. */
  35605. init(): void;
  35606. private _closestFace;
  35607. private _zeroVector;
  35608. private _lookAtTmpMatrix;
  35609. private _lookAtToRef;
  35610. /**
  35611. * Attaches the AttachToBoxBehavior to the passed in mesh
  35612. * @param target The mesh that the specified node will be attached to
  35613. */
  35614. attach(target: Mesh): void;
  35615. /**
  35616. * Detaches the behavior from the mesh
  35617. */
  35618. detach(): void;
  35619. }
  35620. }
  35621. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35622. import { Behavior } from "babylonjs/Behaviors/behavior";
  35623. import { Mesh } from "babylonjs/Meshes/mesh";
  35624. /**
  35625. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35626. */
  35627. export class FadeInOutBehavior implements Behavior<Mesh> {
  35628. /**
  35629. * Time in milliseconds to delay before fading in (Default: 0)
  35630. */
  35631. delay: number;
  35632. /**
  35633. * Time in milliseconds for the mesh to fade in (Default: 300)
  35634. */
  35635. fadeInTime: number;
  35636. private _millisecondsPerFrame;
  35637. private _hovered;
  35638. private _hoverValue;
  35639. private _ownerNode;
  35640. /**
  35641. * Instatiates the FadeInOutBehavior
  35642. */
  35643. constructor();
  35644. /**
  35645. * The name of the behavior
  35646. */
  35647. readonly name: string;
  35648. /**
  35649. * Initializes the behavior
  35650. */
  35651. init(): void;
  35652. /**
  35653. * Attaches the fade behavior on the passed in mesh
  35654. * @param ownerNode The mesh that will be faded in/out once attached
  35655. */
  35656. attach(ownerNode: Mesh): void;
  35657. /**
  35658. * Detaches the behavior from the mesh
  35659. */
  35660. detach(): void;
  35661. /**
  35662. * Triggers the mesh to begin fading in or out
  35663. * @param value if the object should fade in or out (true to fade in)
  35664. */
  35665. fadeIn(value: boolean): void;
  35666. private _update;
  35667. private _setAllVisibility;
  35668. }
  35669. }
  35670. declare module "babylonjs/Misc/pivotTools" {
  35671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35672. /**
  35673. * Class containing a set of static utilities functions for managing Pivots
  35674. * @hidden
  35675. */
  35676. export class PivotTools {
  35677. private static _PivotCached;
  35678. private static _OldPivotPoint;
  35679. private static _PivotTranslation;
  35680. private static _PivotTmpVector;
  35681. /** @hidden */
  35682. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35683. /** @hidden */
  35684. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35685. }
  35686. }
  35687. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35688. import { Scene } from "babylonjs/scene";
  35689. import { Vector4, Plane } from "babylonjs/Maths/math";
  35690. import { Mesh } from "babylonjs/Meshes/mesh";
  35691. /**
  35692. * Class containing static functions to help procedurally build meshes
  35693. */
  35694. export class PlaneBuilder {
  35695. /**
  35696. * Creates a plane mesh
  35697. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35698. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35699. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35703. * @param name defines the name of the mesh
  35704. * @param options defines the options used to create the mesh
  35705. * @param scene defines the hosting scene
  35706. * @returns the plane mesh
  35707. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35708. */
  35709. static CreatePlane(name: string, options: {
  35710. size?: number;
  35711. width?: number;
  35712. height?: number;
  35713. sideOrientation?: number;
  35714. frontUVs?: Vector4;
  35715. backUVs?: Vector4;
  35716. updatable?: boolean;
  35717. sourcePlane?: Plane;
  35718. }, scene: Scene): Mesh;
  35719. }
  35720. }
  35721. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35722. import { Behavior } from "babylonjs/Behaviors/behavior";
  35723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35724. import { Observable } from "babylonjs/Misc/observable";
  35725. import { Vector3 } from "babylonjs/Maths/math";
  35726. import { Ray } from "babylonjs/Culling/ray";
  35727. import "babylonjs/Meshes/Builders/planeBuilder";
  35728. /**
  35729. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35730. */
  35731. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35732. private static _AnyMouseID;
  35733. private _attachedNode;
  35734. private _dragPlane;
  35735. private _scene;
  35736. private _pointerObserver;
  35737. private _beforeRenderObserver;
  35738. private static _planeScene;
  35739. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35740. /**
  35741. * 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)
  35742. */
  35743. maxDragAngle: number;
  35744. /**
  35745. * @hidden
  35746. */
  35747. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35748. /**
  35749. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35750. */
  35751. currentDraggingPointerID: number;
  35752. /**
  35753. * The last position where the pointer hit the drag plane in world space
  35754. */
  35755. lastDragPosition: Vector3;
  35756. /**
  35757. * If the behavior is currently in a dragging state
  35758. */
  35759. dragging: boolean;
  35760. /**
  35761. * 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)
  35762. */
  35763. dragDeltaRatio: number;
  35764. /**
  35765. * If the drag plane orientation should be updated during the dragging (Default: true)
  35766. */
  35767. updateDragPlane: boolean;
  35768. private _debugMode;
  35769. private _moving;
  35770. /**
  35771. * Fires each time the attached mesh is dragged with the pointer
  35772. * * delta between last drag position and current drag position in world space
  35773. * * dragDistance along the drag axis
  35774. * * dragPlaneNormal normal of the current drag plane used during the drag
  35775. * * dragPlanePoint in world space where the drag intersects the drag plane
  35776. */
  35777. onDragObservable: Observable<{
  35778. delta: Vector3;
  35779. dragPlanePoint: Vector3;
  35780. dragPlaneNormal: Vector3;
  35781. dragDistance: number;
  35782. pointerId: number;
  35783. }>;
  35784. /**
  35785. * Fires each time a drag begins (eg. mouse down on mesh)
  35786. */
  35787. onDragStartObservable: Observable<{
  35788. dragPlanePoint: Vector3;
  35789. pointerId: number;
  35790. }>;
  35791. /**
  35792. * Fires each time a drag ends (eg. mouse release after drag)
  35793. */
  35794. onDragEndObservable: Observable<{
  35795. dragPlanePoint: Vector3;
  35796. pointerId: number;
  35797. }>;
  35798. /**
  35799. * If the attached mesh should be moved when dragged
  35800. */
  35801. moveAttached: boolean;
  35802. /**
  35803. * If the drag behavior will react to drag events (Default: true)
  35804. */
  35805. enabled: boolean;
  35806. /**
  35807. * If camera controls should be detached during the drag
  35808. */
  35809. detachCameraControls: boolean;
  35810. /**
  35811. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35812. */
  35813. useObjectOrienationForDragging: boolean;
  35814. private _options;
  35815. /**
  35816. * Creates a pointer drag behavior that can be attached to a mesh
  35817. * @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)
  35818. */
  35819. constructor(options?: {
  35820. dragAxis?: Vector3;
  35821. dragPlaneNormal?: Vector3;
  35822. });
  35823. /**
  35824. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35825. */
  35826. validateDrag: (targetPosition: Vector3) => boolean;
  35827. /**
  35828. * The name of the behavior
  35829. */
  35830. readonly name: string;
  35831. /**
  35832. * Initializes the behavior
  35833. */
  35834. init(): void;
  35835. private _tmpVector;
  35836. private _alternatePickedPoint;
  35837. private _worldDragAxis;
  35838. private _targetPosition;
  35839. private _attachedElement;
  35840. /**
  35841. * Attaches the drag behavior the passed in mesh
  35842. * @param ownerNode The mesh that will be dragged around once attached
  35843. */
  35844. attach(ownerNode: AbstractMesh): void;
  35845. /**
  35846. * Force relase the drag action by code.
  35847. */
  35848. releaseDrag(): void;
  35849. private _startDragRay;
  35850. private _lastPointerRay;
  35851. /**
  35852. * Simulates the start of a pointer drag event on the behavior
  35853. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35854. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35855. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35856. */
  35857. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35858. private _startDrag;
  35859. private _dragDelta;
  35860. private _moveDrag;
  35861. private _pickWithRayOnDragPlane;
  35862. private _pointA;
  35863. private _pointB;
  35864. private _pointC;
  35865. private _lineA;
  35866. private _lineB;
  35867. private _localAxis;
  35868. private _lookAt;
  35869. private _updateDragPlanePosition;
  35870. /**
  35871. * Detaches the behavior from the mesh
  35872. */
  35873. detach(): void;
  35874. }
  35875. }
  35876. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35877. import { Mesh } from "babylonjs/Meshes/mesh";
  35878. import { Behavior } from "babylonjs/Behaviors/behavior";
  35879. /**
  35880. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35881. */
  35882. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35883. private _dragBehaviorA;
  35884. private _dragBehaviorB;
  35885. private _startDistance;
  35886. private _initialScale;
  35887. private _targetScale;
  35888. private _ownerNode;
  35889. private _sceneRenderObserver;
  35890. /**
  35891. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35892. */
  35893. constructor();
  35894. /**
  35895. * The name of the behavior
  35896. */
  35897. readonly name: string;
  35898. /**
  35899. * Initializes the behavior
  35900. */
  35901. init(): void;
  35902. private _getCurrentDistance;
  35903. /**
  35904. * Attaches the scale behavior the passed in mesh
  35905. * @param ownerNode The mesh that will be scaled around once attached
  35906. */
  35907. attach(ownerNode: Mesh): void;
  35908. /**
  35909. * Detaches the behavior from the mesh
  35910. */
  35911. detach(): void;
  35912. }
  35913. }
  35914. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35915. import { Behavior } from "babylonjs/Behaviors/behavior";
  35916. import { Mesh } from "babylonjs/Meshes/mesh";
  35917. import { Observable } from "babylonjs/Misc/observable";
  35918. /**
  35919. * 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
  35920. */
  35921. export class SixDofDragBehavior implements Behavior<Mesh> {
  35922. private static _virtualScene;
  35923. private _ownerNode;
  35924. private _sceneRenderObserver;
  35925. private _scene;
  35926. private _targetPosition;
  35927. private _virtualOriginMesh;
  35928. private _virtualDragMesh;
  35929. private _pointerObserver;
  35930. private _moving;
  35931. private _startingOrientation;
  35932. /**
  35933. * 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)
  35934. */
  35935. private zDragFactor;
  35936. /**
  35937. * If the object should rotate to face the drag origin
  35938. */
  35939. rotateDraggedObject: boolean;
  35940. /**
  35941. * If the behavior is currently in a dragging state
  35942. */
  35943. dragging: boolean;
  35944. /**
  35945. * 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)
  35946. */
  35947. dragDeltaRatio: number;
  35948. /**
  35949. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35950. */
  35951. currentDraggingPointerID: number;
  35952. /**
  35953. * If camera controls should be detached during the drag
  35954. */
  35955. detachCameraControls: boolean;
  35956. /**
  35957. * Fires each time a drag starts
  35958. */
  35959. onDragStartObservable: Observable<{}>;
  35960. /**
  35961. * Fires each time a drag ends (eg. mouse release after drag)
  35962. */
  35963. onDragEndObservable: Observable<{}>;
  35964. /**
  35965. * 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
  35966. */
  35967. constructor();
  35968. /**
  35969. * The name of the behavior
  35970. */
  35971. readonly name: string;
  35972. /**
  35973. * Initializes the behavior
  35974. */
  35975. init(): void;
  35976. /**
  35977. * Attaches the scale behavior the passed in mesh
  35978. * @param ownerNode The mesh that will be scaled around once attached
  35979. */
  35980. attach(ownerNode: Mesh): void;
  35981. /**
  35982. * Detaches the behavior from the mesh
  35983. */
  35984. detach(): void;
  35985. }
  35986. }
  35987. declare module "babylonjs/Behaviors/Meshes/index" {
  35988. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35989. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35990. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35991. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35992. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35993. }
  35994. declare module "babylonjs/Behaviors/index" {
  35995. export * from "babylonjs/Behaviors/behavior";
  35996. export * from "babylonjs/Behaviors/Cameras/index";
  35997. export * from "babylonjs/Behaviors/Meshes/index";
  35998. }
  35999. declare module "babylonjs/Bones/boneIKController" {
  36000. import { Bone } from "babylonjs/Bones/bone";
  36001. import { Vector3 } from "babylonjs/Maths/math";
  36002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36003. import { Nullable } from "babylonjs/types";
  36004. /**
  36005. * Class used to apply inverse kinematics to bones
  36006. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36007. */
  36008. export class BoneIKController {
  36009. private static _tmpVecs;
  36010. private static _tmpQuat;
  36011. private static _tmpMats;
  36012. /**
  36013. * Gets or sets the target mesh
  36014. */
  36015. targetMesh: AbstractMesh;
  36016. /** Gets or sets the mesh used as pole */
  36017. poleTargetMesh: AbstractMesh;
  36018. /**
  36019. * Gets or sets the bone used as pole
  36020. */
  36021. poleTargetBone: Nullable<Bone>;
  36022. /**
  36023. * Gets or sets the target position
  36024. */
  36025. targetPosition: Vector3;
  36026. /**
  36027. * Gets or sets the pole target position
  36028. */
  36029. poleTargetPosition: Vector3;
  36030. /**
  36031. * Gets or sets the pole target local offset
  36032. */
  36033. poleTargetLocalOffset: Vector3;
  36034. /**
  36035. * Gets or sets the pole angle
  36036. */
  36037. poleAngle: number;
  36038. /**
  36039. * Gets or sets the mesh associated with the controller
  36040. */
  36041. mesh: AbstractMesh;
  36042. /**
  36043. * 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)
  36044. */
  36045. slerpAmount: number;
  36046. private _bone1Quat;
  36047. private _bone1Mat;
  36048. private _bone2Ang;
  36049. private _bone1;
  36050. private _bone2;
  36051. private _bone1Length;
  36052. private _bone2Length;
  36053. private _maxAngle;
  36054. private _maxReach;
  36055. private _rightHandedSystem;
  36056. private _bendAxis;
  36057. private _slerping;
  36058. private _adjustRoll;
  36059. /**
  36060. * Gets or sets maximum allowed angle
  36061. */
  36062. maxAngle: number;
  36063. /**
  36064. * Creates a new BoneIKController
  36065. * @param mesh defines the mesh to control
  36066. * @param bone defines the bone to control
  36067. * @param options defines options to set up the controller
  36068. */
  36069. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36070. targetMesh?: AbstractMesh;
  36071. poleTargetMesh?: AbstractMesh;
  36072. poleTargetBone?: Bone;
  36073. poleTargetLocalOffset?: Vector3;
  36074. poleAngle?: number;
  36075. bendAxis?: Vector3;
  36076. maxAngle?: number;
  36077. slerpAmount?: number;
  36078. });
  36079. private _setMaxAngle;
  36080. /**
  36081. * Force the controller to update the bones
  36082. */
  36083. update(): void;
  36084. }
  36085. }
  36086. declare module "babylonjs/Bones/boneLookController" {
  36087. import { Vector3, Space } from "babylonjs/Maths/math";
  36088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36089. import { Bone } from "babylonjs/Bones/bone";
  36090. /**
  36091. * Class used to make a bone look toward a point in space
  36092. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36093. */
  36094. export class BoneLookController {
  36095. private static _tmpVecs;
  36096. private static _tmpQuat;
  36097. private static _tmpMats;
  36098. /**
  36099. * The target Vector3 that the bone will look at
  36100. */
  36101. target: Vector3;
  36102. /**
  36103. * The mesh that the bone is attached to
  36104. */
  36105. mesh: AbstractMesh;
  36106. /**
  36107. * The bone that will be looking to the target
  36108. */
  36109. bone: Bone;
  36110. /**
  36111. * The up axis of the coordinate system that is used when the bone is rotated
  36112. */
  36113. upAxis: Vector3;
  36114. /**
  36115. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36116. */
  36117. upAxisSpace: Space;
  36118. /**
  36119. * Used to make an adjustment to the yaw of the bone
  36120. */
  36121. adjustYaw: number;
  36122. /**
  36123. * Used to make an adjustment to the pitch of the bone
  36124. */
  36125. adjustPitch: number;
  36126. /**
  36127. * Used to make an adjustment to the roll of the bone
  36128. */
  36129. adjustRoll: number;
  36130. /**
  36131. * 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)
  36132. */
  36133. slerpAmount: number;
  36134. private _minYaw;
  36135. private _maxYaw;
  36136. private _minPitch;
  36137. private _maxPitch;
  36138. private _minYawSin;
  36139. private _minYawCos;
  36140. private _maxYawSin;
  36141. private _maxYawCos;
  36142. private _midYawConstraint;
  36143. private _minPitchTan;
  36144. private _maxPitchTan;
  36145. private _boneQuat;
  36146. private _slerping;
  36147. private _transformYawPitch;
  36148. private _transformYawPitchInv;
  36149. private _firstFrameSkipped;
  36150. private _yawRange;
  36151. private _fowardAxis;
  36152. /**
  36153. * Gets or sets the minimum yaw angle that the bone can look to
  36154. */
  36155. minYaw: number;
  36156. /**
  36157. * Gets or sets the maximum yaw angle that the bone can look to
  36158. */
  36159. maxYaw: number;
  36160. /**
  36161. * Gets or sets the minimum pitch angle that the bone can look to
  36162. */
  36163. minPitch: number;
  36164. /**
  36165. * Gets or sets the maximum pitch angle that the bone can look to
  36166. */
  36167. maxPitch: number;
  36168. /**
  36169. * Create a BoneLookController
  36170. * @param mesh the mesh that the bone belongs to
  36171. * @param bone the bone that will be looking to the target
  36172. * @param target the target Vector3 to look at
  36173. * @param options optional settings:
  36174. * * maxYaw: the maximum angle the bone will yaw to
  36175. * * minYaw: the minimum angle the bone will yaw to
  36176. * * maxPitch: the maximum angle the bone will pitch to
  36177. * * minPitch: the minimum angle the bone will yaw to
  36178. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36179. * * upAxis: the up axis of the coordinate system
  36180. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36181. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36182. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36183. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36184. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36185. * * adjustRoll: used to make an adjustment to the roll of the bone
  36186. **/
  36187. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36188. maxYaw?: number;
  36189. minYaw?: number;
  36190. maxPitch?: number;
  36191. minPitch?: number;
  36192. slerpAmount?: number;
  36193. upAxis?: Vector3;
  36194. upAxisSpace?: Space;
  36195. yawAxis?: Vector3;
  36196. pitchAxis?: Vector3;
  36197. adjustYaw?: number;
  36198. adjustPitch?: number;
  36199. adjustRoll?: number;
  36200. });
  36201. /**
  36202. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36203. */
  36204. update(): void;
  36205. private _getAngleDiff;
  36206. private _getAngleBetween;
  36207. private _isAngleBetween;
  36208. }
  36209. }
  36210. declare module "babylonjs/Bones/index" {
  36211. export * from "babylonjs/Bones/bone";
  36212. export * from "babylonjs/Bones/boneIKController";
  36213. export * from "babylonjs/Bones/boneLookController";
  36214. export * from "babylonjs/Bones/skeleton";
  36215. }
  36216. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36217. import { Nullable } from "babylonjs/types";
  36218. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36219. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36220. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36221. /**
  36222. * Manage the gamepad inputs to control an arc rotate camera.
  36223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36224. */
  36225. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36226. /**
  36227. * Defines the camera the input is attached to.
  36228. */
  36229. camera: ArcRotateCamera;
  36230. /**
  36231. * Defines the gamepad the input is gathering event from.
  36232. */
  36233. gamepad: Nullable<Gamepad>;
  36234. /**
  36235. * Defines the gamepad rotation sensiblity.
  36236. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36237. */
  36238. gamepadRotationSensibility: number;
  36239. /**
  36240. * Defines the gamepad move sensiblity.
  36241. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36242. */
  36243. gamepadMoveSensibility: number;
  36244. private _onGamepadConnectedObserver;
  36245. private _onGamepadDisconnectedObserver;
  36246. /**
  36247. * Attach the input controls to a specific dom element to get the input from.
  36248. * @param element Defines the element the controls should be listened from
  36249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36250. */
  36251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36252. /**
  36253. * Detach the current controls from the specified dom element.
  36254. * @param element Defines the element to stop listening the inputs from
  36255. */
  36256. detachControl(element: Nullable<HTMLElement>): void;
  36257. /**
  36258. * Update the current camera state depending on the inputs that have been used this frame.
  36259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36260. */
  36261. checkInputs(): void;
  36262. /**
  36263. * Gets the class name of the current intput.
  36264. * @returns the class name
  36265. */
  36266. getClassName(): string;
  36267. /**
  36268. * Get the friendly name associated with the input class.
  36269. * @returns the input friendly name
  36270. */
  36271. getSimpleName(): string;
  36272. }
  36273. }
  36274. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36275. import { Nullable } from "babylonjs/types";
  36276. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36277. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36278. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36279. interface ArcRotateCameraInputsManager {
  36280. /**
  36281. * Add orientation input support to the input manager.
  36282. * @returns the current input manager
  36283. */
  36284. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36285. }
  36286. }
  36287. /**
  36288. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36290. */
  36291. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36292. /**
  36293. * Defines the camera the input is attached to.
  36294. */
  36295. camera: ArcRotateCamera;
  36296. /**
  36297. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36298. */
  36299. alphaCorrection: number;
  36300. /**
  36301. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36302. */
  36303. gammaCorrection: number;
  36304. private _alpha;
  36305. private _gamma;
  36306. private _dirty;
  36307. private _deviceOrientationHandler;
  36308. /**
  36309. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36310. */
  36311. constructor();
  36312. /**
  36313. * Attach the input controls to a specific dom element to get the input from.
  36314. * @param element Defines the element the controls should be listened from
  36315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36316. */
  36317. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36318. /** @hidden */
  36319. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36320. /**
  36321. * Update the current camera state depending on the inputs that have been used this frame.
  36322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36323. */
  36324. checkInputs(): void;
  36325. /**
  36326. * Detach the current controls from the specified dom element.
  36327. * @param element Defines the element to stop listening the inputs from
  36328. */
  36329. detachControl(element: Nullable<HTMLElement>): void;
  36330. /**
  36331. * Gets the class name of the current intput.
  36332. * @returns the class name
  36333. */
  36334. getClassName(): string;
  36335. /**
  36336. * Get the friendly name associated with the input class.
  36337. * @returns the input friendly name
  36338. */
  36339. getSimpleName(): string;
  36340. }
  36341. }
  36342. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36343. import { Nullable } from "babylonjs/types";
  36344. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36345. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36346. /**
  36347. * Listen to mouse events to control the camera.
  36348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36349. */
  36350. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36351. /**
  36352. * Defines the camera the input is attached to.
  36353. */
  36354. camera: FlyCamera;
  36355. /**
  36356. * Defines if touch is enabled. (Default is true.)
  36357. */
  36358. touchEnabled: boolean;
  36359. /**
  36360. * Defines the buttons associated with the input to handle camera rotation.
  36361. */
  36362. buttons: number[];
  36363. /**
  36364. * Assign buttons for Yaw control.
  36365. */
  36366. buttonsYaw: number[];
  36367. /**
  36368. * Assign buttons for Pitch control.
  36369. */
  36370. buttonsPitch: number[];
  36371. /**
  36372. * Assign buttons for Roll control.
  36373. */
  36374. buttonsRoll: number[];
  36375. /**
  36376. * Detect if any button is being pressed while mouse is moved.
  36377. * -1 = Mouse locked.
  36378. * 0 = Left button.
  36379. * 1 = Middle Button.
  36380. * 2 = Right Button.
  36381. */
  36382. activeButton: number;
  36383. /**
  36384. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36385. * Higher values reduce its sensitivity.
  36386. */
  36387. angularSensibility: number;
  36388. private _mousemoveCallback;
  36389. private _observer;
  36390. private _rollObserver;
  36391. private previousPosition;
  36392. private noPreventDefault;
  36393. private element;
  36394. /**
  36395. * Listen to mouse events to control the camera.
  36396. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36398. */
  36399. constructor(touchEnabled?: boolean);
  36400. /**
  36401. * Attach the mouse control to the HTML DOM element.
  36402. * @param element Defines the element that listens to the input events.
  36403. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36404. */
  36405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36406. /**
  36407. * Detach the current controls from the specified dom element.
  36408. * @param element Defines the element to stop listening the inputs from
  36409. */
  36410. detachControl(element: Nullable<HTMLElement>): void;
  36411. /**
  36412. * Gets the class name of the current input.
  36413. * @returns the class name.
  36414. */
  36415. getClassName(): string;
  36416. /**
  36417. * Get the friendly name associated with the input class.
  36418. * @returns the input's friendly name.
  36419. */
  36420. getSimpleName(): string;
  36421. private _pointerInput;
  36422. private _onMouseMove;
  36423. /**
  36424. * Rotate camera by mouse offset.
  36425. */
  36426. private rotateCamera;
  36427. }
  36428. }
  36429. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36430. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36431. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36432. /**
  36433. * Default Inputs manager for the FlyCamera.
  36434. * It groups all the default supported inputs for ease of use.
  36435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36436. */
  36437. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36438. /**
  36439. * Instantiates a new FlyCameraInputsManager.
  36440. * @param camera Defines the camera the inputs belong to.
  36441. */
  36442. constructor(camera: FlyCamera);
  36443. /**
  36444. * Add keyboard input support to the input manager.
  36445. * @returns the new FlyCameraKeyboardMoveInput().
  36446. */
  36447. addKeyboard(): FlyCameraInputsManager;
  36448. /**
  36449. * Add mouse input support to the input manager.
  36450. * @param touchEnabled Enable touch screen support.
  36451. * @returns the new FlyCameraMouseInput().
  36452. */
  36453. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36454. }
  36455. }
  36456. declare module "babylonjs/Cameras/flyCamera" {
  36457. import { Scene } from "babylonjs/scene";
  36458. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36460. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36461. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36462. /**
  36463. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36464. * such as in a 3D Space Shooter or a Flight Simulator.
  36465. */
  36466. export class FlyCamera extends TargetCamera {
  36467. /**
  36468. * Define the collision ellipsoid of the camera.
  36469. * This is helpful for simulating a camera body, like a player's body.
  36470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36471. */
  36472. ellipsoid: Vector3;
  36473. /**
  36474. * Define an offset for the position of the ellipsoid around the camera.
  36475. * This can be helpful if the camera is attached away from the player's body center,
  36476. * such as at its head.
  36477. */
  36478. ellipsoidOffset: Vector3;
  36479. /**
  36480. * Enable or disable collisions of the camera with the rest of the scene objects.
  36481. */
  36482. checkCollisions: boolean;
  36483. /**
  36484. * Enable or disable gravity on the camera.
  36485. */
  36486. applyGravity: boolean;
  36487. /**
  36488. * Define the current direction the camera is moving to.
  36489. */
  36490. cameraDirection: Vector3;
  36491. /**
  36492. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36493. * This overrides and empties cameraRotation.
  36494. */
  36495. rotationQuaternion: Quaternion;
  36496. /**
  36497. * Track Roll to maintain the wanted Rolling when looking around.
  36498. */
  36499. _trackRoll: number;
  36500. /**
  36501. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36502. */
  36503. rollCorrect: number;
  36504. /**
  36505. * Mimic a banked turn, Rolling the camera when Yawing.
  36506. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36507. */
  36508. bankedTurn: boolean;
  36509. /**
  36510. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36511. */
  36512. bankedTurnLimit: number;
  36513. /**
  36514. * Value of 0 disables the banked Roll.
  36515. * Value of 1 is equal to the Yaw angle in radians.
  36516. */
  36517. bankedTurnMultiplier: number;
  36518. /**
  36519. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36520. */
  36521. inputs: FlyCameraInputsManager;
  36522. /**
  36523. * Gets the input sensibility for mouse input.
  36524. * Higher values reduce sensitivity.
  36525. */
  36526. /**
  36527. * Sets the input sensibility for a mouse input.
  36528. * Higher values reduce sensitivity.
  36529. */
  36530. angularSensibility: number;
  36531. /**
  36532. * Get the keys for camera movement forward.
  36533. */
  36534. /**
  36535. * Set the keys for camera movement forward.
  36536. */
  36537. keysForward: number[];
  36538. /**
  36539. * Get the keys for camera movement backward.
  36540. */
  36541. keysBackward: number[];
  36542. /**
  36543. * Get the keys for camera movement up.
  36544. */
  36545. /**
  36546. * Set the keys for camera movement up.
  36547. */
  36548. keysUp: number[];
  36549. /**
  36550. * Get the keys for camera movement down.
  36551. */
  36552. /**
  36553. * Set the keys for camera movement down.
  36554. */
  36555. keysDown: number[];
  36556. /**
  36557. * Get the keys for camera movement left.
  36558. */
  36559. /**
  36560. * Set the keys for camera movement left.
  36561. */
  36562. keysLeft: number[];
  36563. /**
  36564. * Set the keys for camera movement right.
  36565. */
  36566. /**
  36567. * Set the keys for camera movement right.
  36568. */
  36569. keysRight: number[];
  36570. /**
  36571. * Event raised when the camera collides with a mesh in the scene.
  36572. */
  36573. onCollide: (collidedMesh: AbstractMesh) => void;
  36574. private _collider;
  36575. private _needMoveForGravity;
  36576. private _oldPosition;
  36577. private _diffPosition;
  36578. private _newPosition;
  36579. /** @hidden */
  36580. _localDirection: Vector3;
  36581. /** @hidden */
  36582. _transformedDirection: Vector3;
  36583. /**
  36584. * Instantiates a FlyCamera.
  36585. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36586. * such as in a 3D Space Shooter or a Flight Simulator.
  36587. * @param name Define the name of the camera in the scene.
  36588. * @param position Define the starting position of the camera in the scene.
  36589. * @param scene Define the scene the camera belongs to.
  36590. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36591. */
  36592. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36593. /**
  36594. * Attach a control to the HTML DOM element.
  36595. * @param element Defines the element that listens to the input events.
  36596. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36597. */
  36598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36599. /**
  36600. * Detach a control from the HTML DOM element.
  36601. * The camera will stop reacting to that input.
  36602. * @param element Defines the element that listens to the input events.
  36603. */
  36604. detachControl(element: HTMLElement): void;
  36605. private _collisionMask;
  36606. /**
  36607. * Get the mask that the camera ignores in collision events.
  36608. */
  36609. /**
  36610. * Set the mask that the camera ignores in collision events.
  36611. */
  36612. collisionMask: number;
  36613. /** @hidden */
  36614. _collideWithWorld(displacement: Vector3): void;
  36615. /** @hidden */
  36616. private _onCollisionPositionChange;
  36617. /** @hidden */
  36618. _checkInputs(): void;
  36619. /** @hidden */
  36620. _decideIfNeedsToMove(): boolean;
  36621. /** @hidden */
  36622. _updatePosition(): void;
  36623. /**
  36624. * Restore the Roll to its target value at the rate specified.
  36625. * @param rate - Higher means slower restoring.
  36626. * @hidden
  36627. */
  36628. restoreRoll(rate: number): void;
  36629. /**
  36630. * Destroy the camera and release the current resources held by it.
  36631. */
  36632. dispose(): void;
  36633. /**
  36634. * Get the current object class name.
  36635. * @returns the class name.
  36636. */
  36637. getClassName(): string;
  36638. }
  36639. }
  36640. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36641. import { Nullable } from "babylonjs/types";
  36642. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36643. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36644. /**
  36645. * Listen to keyboard events to control the camera.
  36646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36647. */
  36648. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36649. /**
  36650. * Defines the camera the input is attached to.
  36651. */
  36652. camera: FlyCamera;
  36653. /**
  36654. * The list of keyboard keys used to control the forward move of the camera.
  36655. */
  36656. keysForward: number[];
  36657. /**
  36658. * The list of keyboard keys used to control the backward move of the camera.
  36659. */
  36660. keysBackward: number[];
  36661. /**
  36662. * The list of keyboard keys used to control the forward move of the camera.
  36663. */
  36664. keysUp: number[];
  36665. /**
  36666. * The list of keyboard keys used to control the backward move of the camera.
  36667. */
  36668. keysDown: number[];
  36669. /**
  36670. * The list of keyboard keys used to control the right strafe move of the camera.
  36671. */
  36672. keysRight: number[];
  36673. /**
  36674. * The list of keyboard keys used to control the left strafe move of the camera.
  36675. */
  36676. keysLeft: number[];
  36677. private _keys;
  36678. private _onCanvasBlurObserver;
  36679. private _onKeyboardObserver;
  36680. private _engine;
  36681. private _scene;
  36682. /**
  36683. * Attach the input controls to a specific dom element to get the input from.
  36684. * @param element Defines the element the controls should be listened from
  36685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36686. */
  36687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36688. /**
  36689. * Detach the current controls from the specified dom element.
  36690. * @param element Defines the element to stop listening the inputs from
  36691. */
  36692. detachControl(element: Nullable<HTMLElement>): void;
  36693. /**
  36694. * Gets the class name of the current intput.
  36695. * @returns the class name
  36696. */
  36697. getClassName(): string;
  36698. /** @hidden */
  36699. _onLostFocus(e: FocusEvent): void;
  36700. /**
  36701. * Get the friendly name associated with the input class.
  36702. * @returns the input friendly name
  36703. */
  36704. getSimpleName(): string;
  36705. /**
  36706. * Update the current camera state depending on the inputs that have been used this frame.
  36707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36708. */
  36709. checkInputs(): void;
  36710. }
  36711. }
  36712. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36713. import { Nullable } from "babylonjs/types";
  36714. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36715. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36716. /**
  36717. * Manage the mouse wheel inputs to control a follow camera.
  36718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36719. */
  36720. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36721. /**
  36722. * Defines the camera the input is attached to.
  36723. */
  36724. camera: FollowCamera;
  36725. /**
  36726. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36727. */
  36728. axisControlRadius: boolean;
  36729. /**
  36730. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36731. */
  36732. axisControlHeight: boolean;
  36733. /**
  36734. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36735. */
  36736. axisControlRotation: boolean;
  36737. /**
  36738. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36739. * relation to mouseWheel events.
  36740. */
  36741. wheelPrecision: number;
  36742. /**
  36743. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36744. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36745. */
  36746. wheelDeltaPercentage: number;
  36747. private _wheel;
  36748. private _observer;
  36749. /**
  36750. * Attach the input controls to a specific dom element to get the input from.
  36751. * @param element Defines the element the controls should be listened from
  36752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36753. */
  36754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36755. /**
  36756. * Detach the current controls from the specified dom element.
  36757. * @param element Defines the element to stop listening the inputs from
  36758. */
  36759. detachControl(element: Nullable<HTMLElement>): void;
  36760. /**
  36761. * Gets the class name of the current intput.
  36762. * @returns the class name
  36763. */
  36764. getClassName(): string;
  36765. /**
  36766. * Get the friendly name associated with the input class.
  36767. * @returns the input friendly name
  36768. */
  36769. getSimpleName(): string;
  36770. }
  36771. }
  36772. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36773. import { Nullable } from "babylonjs/types";
  36774. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36775. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36776. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36777. /**
  36778. * Manage the pointers inputs to control an follow camera.
  36779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36780. */
  36781. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36782. /**
  36783. * Defines the camera the input is attached to.
  36784. */
  36785. camera: FollowCamera;
  36786. /**
  36787. * Gets the class name of the current input.
  36788. * @returns the class name
  36789. */
  36790. getClassName(): string;
  36791. /**
  36792. * Defines the pointer angular sensibility along the X axis or how fast is
  36793. * the camera rotating.
  36794. * A negative number will reverse the axis direction.
  36795. */
  36796. angularSensibilityX: number;
  36797. /**
  36798. * Defines the pointer angular sensibility along the Y axis or how fast is
  36799. * the camera rotating.
  36800. * A negative number will reverse the axis direction.
  36801. */
  36802. angularSensibilityY: number;
  36803. /**
  36804. * Defines the pointer pinch precision or how fast is the camera zooming.
  36805. * A negative number will reverse the axis direction.
  36806. */
  36807. pinchPrecision: number;
  36808. /**
  36809. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36810. * from 0.
  36811. * It defines the percentage of current camera.radius to use as delta when
  36812. * pinch zoom is used.
  36813. */
  36814. pinchDeltaPercentage: number;
  36815. /**
  36816. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36817. */
  36818. axisXControlRadius: boolean;
  36819. /**
  36820. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36821. */
  36822. axisXControlHeight: boolean;
  36823. /**
  36824. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36825. */
  36826. axisXControlRotation: boolean;
  36827. /**
  36828. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36829. */
  36830. axisYControlRadius: boolean;
  36831. /**
  36832. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36833. */
  36834. axisYControlHeight: boolean;
  36835. /**
  36836. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36837. */
  36838. axisYControlRotation: boolean;
  36839. /**
  36840. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36841. */
  36842. axisPinchControlRadius: boolean;
  36843. /**
  36844. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36845. */
  36846. axisPinchControlHeight: boolean;
  36847. /**
  36848. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36849. */
  36850. axisPinchControlRotation: boolean;
  36851. /**
  36852. * Log error messages if basic misconfiguration has occurred.
  36853. */
  36854. warningEnable: boolean;
  36855. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36856. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36857. private _warningCounter;
  36858. private _warning;
  36859. }
  36860. }
  36861. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36862. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36863. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36864. /**
  36865. * Default Inputs manager for the FollowCamera.
  36866. * It groups all the default supported inputs for ease of use.
  36867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36868. */
  36869. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36870. /**
  36871. * Instantiates a new FollowCameraInputsManager.
  36872. * @param camera Defines the camera the inputs belong to
  36873. */
  36874. constructor(camera: FollowCamera);
  36875. /**
  36876. * Add keyboard input support to the input manager.
  36877. * @returns the current input manager
  36878. */
  36879. addKeyboard(): FollowCameraInputsManager;
  36880. /**
  36881. * Add mouse wheel input support to the input manager.
  36882. * @returns the current input manager
  36883. */
  36884. addMouseWheel(): FollowCameraInputsManager;
  36885. /**
  36886. * Add pointers input support to the input manager.
  36887. * @returns the current input manager
  36888. */
  36889. addPointers(): FollowCameraInputsManager;
  36890. /**
  36891. * Add orientation input support to the input manager.
  36892. * @returns the current input manager
  36893. */
  36894. addVRDeviceOrientation(): FollowCameraInputsManager;
  36895. }
  36896. }
  36897. declare module "babylonjs/Cameras/followCamera" {
  36898. import { Nullable } from "babylonjs/types";
  36899. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36900. import { Scene } from "babylonjs/scene";
  36901. import { Vector3 } from "babylonjs/Maths/math";
  36902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36903. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36904. /**
  36905. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36906. * an arc rotate version arcFollowCamera are available.
  36907. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36908. */
  36909. export class FollowCamera extends TargetCamera {
  36910. /**
  36911. * Distance the follow camera should follow an object at
  36912. */
  36913. radius: number;
  36914. /**
  36915. * Minimum allowed distance of the camera to the axis of rotation
  36916. * (The camera can not get closer).
  36917. * This can help limiting how the Camera is able to move in the scene.
  36918. */
  36919. lowerRadiusLimit: Nullable<number>;
  36920. /**
  36921. * Maximum allowed distance of the camera to the axis of rotation
  36922. * (The camera can not get further).
  36923. * This can help limiting how the Camera is able to move in the scene.
  36924. */
  36925. upperRadiusLimit: Nullable<number>;
  36926. /**
  36927. * Define a rotation offset between the camera and the object it follows
  36928. */
  36929. rotationOffset: number;
  36930. /**
  36931. * Minimum 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. lowerRotationOffsetLimit: Nullable<number>;
  36935. /**
  36936. * Maximum allowed angle to camera position relative to target object.
  36937. * This can help limiting how the Camera is able to move in the scene.
  36938. */
  36939. upperRotationOffsetLimit: Nullable<number>;
  36940. /**
  36941. * Define a height offset between the camera and the object it follows.
  36942. * It can help following an object from the top (like a car chaing a plane)
  36943. */
  36944. heightOffset: number;
  36945. /**
  36946. * Minimum 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. lowerHeightOffsetLimit: Nullable<number>;
  36950. /**
  36951. * Maximum allowed height of camera position relative to target object.
  36952. * This can help limiting how the Camera is able to move in the scene.
  36953. */
  36954. upperHeightOffsetLimit: Nullable<number>;
  36955. /**
  36956. * Define how fast the camera can accelerate to follow it s target.
  36957. */
  36958. cameraAcceleration: number;
  36959. /**
  36960. * Define the speed limit of the camera following an object.
  36961. */
  36962. maxCameraSpeed: number;
  36963. /**
  36964. * Define the target of the camera.
  36965. */
  36966. lockedTarget: Nullable<AbstractMesh>;
  36967. /**
  36968. * Defines the input associated with the camera.
  36969. */
  36970. inputs: FollowCameraInputsManager;
  36971. /**
  36972. * Instantiates the follow camera.
  36973. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36974. * @param name Define the name of the camera in the scene
  36975. * @param position Define the position of the camera
  36976. * @param scene Define the scene the camera belong to
  36977. * @param lockedTarget Define the target of the camera
  36978. */
  36979. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36980. private _follow;
  36981. /**
  36982. * Attached controls to the current camera.
  36983. * @param element Defines the element the controls should be listened from
  36984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36985. */
  36986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36987. /**
  36988. * Detach the current controls from the camera.
  36989. * The camera will stop reacting to inputs.
  36990. * @param element Defines the element to stop listening the inputs from
  36991. */
  36992. detachControl(element: HTMLElement): void;
  36993. /** @hidden */
  36994. _checkInputs(): void;
  36995. private _checkLimits;
  36996. /**
  36997. * Gets the camera class name.
  36998. * @returns the class name
  36999. */
  37000. getClassName(): string;
  37001. }
  37002. /**
  37003. * Arc Rotate version of the follow camera.
  37004. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37005. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37006. */
  37007. export class ArcFollowCamera extends TargetCamera {
  37008. /** The longitudinal angle of the camera */
  37009. alpha: number;
  37010. /** The latitudinal angle of the camera */
  37011. beta: number;
  37012. /** The radius of the camera from its target */
  37013. radius: number;
  37014. /** Define the camera target (the messh it should follow) */
  37015. target: Nullable<AbstractMesh>;
  37016. private _cartesianCoordinates;
  37017. /**
  37018. * Instantiates a new ArcFollowCamera
  37019. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37020. * @param name Define the name of the camera
  37021. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37022. * @param beta Define the rotation angle of the camera around the elevation axis
  37023. * @param radius Define the radius of the camera from its target point
  37024. * @param target Define the target of the camera
  37025. * @param scene Define the scene the camera belongs to
  37026. */
  37027. constructor(name: string,
  37028. /** The longitudinal angle of the camera */
  37029. alpha: number,
  37030. /** The latitudinal angle of the camera */
  37031. beta: number,
  37032. /** The radius of the camera from its target */
  37033. radius: number,
  37034. /** Define the camera target (the messh it should follow) */
  37035. target: Nullable<AbstractMesh>, scene: Scene);
  37036. private _follow;
  37037. /** @hidden */
  37038. _checkInputs(): void;
  37039. /**
  37040. * Returns the class name of the object.
  37041. * It is mostly used internally for serialization purposes.
  37042. */
  37043. getClassName(): string;
  37044. }
  37045. }
  37046. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37047. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37048. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37049. import { Nullable } from "babylonjs/types";
  37050. /**
  37051. * Manage the keyboard inputs to control the movement of a follow camera.
  37052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37053. */
  37054. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37055. /**
  37056. * Defines the camera the input is attached to.
  37057. */
  37058. camera: FollowCamera;
  37059. /**
  37060. * Defines the list of key codes associated with the up action (increase heightOffset)
  37061. */
  37062. keysHeightOffsetIncr: number[];
  37063. /**
  37064. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37065. */
  37066. keysHeightOffsetDecr: number[];
  37067. /**
  37068. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37069. */
  37070. keysHeightOffsetModifierAlt: boolean;
  37071. /**
  37072. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37073. */
  37074. keysHeightOffsetModifierCtrl: boolean;
  37075. /**
  37076. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37077. */
  37078. keysHeightOffsetModifierShift: boolean;
  37079. /**
  37080. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37081. */
  37082. keysRotationOffsetIncr: number[];
  37083. /**
  37084. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37085. */
  37086. keysRotationOffsetDecr: number[];
  37087. /**
  37088. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37089. */
  37090. keysRotationOffsetModifierAlt: boolean;
  37091. /**
  37092. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37093. */
  37094. keysRotationOffsetModifierCtrl: boolean;
  37095. /**
  37096. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37097. */
  37098. keysRotationOffsetModifierShift: boolean;
  37099. /**
  37100. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37101. */
  37102. keysRadiusIncr: number[];
  37103. /**
  37104. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37105. */
  37106. keysRadiusDecr: number[];
  37107. /**
  37108. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37109. */
  37110. keysRadiusModifierAlt: boolean;
  37111. /**
  37112. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37113. */
  37114. keysRadiusModifierCtrl: boolean;
  37115. /**
  37116. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37117. */
  37118. keysRadiusModifierShift: boolean;
  37119. /**
  37120. * Defines the rate of change of heightOffset.
  37121. */
  37122. heightSensibility: number;
  37123. /**
  37124. * Defines the rate of change of rotationOffset.
  37125. */
  37126. rotationSensibility: number;
  37127. /**
  37128. * Defines the rate of change of radius.
  37129. */
  37130. radiusSensibility: number;
  37131. private _keys;
  37132. private _ctrlPressed;
  37133. private _altPressed;
  37134. private _shiftPressed;
  37135. private _onCanvasBlurObserver;
  37136. private _onKeyboardObserver;
  37137. private _engine;
  37138. private _scene;
  37139. /**
  37140. * Attach the input controls to a specific dom element to get the input from.
  37141. * @param element Defines the element the controls should be listened from
  37142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37143. */
  37144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37145. /**
  37146. * Detach the current controls from the specified dom element.
  37147. * @param element Defines the element to stop listening the inputs from
  37148. */
  37149. detachControl(element: Nullable<HTMLElement>): void;
  37150. /**
  37151. * Update the current camera state depending on the inputs that have been used this frame.
  37152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37153. */
  37154. checkInputs(): void;
  37155. /**
  37156. * Gets the class name of the current input.
  37157. * @returns the class name
  37158. */
  37159. getClassName(): string;
  37160. /**
  37161. * Get the friendly name associated with the input class.
  37162. * @returns the input friendly name
  37163. */
  37164. getSimpleName(): string;
  37165. /**
  37166. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37167. * allow modification of the heightOffset value.
  37168. */
  37169. private _modifierHeightOffset;
  37170. /**
  37171. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37172. * allow modification of the rotationOffset value.
  37173. */
  37174. private _modifierRotationOffset;
  37175. /**
  37176. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37177. * allow modification of the radius value.
  37178. */
  37179. private _modifierRadius;
  37180. }
  37181. }
  37182. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37183. import { Nullable } from "babylonjs/types";
  37184. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37185. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37186. module "babylonjs/Cameras/freeCameraInputsManager" {
  37187. interface FreeCameraInputsManager {
  37188. /**
  37189. * Add orientation input support to the input manager.
  37190. * @returns the current input manager
  37191. */
  37192. addDeviceOrientation(): FreeCameraInputsManager;
  37193. }
  37194. }
  37195. /**
  37196. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37197. * Screen rotation is taken into account.
  37198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37199. */
  37200. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37201. private _camera;
  37202. private _screenOrientationAngle;
  37203. private _constantTranform;
  37204. private _screenQuaternion;
  37205. private _alpha;
  37206. private _beta;
  37207. private _gamma;
  37208. /**
  37209. * Instantiates a new input
  37210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37211. */
  37212. constructor();
  37213. /**
  37214. * Define the camera controlled by the input.
  37215. */
  37216. camera: FreeCamera;
  37217. /**
  37218. * Attach the input controls to a specific dom element to get the input from.
  37219. * @param element Defines the element the controls should be listened from
  37220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37221. */
  37222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37223. private _orientationChanged;
  37224. private _deviceOrientation;
  37225. /**
  37226. * Detach the current controls from the specified dom element.
  37227. * @param element Defines the element to stop listening the inputs from
  37228. */
  37229. detachControl(element: Nullable<HTMLElement>): void;
  37230. /**
  37231. * Update the current camera state depending on the inputs that have been used this frame.
  37232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37233. */
  37234. checkInputs(): void;
  37235. /**
  37236. * Gets the class name of the current intput.
  37237. * @returns the class name
  37238. */
  37239. getClassName(): string;
  37240. /**
  37241. * Get the friendly name associated with the input class.
  37242. * @returns the input friendly name
  37243. */
  37244. getSimpleName(): string;
  37245. }
  37246. }
  37247. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37248. import { Nullable } from "babylonjs/types";
  37249. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37250. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37251. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37252. /**
  37253. * Manage the gamepad inputs to control a free camera.
  37254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37255. */
  37256. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37257. /**
  37258. * Define the camera the input is attached to.
  37259. */
  37260. camera: FreeCamera;
  37261. /**
  37262. * Define the Gamepad controlling the input
  37263. */
  37264. gamepad: Nullable<Gamepad>;
  37265. /**
  37266. * Defines the gamepad rotation sensiblity.
  37267. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37268. */
  37269. gamepadAngularSensibility: number;
  37270. /**
  37271. * Defines the gamepad move sensiblity.
  37272. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37273. */
  37274. gamepadMoveSensibility: number;
  37275. private _onGamepadConnectedObserver;
  37276. private _onGamepadDisconnectedObserver;
  37277. private _cameraTransform;
  37278. private _deltaTransform;
  37279. private _vector3;
  37280. private _vector2;
  37281. /**
  37282. * Attach the input controls to a specific dom element to get the input from.
  37283. * @param element Defines the element the controls should be listened from
  37284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37285. */
  37286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37287. /**
  37288. * Detach the current controls from the specified dom element.
  37289. * @param element Defines the element to stop listening the inputs from
  37290. */
  37291. detachControl(element: Nullable<HTMLElement>): void;
  37292. /**
  37293. * Update the current camera state depending on the inputs that have been used this frame.
  37294. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37295. */
  37296. checkInputs(): void;
  37297. /**
  37298. * Gets the class name of the current intput.
  37299. * @returns the class name
  37300. */
  37301. getClassName(): string;
  37302. /**
  37303. * Get the friendly name associated with the input class.
  37304. * @returns the input friendly name
  37305. */
  37306. getSimpleName(): string;
  37307. }
  37308. }
  37309. declare module "babylonjs/Misc/virtualJoystick" {
  37310. import { Nullable } from "babylonjs/types";
  37311. import { Vector3 } from "babylonjs/Maths/math";
  37312. /**
  37313. * Defines the potential axis of a Joystick
  37314. */
  37315. export enum JoystickAxis {
  37316. /** X axis */
  37317. X = 0,
  37318. /** Y axis */
  37319. Y = 1,
  37320. /** Z axis */
  37321. Z = 2
  37322. }
  37323. /**
  37324. * Class used to define virtual joystick (used in touch mode)
  37325. */
  37326. export class VirtualJoystick {
  37327. /**
  37328. * Gets or sets a boolean indicating that left and right values must be inverted
  37329. */
  37330. reverseLeftRight: boolean;
  37331. /**
  37332. * Gets or sets a boolean indicating that up and down values must be inverted
  37333. */
  37334. reverseUpDown: boolean;
  37335. /**
  37336. * Gets the offset value for the position (ie. the change of the position value)
  37337. */
  37338. deltaPosition: Vector3;
  37339. /**
  37340. * Gets a boolean indicating if the virtual joystick was pressed
  37341. */
  37342. pressed: boolean;
  37343. /**
  37344. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37345. */
  37346. static Canvas: Nullable<HTMLCanvasElement>;
  37347. private static _globalJoystickIndex;
  37348. private static vjCanvasContext;
  37349. private static vjCanvasWidth;
  37350. private static vjCanvasHeight;
  37351. private static halfWidth;
  37352. private _action;
  37353. private _axisTargetedByLeftAndRight;
  37354. private _axisTargetedByUpAndDown;
  37355. private _joystickSensibility;
  37356. private _inversedSensibility;
  37357. private _joystickPointerID;
  37358. private _joystickColor;
  37359. private _joystickPointerPos;
  37360. private _joystickPreviousPointerPos;
  37361. private _joystickPointerStartPos;
  37362. private _deltaJoystickVector;
  37363. private _leftJoystick;
  37364. private _touches;
  37365. private _onPointerDownHandlerRef;
  37366. private _onPointerMoveHandlerRef;
  37367. private _onPointerUpHandlerRef;
  37368. private _onResize;
  37369. /**
  37370. * Creates a new virtual joystick
  37371. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37372. */
  37373. constructor(leftJoystick?: boolean);
  37374. /**
  37375. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37376. * @param newJoystickSensibility defines the new sensibility
  37377. */
  37378. setJoystickSensibility(newJoystickSensibility: number): void;
  37379. private _onPointerDown;
  37380. private _onPointerMove;
  37381. private _onPointerUp;
  37382. /**
  37383. * Change the color of the virtual joystick
  37384. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37385. */
  37386. setJoystickColor(newColor: string): void;
  37387. /**
  37388. * Defines a callback to call when the joystick is touched
  37389. * @param action defines the callback
  37390. */
  37391. setActionOnTouch(action: () => any): void;
  37392. /**
  37393. * Defines which axis you'd like to control for left & right
  37394. * @param axis defines the axis to use
  37395. */
  37396. setAxisForLeftRight(axis: JoystickAxis): void;
  37397. /**
  37398. * Defines which axis you'd like to control for up & down
  37399. * @param axis defines the axis to use
  37400. */
  37401. setAxisForUpDown(axis: JoystickAxis): void;
  37402. private _drawVirtualJoystick;
  37403. /**
  37404. * Release internal HTML canvas
  37405. */
  37406. releaseCanvas(): void;
  37407. }
  37408. }
  37409. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37410. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37411. import { Nullable } from "babylonjs/types";
  37412. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37413. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37414. module "babylonjs/Cameras/freeCameraInputsManager" {
  37415. interface FreeCameraInputsManager {
  37416. /**
  37417. * Add virtual joystick input support to the input manager.
  37418. * @returns the current input manager
  37419. */
  37420. addVirtualJoystick(): FreeCameraInputsManager;
  37421. }
  37422. }
  37423. /**
  37424. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37426. */
  37427. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37428. /**
  37429. * Defines the camera the input is attached to.
  37430. */
  37431. camera: FreeCamera;
  37432. private _leftjoystick;
  37433. private _rightjoystick;
  37434. /**
  37435. * Gets the left stick of the virtual joystick.
  37436. * @returns The virtual Joystick
  37437. */
  37438. getLeftJoystick(): VirtualJoystick;
  37439. /**
  37440. * Gets the right stick of the virtual joystick.
  37441. * @returns The virtual Joystick
  37442. */
  37443. getRightJoystick(): VirtualJoystick;
  37444. /**
  37445. * Update the current camera state depending on the inputs that have been used this frame.
  37446. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37447. */
  37448. checkInputs(): void;
  37449. /**
  37450. * Attach the input controls to a specific dom element to get the input from.
  37451. * @param element Defines the element the controls should be listened from
  37452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37453. */
  37454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37455. /**
  37456. * Detach the current controls from the specified dom element.
  37457. * @param element Defines the element to stop listening the inputs from
  37458. */
  37459. detachControl(element: Nullable<HTMLElement>): void;
  37460. /**
  37461. * Gets the class name of the current intput.
  37462. * @returns the class name
  37463. */
  37464. getClassName(): string;
  37465. /**
  37466. * Get the friendly name associated with the input class.
  37467. * @returns the input friendly name
  37468. */
  37469. getSimpleName(): string;
  37470. }
  37471. }
  37472. declare module "babylonjs/Cameras/Inputs/index" {
  37473. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37474. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37475. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37476. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37477. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37478. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37479. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37480. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37481. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37482. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37483. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37484. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37485. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37486. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37487. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37488. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37489. }
  37490. declare module "babylonjs/Cameras/touchCamera" {
  37491. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37492. import { Scene } from "babylonjs/scene";
  37493. import { Vector3 } from "babylonjs/Maths/math";
  37494. /**
  37495. * This represents a FPS type of camera controlled by touch.
  37496. * This is like a universal camera minus the Gamepad controls.
  37497. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37498. */
  37499. export class TouchCamera extends FreeCamera {
  37500. /**
  37501. * Defines the touch sensibility for rotation.
  37502. * The higher the faster.
  37503. */
  37504. touchAngularSensibility: number;
  37505. /**
  37506. * Defines the touch sensibility for move.
  37507. * The higher the faster.
  37508. */
  37509. touchMoveSensibility: number;
  37510. /**
  37511. * Instantiates a new touch camera.
  37512. * This represents a FPS type of camera controlled by touch.
  37513. * This is like a universal camera minus the Gamepad controls.
  37514. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37515. * @param name Define the name of the camera in the scene
  37516. * @param position Define the start position of the camera in the scene
  37517. * @param scene Define the scene the camera belongs to
  37518. */
  37519. constructor(name: string, position: Vector3, scene: Scene);
  37520. /**
  37521. * Gets the current object class name.
  37522. * @return the class name
  37523. */
  37524. getClassName(): string;
  37525. /** @hidden */
  37526. _setupInputs(): void;
  37527. }
  37528. }
  37529. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37531. import { Scene } from "babylonjs/scene";
  37532. import { Vector3, Axis } from "babylonjs/Maths/math";
  37533. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37534. /**
  37535. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37536. * being tilted forward or back and left or right.
  37537. */
  37538. export class DeviceOrientationCamera extends FreeCamera {
  37539. private _initialQuaternion;
  37540. private _quaternionCache;
  37541. /**
  37542. * Creates a new device orientation camera
  37543. * @param name The name of the camera
  37544. * @param position The start position camera
  37545. * @param scene The scene the camera belongs to
  37546. */
  37547. constructor(name: string, position: Vector3, scene: Scene);
  37548. /**
  37549. * Gets the current instance class name ("DeviceOrientationCamera").
  37550. * This helps avoiding instanceof at run time.
  37551. * @returns the class name
  37552. */
  37553. getClassName(): string;
  37554. /**
  37555. * @hidden
  37556. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37557. */
  37558. _checkInputs(): void;
  37559. /**
  37560. * Reset the camera to its default orientation on the specified axis only.
  37561. * @param axis The axis to reset
  37562. */
  37563. resetToCurrentRotation(axis?: Axis): void;
  37564. }
  37565. }
  37566. declare module "babylonjs/Cameras/universalCamera" {
  37567. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37568. import { Scene } from "babylonjs/scene";
  37569. import { Vector3 } from "babylonjs/Maths/math";
  37570. /**
  37571. * 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,
  37572. * which still works and will still be found in many Playgrounds.
  37573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37574. */
  37575. export class UniversalCamera extends TouchCamera {
  37576. /**
  37577. * Defines the gamepad rotation sensiblity.
  37578. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37579. */
  37580. gamepadAngularSensibility: number;
  37581. /**
  37582. * Defines the gamepad move sensiblity.
  37583. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37584. */
  37585. gamepadMoveSensibility: number;
  37586. /**
  37587. * 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,
  37588. * which still works and will still be found in many Playgrounds.
  37589. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37590. * @param name Define the name of the camera in the scene
  37591. * @param position Define the start position of the camera in the scene
  37592. * @param scene Define the scene the camera belongs to
  37593. */
  37594. constructor(name: string, position: Vector3, scene: Scene);
  37595. /**
  37596. * Gets the current object class name.
  37597. * @return the class name
  37598. */
  37599. getClassName(): string;
  37600. }
  37601. }
  37602. declare module "babylonjs/Cameras/gamepadCamera" {
  37603. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37604. import { Scene } from "babylonjs/scene";
  37605. import { Vector3 } from "babylonjs/Maths/math";
  37606. /**
  37607. * This represents a FPS type of camera. This is only here for back compat purpose.
  37608. * Please use the UniversalCamera instead as both are identical.
  37609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37610. */
  37611. export class GamepadCamera extends UniversalCamera {
  37612. /**
  37613. * Instantiates a new Gamepad Camera
  37614. * This represents a FPS type of camera. This is only here for back compat purpose.
  37615. * Please use the UniversalCamera instead as both are identical.
  37616. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37617. * @param name Define the name of the camera in the scene
  37618. * @param position Define the start position of the camera in the scene
  37619. * @param scene Define the scene the camera belongs to
  37620. */
  37621. constructor(name: string, position: Vector3, scene: Scene);
  37622. /**
  37623. * Gets the current object class name.
  37624. * @return the class name
  37625. */
  37626. getClassName(): string;
  37627. }
  37628. }
  37629. declare module "babylonjs/Shaders/pass.fragment" {
  37630. /** @hidden */
  37631. export var passPixelShader: {
  37632. name: string;
  37633. shader: string;
  37634. };
  37635. }
  37636. declare module "babylonjs/Shaders/passCube.fragment" {
  37637. /** @hidden */
  37638. export var passCubePixelShader: {
  37639. name: string;
  37640. shader: string;
  37641. };
  37642. }
  37643. declare module "babylonjs/PostProcesses/passPostProcess" {
  37644. import { Nullable } from "babylonjs/types";
  37645. import { Camera } from "babylonjs/Cameras/camera";
  37646. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37647. import { Engine } from "babylonjs/Engines/engine";
  37648. import "babylonjs/Shaders/pass.fragment";
  37649. import "babylonjs/Shaders/passCube.fragment";
  37650. /**
  37651. * PassPostProcess which produces an output the same as it's input
  37652. */
  37653. export class PassPostProcess extends PostProcess {
  37654. /**
  37655. * Creates the PassPostProcess
  37656. * @param name The name of the effect.
  37657. * @param options The required width/height ratio to downsize to before computing the render pass.
  37658. * @param camera The camera to apply the render pass to.
  37659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37660. * @param engine The engine which the post process will be applied. (default: current engine)
  37661. * @param reusable If the post process can be reused on the same frame. (default: false)
  37662. * @param textureType The type of texture to be used when performing the post processing.
  37663. * @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)
  37664. */
  37665. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37666. }
  37667. /**
  37668. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37669. */
  37670. export class PassCubePostProcess extends PostProcess {
  37671. private _face;
  37672. /**
  37673. * Gets or sets the cube face to display.
  37674. * * 0 is +X
  37675. * * 1 is -X
  37676. * * 2 is +Y
  37677. * * 3 is -Y
  37678. * * 4 is +Z
  37679. * * 5 is -Z
  37680. */
  37681. face: number;
  37682. /**
  37683. * Creates the PassCubePostProcess
  37684. * @param name The name of the effect.
  37685. * @param options The required width/height ratio to downsize to before computing the render pass.
  37686. * @param camera The camera to apply the render pass to.
  37687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37688. * @param engine The engine which the post process will be applied. (default: current engine)
  37689. * @param reusable If the post process can be reused on the same frame. (default: false)
  37690. * @param textureType The type of texture to be used when performing the post processing.
  37691. * @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)
  37692. */
  37693. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37694. }
  37695. }
  37696. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37697. /** @hidden */
  37698. export var anaglyphPixelShader: {
  37699. name: string;
  37700. shader: string;
  37701. };
  37702. }
  37703. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37704. import { Engine } from "babylonjs/Engines/engine";
  37705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37706. import { Camera } from "babylonjs/Cameras/camera";
  37707. import "babylonjs/Shaders/anaglyph.fragment";
  37708. /**
  37709. * Postprocess used to generate anaglyphic rendering
  37710. */
  37711. export class AnaglyphPostProcess extends PostProcess {
  37712. private _passedProcess;
  37713. /**
  37714. * Creates a new AnaglyphPostProcess
  37715. * @param name defines postprocess name
  37716. * @param options defines creation options or target ratio scale
  37717. * @param rigCameras defines cameras using this postprocess
  37718. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37719. * @param engine defines hosting engine
  37720. * @param reusable defines if the postprocess will be reused multiple times per frame
  37721. */
  37722. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37723. }
  37724. }
  37725. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37726. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37727. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37728. import { Scene } from "babylonjs/scene";
  37729. import { Vector3 } from "babylonjs/Maths/math";
  37730. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37731. /**
  37732. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37733. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37734. */
  37735. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37736. /**
  37737. * Creates a new AnaglyphArcRotateCamera
  37738. * @param name defines camera name
  37739. * @param alpha defines alpha angle (in radians)
  37740. * @param beta defines beta angle (in radians)
  37741. * @param radius defines radius
  37742. * @param target defines camera target
  37743. * @param interaxialDistance defines distance between each color axis
  37744. * @param scene defines the hosting scene
  37745. */
  37746. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37747. /**
  37748. * Gets camera class name
  37749. * @returns AnaglyphArcRotateCamera
  37750. */
  37751. getClassName(): string;
  37752. }
  37753. }
  37754. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37755. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37756. import { Scene } from "babylonjs/scene";
  37757. import { Vector3 } from "babylonjs/Maths/math";
  37758. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37759. /**
  37760. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37761. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37762. */
  37763. export class AnaglyphFreeCamera extends FreeCamera {
  37764. /**
  37765. * Creates a new AnaglyphFreeCamera
  37766. * @param name defines camera name
  37767. * @param position defines initial position
  37768. * @param interaxialDistance defines distance between each color axis
  37769. * @param scene defines the hosting scene
  37770. */
  37771. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37772. /**
  37773. * Gets camera class name
  37774. * @returns AnaglyphFreeCamera
  37775. */
  37776. getClassName(): string;
  37777. }
  37778. }
  37779. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37780. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37781. import { Scene } from "babylonjs/scene";
  37782. import { Vector3 } from "babylonjs/Maths/math";
  37783. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37784. /**
  37785. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37786. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37787. */
  37788. export class AnaglyphGamepadCamera extends GamepadCamera {
  37789. /**
  37790. * Creates a new AnaglyphGamepadCamera
  37791. * @param name defines camera name
  37792. * @param position defines initial position
  37793. * @param interaxialDistance defines distance between each color axis
  37794. * @param scene defines the hosting scene
  37795. */
  37796. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37797. /**
  37798. * Gets camera class name
  37799. * @returns AnaglyphGamepadCamera
  37800. */
  37801. getClassName(): string;
  37802. }
  37803. }
  37804. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37805. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37806. import { Scene } from "babylonjs/scene";
  37807. import { Vector3 } from "babylonjs/Maths/math";
  37808. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37809. /**
  37810. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37811. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37812. */
  37813. export class AnaglyphUniversalCamera extends UniversalCamera {
  37814. /**
  37815. * Creates a new AnaglyphUniversalCamera
  37816. * @param name defines camera name
  37817. * @param position defines initial position
  37818. * @param interaxialDistance defines distance between each color axis
  37819. * @param scene defines the hosting scene
  37820. */
  37821. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37822. /**
  37823. * Gets camera class name
  37824. * @returns AnaglyphUniversalCamera
  37825. */
  37826. getClassName(): string;
  37827. }
  37828. }
  37829. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37830. /** @hidden */
  37831. export var stereoscopicInterlacePixelShader: {
  37832. name: string;
  37833. shader: string;
  37834. };
  37835. }
  37836. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37837. import { Camera } from "babylonjs/Cameras/camera";
  37838. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37839. import { Engine } from "babylonjs/Engines/engine";
  37840. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37841. /**
  37842. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37843. */
  37844. export class StereoscopicInterlacePostProcess extends PostProcess {
  37845. private _stepSize;
  37846. private _passedProcess;
  37847. /**
  37848. * Initializes a StereoscopicInterlacePostProcess
  37849. * @param name The name of the effect.
  37850. * @param rigCameras The rig cameras to be appled to the post process
  37851. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37852. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37853. * @param engine The engine which the post process will be applied. (default: current engine)
  37854. * @param reusable If the post process can be reused on the same frame. (default: false)
  37855. */
  37856. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37857. }
  37858. }
  37859. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37860. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37861. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37862. import { Scene } from "babylonjs/scene";
  37863. import { Vector3 } from "babylonjs/Maths/math";
  37864. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37865. /**
  37866. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37867. * @see http://doc.babylonjs.com/features/cameras
  37868. */
  37869. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37870. /**
  37871. * Creates a new StereoscopicArcRotateCamera
  37872. * @param name defines camera name
  37873. * @param alpha defines alpha angle (in radians)
  37874. * @param beta defines beta angle (in radians)
  37875. * @param radius defines radius
  37876. * @param target defines camera target
  37877. * @param interaxialDistance defines distance between each color axis
  37878. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37879. * @param scene defines the hosting scene
  37880. */
  37881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37882. /**
  37883. * Gets camera class name
  37884. * @returns StereoscopicArcRotateCamera
  37885. */
  37886. getClassName(): string;
  37887. }
  37888. }
  37889. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37890. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37891. import { Scene } from "babylonjs/scene";
  37892. import { Vector3 } from "babylonjs/Maths/math";
  37893. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37894. /**
  37895. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37896. * @see http://doc.babylonjs.com/features/cameras
  37897. */
  37898. export class StereoscopicFreeCamera extends FreeCamera {
  37899. /**
  37900. * Creates a new StereoscopicFreeCamera
  37901. * @param name defines camera name
  37902. * @param position defines initial position
  37903. * @param interaxialDistance defines distance between each color axis
  37904. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37905. * @param scene defines the hosting scene
  37906. */
  37907. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37908. /**
  37909. * Gets camera class name
  37910. * @returns StereoscopicFreeCamera
  37911. */
  37912. getClassName(): string;
  37913. }
  37914. }
  37915. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37916. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37917. import { Scene } from "babylonjs/scene";
  37918. import { Vector3 } from "babylonjs/Maths/math";
  37919. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37920. /**
  37921. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37922. * @see http://doc.babylonjs.com/features/cameras
  37923. */
  37924. export class StereoscopicGamepadCamera extends GamepadCamera {
  37925. /**
  37926. * Creates a new StereoscopicGamepadCamera
  37927. * @param name defines camera name
  37928. * @param position defines initial position
  37929. * @param interaxialDistance defines distance between each color axis
  37930. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37931. * @param scene defines the hosting scene
  37932. */
  37933. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37934. /**
  37935. * Gets camera class name
  37936. * @returns StereoscopicGamepadCamera
  37937. */
  37938. getClassName(): string;
  37939. }
  37940. }
  37941. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37942. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37943. import { Scene } from "babylonjs/scene";
  37944. import { Vector3 } from "babylonjs/Maths/math";
  37945. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37946. /**
  37947. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37948. * @see http://doc.babylonjs.com/features/cameras
  37949. */
  37950. export class StereoscopicUniversalCamera extends UniversalCamera {
  37951. /**
  37952. * Creates a new StereoscopicUniversalCamera
  37953. * @param name defines camera name
  37954. * @param position defines initial position
  37955. * @param interaxialDistance defines distance between each color axis
  37956. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37957. * @param scene defines the hosting scene
  37958. */
  37959. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37960. /**
  37961. * Gets camera class name
  37962. * @returns StereoscopicUniversalCamera
  37963. */
  37964. getClassName(): string;
  37965. }
  37966. }
  37967. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37968. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37969. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37970. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37971. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37972. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37973. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37974. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37975. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37976. }
  37977. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37979. import { Scene } from "babylonjs/scene";
  37980. import { Vector3 } from "babylonjs/Maths/math";
  37981. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37982. /**
  37983. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37984. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37985. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37986. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37987. */
  37988. export class VirtualJoysticksCamera extends FreeCamera {
  37989. /**
  37990. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37991. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37992. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37993. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37994. * @param name Define the name of the camera in the scene
  37995. * @param position Define the start position of the camera in the scene
  37996. * @param scene Define the scene the camera belongs to
  37997. */
  37998. constructor(name: string, position: Vector3, scene: Scene);
  37999. /**
  38000. * Gets the current object class name.
  38001. * @return the class name
  38002. */
  38003. getClassName(): string;
  38004. }
  38005. }
  38006. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38007. import { Matrix } from "babylonjs/Maths/math";
  38008. /**
  38009. * This represents all the required metrics to create a VR camera.
  38010. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38011. */
  38012. export class VRCameraMetrics {
  38013. /**
  38014. * Define the horizontal resolution off the screen.
  38015. */
  38016. hResolution: number;
  38017. /**
  38018. * Define the vertical resolution off the screen.
  38019. */
  38020. vResolution: number;
  38021. /**
  38022. * Define the horizontal screen size.
  38023. */
  38024. hScreenSize: number;
  38025. /**
  38026. * Define the vertical screen size.
  38027. */
  38028. vScreenSize: number;
  38029. /**
  38030. * Define the vertical screen center position.
  38031. */
  38032. vScreenCenter: number;
  38033. /**
  38034. * Define the distance of the eyes to the screen.
  38035. */
  38036. eyeToScreenDistance: number;
  38037. /**
  38038. * Define the distance between both lenses
  38039. */
  38040. lensSeparationDistance: number;
  38041. /**
  38042. * Define the distance between both viewer's eyes.
  38043. */
  38044. interpupillaryDistance: number;
  38045. /**
  38046. * Define the distortion factor of the VR postprocess.
  38047. * Please, touch with care.
  38048. */
  38049. distortionK: number[];
  38050. /**
  38051. * Define the chromatic aberration correction factors for the VR post process.
  38052. */
  38053. chromaAbCorrection: number[];
  38054. /**
  38055. * Define the scale factor of the post process.
  38056. * The smaller the better but the slower.
  38057. */
  38058. postProcessScaleFactor: number;
  38059. /**
  38060. * Define an offset for the lens center.
  38061. */
  38062. lensCenterOffset: number;
  38063. /**
  38064. * Define if the current vr camera should compensate the distortion of the lense or not.
  38065. */
  38066. compensateDistortion: boolean;
  38067. /**
  38068. * Gets the rendering aspect ratio based on the provided resolutions.
  38069. */
  38070. readonly aspectRatio: number;
  38071. /**
  38072. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38073. */
  38074. readonly aspectRatioFov: number;
  38075. /**
  38076. * @hidden
  38077. */
  38078. readonly leftHMatrix: Matrix;
  38079. /**
  38080. * @hidden
  38081. */
  38082. readonly rightHMatrix: Matrix;
  38083. /**
  38084. * @hidden
  38085. */
  38086. readonly leftPreViewMatrix: Matrix;
  38087. /**
  38088. * @hidden
  38089. */
  38090. readonly rightPreViewMatrix: Matrix;
  38091. /**
  38092. * Get the default VRMetrics based on the most generic setup.
  38093. * @returns the default vr metrics
  38094. */
  38095. static GetDefault(): VRCameraMetrics;
  38096. }
  38097. }
  38098. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38099. /** @hidden */
  38100. export var vrDistortionCorrectionPixelShader: {
  38101. name: string;
  38102. shader: string;
  38103. };
  38104. }
  38105. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38106. import { Camera } from "babylonjs/Cameras/camera";
  38107. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38108. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38109. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38110. /**
  38111. * VRDistortionCorrectionPostProcess used for mobile VR
  38112. */
  38113. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38114. private _isRightEye;
  38115. private _distortionFactors;
  38116. private _postProcessScaleFactor;
  38117. private _lensCenterOffset;
  38118. private _scaleIn;
  38119. private _scaleFactor;
  38120. private _lensCenter;
  38121. /**
  38122. * Initializes the VRDistortionCorrectionPostProcess
  38123. * @param name The name of the effect.
  38124. * @param camera The camera to apply the render pass to.
  38125. * @param isRightEye If this is for the right eye distortion
  38126. * @param vrMetrics All the required metrics for the VR camera
  38127. */
  38128. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38129. }
  38130. }
  38131. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38132. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38133. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38134. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38135. import { Scene } from "babylonjs/scene";
  38136. import { Vector3 } from "babylonjs/Maths/math";
  38137. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38138. import "babylonjs/Cameras/RigModes/vrRigMode";
  38139. /**
  38140. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38141. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38142. */
  38143. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38144. /**
  38145. * Creates a new VRDeviceOrientationArcRotateCamera
  38146. * @param name defines camera name
  38147. * @param alpha defines the camera rotation along the logitudinal axis
  38148. * @param beta defines the camera rotation along the latitudinal axis
  38149. * @param radius defines the camera distance from its target
  38150. * @param target defines the camera target
  38151. * @param scene defines the scene the camera belongs to
  38152. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38153. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38154. */
  38155. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38156. /**
  38157. * Gets camera class name
  38158. * @returns VRDeviceOrientationArcRotateCamera
  38159. */
  38160. getClassName(): string;
  38161. }
  38162. }
  38163. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38164. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38165. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38166. import { Scene } from "babylonjs/scene";
  38167. import { Vector3 } from "babylonjs/Maths/math";
  38168. import "babylonjs/Cameras/RigModes/vrRigMode";
  38169. /**
  38170. * Camera used to simulate VR rendering (based on FreeCamera)
  38171. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38172. */
  38173. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38174. /**
  38175. * Creates a new VRDeviceOrientationFreeCamera
  38176. * @param name defines camera name
  38177. * @param position defines the start position of the camera
  38178. * @param scene defines the scene the camera belongs to
  38179. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38180. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38181. */
  38182. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38183. /**
  38184. * Gets camera class name
  38185. * @returns VRDeviceOrientationFreeCamera
  38186. */
  38187. getClassName(): string;
  38188. }
  38189. }
  38190. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38191. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38192. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38193. import { Scene } from "babylonjs/scene";
  38194. import { Vector3 } from "babylonjs/Maths/math";
  38195. /**
  38196. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38197. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38198. */
  38199. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38200. /**
  38201. * Creates a new VRDeviceOrientationGamepadCamera
  38202. * @param name defines camera name
  38203. * @param position defines the start position of the camera
  38204. * @param scene defines the scene the camera belongs to
  38205. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38206. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38207. */
  38208. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38209. /**
  38210. * Gets camera class name
  38211. * @returns VRDeviceOrientationGamepadCamera
  38212. */
  38213. getClassName(): string;
  38214. }
  38215. }
  38216. declare module "babylonjs/Gamepads/xboxGamepad" {
  38217. import { Observable } from "babylonjs/Misc/observable";
  38218. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38219. /**
  38220. * Defines supported buttons for XBox360 compatible gamepads
  38221. */
  38222. export enum Xbox360Button {
  38223. /** A */
  38224. A = 0,
  38225. /** B */
  38226. B = 1,
  38227. /** X */
  38228. X = 2,
  38229. /** Y */
  38230. Y = 3,
  38231. /** Start */
  38232. Start = 4,
  38233. /** Back */
  38234. Back = 5,
  38235. /** Left button */
  38236. LB = 6,
  38237. /** Right button */
  38238. RB = 7,
  38239. /** Left stick */
  38240. LeftStick = 8,
  38241. /** Right stick */
  38242. RightStick = 9
  38243. }
  38244. /** Defines values for XBox360 DPad */
  38245. export enum Xbox360Dpad {
  38246. /** Up */
  38247. Up = 0,
  38248. /** Down */
  38249. Down = 1,
  38250. /** Left */
  38251. Left = 2,
  38252. /** Right */
  38253. Right = 3
  38254. }
  38255. /**
  38256. * Defines a XBox360 gamepad
  38257. */
  38258. export class Xbox360Pad extends Gamepad {
  38259. private _leftTrigger;
  38260. private _rightTrigger;
  38261. private _onlefttriggerchanged;
  38262. private _onrighttriggerchanged;
  38263. private _onbuttondown;
  38264. private _onbuttonup;
  38265. private _ondpaddown;
  38266. private _ondpadup;
  38267. /** Observable raised when a button is pressed */
  38268. onButtonDownObservable: Observable<Xbox360Button>;
  38269. /** Observable raised when a button is released */
  38270. onButtonUpObservable: Observable<Xbox360Button>;
  38271. /** Observable raised when a pad is pressed */
  38272. onPadDownObservable: Observable<Xbox360Dpad>;
  38273. /** Observable raised when a pad is released */
  38274. onPadUpObservable: Observable<Xbox360Dpad>;
  38275. private _buttonA;
  38276. private _buttonB;
  38277. private _buttonX;
  38278. private _buttonY;
  38279. private _buttonBack;
  38280. private _buttonStart;
  38281. private _buttonLB;
  38282. private _buttonRB;
  38283. private _buttonLeftStick;
  38284. private _buttonRightStick;
  38285. private _dPadUp;
  38286. private _dPadDown;
  38287. private _dPadLeft;
  38288. private _dPadRight;
  38289. private _isXboxOnePad;
  38290. /**
  38291. * Creates a new XBox360 gamepad object
  38292. * @param id defines the id of this gamepad
  38293. * @param index defines its index
  38294. * @param gamepad defines the internal HTML gamepad object
  38295. * @param xboxOne defines if it is a XBox One gamepad
  38296. */
  38297. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38298. /**
  38299. * Defines the callback to call when left trigger is pressed
  38300. * @param callback defines the callback to use
  38301. */
  38302. onlefttriggerchanged(callback: (value: number) => void): void;
  38303. /**
  38304. * Defines the callback to call when right trigger is pressed
  38305. * @param callback defines the callback to use
  38306. */
  38307. onrighttriggerchanged(callback: (value: number) => void): void;
  38308. /**
  38309. * Gets the left trigger value
  38310. */
  38311. /**
  38312. * Sets the left trigger value
  38313. */
  38314. leftTrigger: number;
  38315. /**
  38316. * Gets the right trigger value
  38317. */
  38318. /**
  38319. * Sets the right trigger value
  38320. */
  38321. rightTrigger: number;
  38322. /**
  38323. * Defines the callback to call when a button is pressed
  38324. * @param callback defines the callback to use
  38325. */
  38326. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38327. /**
  38328. * Defines the callback to call when a button is released
  38329. * @param callback defines the callback to use
  38330. */
  38331. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38332. /**
  38333. * Defines the callback to call when a pad is pressed
  38334. * @param callback defines the callback to use
  38335. */
  38336. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38337. /**
  38338. * Defines the callback to call when a pad is released
  38339. * @param callback defines the callback to use
  38340. */
  38341. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38342. private _setButtonValue;
  38343. private _setDPadValue;
  38344. /**
  38345. * Gets the value of the `A` button
  38346. */
  38347. /**
  38348. * Sets the value of the `A` button
  38349. */
  38350. buttonA: number;
  38351. /**
  38352. * Gets the value of the `B` button
  38353. */
  38354. /**
  38355. * Sets the value of the `B` button
  38356. */
  38357. buttonB: number;
  38358. /**
  38359. * Gets the value of the `X` button
  38360. */
  38361. /**
  38362. * Sets the value of the `X` button
  38363. */
  38364. buttonX: number;
  38365. /**
  38366. * Gets the value of the `Y` button
  38367. */
  38368. /**
  38369. * Sets the value of the `Y` button
  38370. */
  38371. buttonY: number;
  38372. /**
  38373. * Gets the value of the `Start` button
  38374. */
  38375. /**
  38376. * Sets the value of the `Start` button
  38377. */
  38378. buttonStart: number;
  38379. /**
  38380. * Gets the value of the `Back` button
  38381. */
  38382. /**
  38383. * Sets the value of the `Back` button
  38384. */
  38385. buttonBack: number;
  38386. /**
  38387. * Gets the value of the `Left` button
  38388. */
  38389. /**
  38390. * Sets the value of the `Left` button
  38391. */
  38392. buttonLB: number;
  38393. /**
  38394. * Gets the value of the `Right` button
  38395. */
  38396. /**
  38397. * Sets the value of the `Right` button
  38398. */
  38399. buttonRB: number;
  38400. /**
  38401. * Gets the value of the Left joystick
  38402. */
  38403. /**
  38404. * Sets the value of the Left joystick
  38405. */
  38406. buttonLeftStick: number;
  38407. /**
  38408. * Gets the value of the Right joystick
  38409. */
  38410. /**
  38411. * Sets the value of the Right joystick
  38412. */
  38413. buttonRightStick: number;
  38414. /**
  38415. * Gets the value of D-pad up
  38416. */
  38417. /**
  38418. * Sets the value of D-pad up
  38419. */
  38420. dPadUp: number;
  38421. /**
  38422. * Gets the value of D-pad down
  38423. */
  38424. /**
  38425. * Sets the value of D-pad down
  38426. */
  38427. dPadDown: number;
  38428. /**
  38429. * Gets the value of D-pad left
  38430. */
  38431. /**
  38432. * Sets the value of D-pad left
  38433. */
  38434. dPadLeft: number;
  38435. /**
  38436. * Gets the value of D-pad right
  38437. */
  38438. /**
  38439. * Sets the value of D-pad right
  38440. */
  38441. dPadRight: number;
  38442. /**
  38443. * Force the gamepad to synchronize with device values
  38444. */
  38445. update(): void;
  38446. /**
  38447. * Disposes the gamepad
  38448. */
  38449. dispose(): void;
  38450. }
  38451. }
  38452. declare module "babylonjs/Materials/pushMaterial" {
  38453. import { Nullable } from "babylonjs/types";
  38454. import { Scene } from "babylonjs/scene";
  38455. import { Matrix } from "babylonjs/Maths/math";
  38456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38457. import { Mesh } from "babylonjs/Meshes/mesh";
  38458. import { Material } from "babylonjs/Materials/material";
  38459. import { Effect } from "babylonjs/Materials/effect";
  38460. /**
  38461. * Base class of materials working in push mode in babylon JS
  38462. * @hidden
  38463. */
  38464. export class PushMaterial extends Material {
  38465. protected _activeEffect: Effect;
  38466. protected _normalMatrix: Matrix;
  38467. /**
  38468. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38469. * This means that the material can keep using a previous shader while a new one is being compiled.
  38470. * This is mostly used when shader parallel compilation is supported (true by default)
  38471. */
  38472. allowShaderHotSwapping: boolean;
  38473. constructor(name: string, scene: Scene);
  38474. getEffect(): Effect;
  38475. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38476. /**
  38477. * Binds the given world matrix to the active effect
  38478. *
  38479. * @param world the matrix to bind
  38480. */
  38481. bindOnlyWorldMatrix(world: Matrix): void;
  38482. /**
  38483. * Binds the given normal matrix to the active effect
  38484. *
  38485. * @param normalMatrix the matrix to bind
  38486. */
  38487. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38488. bind(world: Matrix, mesh?: Mesh): void;
  38489. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38490. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38491. }
  38492. }
  38493. declare module "babylonjs/Materials/materialFlags" {
  38494. /**
  38495. * This groups all the flags used to control the materials channel.
  38496. */
  38497. export class MaterialFlags {
  38498. private static _DiffuseTextureEnabled;
  38499. /**
  38500. * Are diffuse textures enabled in the application.
  38501. */
  38502. static DiffuseTextureEnabled: boolean;
  38503. private static _AmbientTextureEnabled;
  38504. /**
  38505. * Are ambient textures enabled in the application.
  38506. */
  38507. static AmbientTextureEnabled: boolean;
  38508. private static _OpacityTextureEnabled;
  38509. /**
  38510. * Are opacity textures enabled in the application.
  38511. */
  38512. static OpacityTextureEnabled: boolean;
  38513. private static _ReflectionTextureEnabled;
  38514. /**
  38515. * Are reflection textures enabled in the application.
  38516. */
  38517. static ReflectionTextureEnabled: boolean;
  38518. private static _EmissiveTextureEnabled;
  38519. /**
  38520. * Are emissive textures enabled in the application.
  38521. */
  38522. static EmissiveTextureEnabled: boolean;
  38523. private static _SpecularTextureEnabled;
  38524. /**
  38525. * Are specular textures enabled in the application.
  38526. */
  38527. static SpecularTextureEnabled: boolean;
  38528. private static _BumpTextureEnabled;
  38529. /**
  38530. * Are bump textures enabled in the application.
  38531. */
  38532. static BumpTextureEnabled: boolean;
  38533. private static _LightmapTextureEnabled;
  38534. /**
  38535. * Are lightmap textures enabled in the application.
  38536. */
  38537. static LightmapTextureEnabled: boolean;
  38538. private static _RefractionTextureEnabled;
  38539. /**
  38540. * Are refraction textures enabled in the application.
  38541. */
  38542. static RefractionTextureEnabled: boolean;
  38543. private static _ColorGradingTextureEnabled;
  38544. /**
  38545. * Are color grading textures enabled in the application.
  38546. */
  38547. static ColorGradingTextureEnabled: boolean;
  38548. private static _FresnelEnabled;
  38549. /**
  38550. * Are fresnels enabled in the application.
  38551. */
  38552. static FresnelEnabled: boolean;
  38553. private static _ClearCoatTextureEnabled;
  38554. /**
  38555. * Are clear coat textures enabled in the application.
  38556. */
  38557. static ClearCoatTextureEnabled: boolean;
  38558. private static _ClearCoatBumpTextureEnabled;
  38559. /**
  38560. * Are clear coat bump textures enabled in the application.
  38561. */
  38562. static ClearCoatBumpTextureEnabled: boolean;
  38563. private static _ClearCoatTintTextureEnabled;
  38564. /**
  38565. * Are clear coat tint textures enabled in the application.
  38566. */
  38567. static ClearCoatTintTextureEnabled: boolean;
  38568. private static _SheenTextureEnabled;
  38569. /**
  38570. * Are sheen textures enabled in the application.
  38571. */
  38572. static SheenTextureEnabled: boolean;
  38573. private static _AnisotropicTextureEnabled;
  38574. /**
  38575. * Are anisotropic textures enabled in the application.
  38576. */
  38577. static AnisotropicTextureEnabled: boolean;
  38578. }
  38579. }
  38580. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38581. /** @hidden */
  38582. export var defaultFragmentDeclaration: {
  38583. name: string;
  38584. shader: string;
  38585. };
  38586. }
  38587. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38588. /** @hidden */
  38589. export var defaultUboDeclaration: {
  38590. name: string;
  38591. shader: string;
  38592. };
  38593. }
  38594. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38595. /** @hidden */
  38596. export var lightFragmentDeclaration: {
  38597. name: string;
  38598. shader: string;
  38599. };
  38600. }
  38601. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38602. /** @hidden */
  38603. export var lightUboDeclaration: {
  38604. name: string;
  38605. shader: string;
  38606. };
  38607. }
  38608. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38609. /** @hidden */
  38610. export var lightsFragmentFunctions: {
  38611. name: string;
  38612. shader: string;
  38613. };
  38614. }
  38615. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38616. /** @hidden */
  38617. export var shadowsFragmentFunctions: {
  38618. name: string;
  38619. shader: string;
  38620. };
  38621. }
  38622. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38623. /** @hidden */
  38624. export var fresnelFunction: {
  38625. name: string;
  38626. shader: string;
  38627. };
  38628. }
  38629. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38630. /** @hidden */
  38631. export var reflectionFunction: {
  38632. name: string;
  38633. shader: string;
  38634. };
  38635. }
  38636. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38637. /** @hidden */
  38638. export var bumpFragmentFunctions: {
  38639. name: string;
  38640. shader: string;
  38641. };
  38642. }
  38643. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38644. /** @hidden */
  38645. export var logDepthDeclaration: {
  38646. name: string;
  38647. shader: string;
  38648. };
  38649. }
  38650. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38651. /** @hidden */
  38652. export var bumpFragment: {
  38653. name: string;
  38654. shader: string;
  38655. };
  38656. }
  38657. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38658. /** @hidden */
  38659. export var depthPrePass: {
  38660. name: string;
  38661. shader: string;
  38662. };
  38663. }
  38664. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38665. /** @hidden */
  38666. export var lightFragment: {
  38667. name: string;
  38668. shader: string;
  38669. };
  38670. }
  38671. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38672. /** @hidden */
  38673. export var logDepthFragment: {
  38674. name: string;
  38675. shader: string;
  38676. };
  38677. }
  38678. declare module "babylonjs/Shaders/default.fragment" {
  38679. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38680. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38681. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38682. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38683. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38684. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38685. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38686. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38687. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38688. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38689. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38690. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38691. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38692. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38693. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38694. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38695. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38696. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38697. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38698. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38699. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38700. /** @hidden */
  38701. export var defaultPixelShader: {
  38702. name: string;
  38703. shader: string;
  38704. };
  38705. }
  38706. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38707. /** @hidden */
  38708. export var defaultVertexDeclaration: {
  38709. name: string;
  38710. shader: string;
  38711. };
  38712. }
  38713. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38714. /** @hidden */
  38715. export var bumpVertexDeclaration: {
  38716. name: string;
  38717. shader: string;
  38718. };
  38719. }
  38720. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38721. /** @hidden */
  38722. export var bumpVertex: {
  38723. name: string;
  38724. shader: string;
  38725. };
  38726. }
  38727. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38728. /** @hidden */
  38729. export var fogVertex: {
  38730. name: string;
  38731. shader: string;
  38732. };
  38733. }
  38734. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38735. /** @hidden */
  38736. export var shadowsVertex: {
  38737. name: string;
  38738. shader: string;
  38739. };
  38740. }
  38741. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38742. /** @hidden */
  38743. export var pointCloudVertex: {
  38744. name: string;
  38745. shader: string;
  38746. };
  38747. }
  38748. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38749. /** @hidden */
  38750. export var logDepthVertex: {
  38751. name: string;
  38752. shader: string;
  38753. };
  38754. }
  38755. declare module "babylonjs/Shaders/default.vertex" {
  38756. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38757. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38758. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38759. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38760. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38761. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38762. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38763. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38764. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38765. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38766. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38767. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38768. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38769. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38770. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38771. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38772. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38773. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38774. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38775. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38776. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38777. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38778. /** @hidden */
  38779. export var defaultVertexShader: {
  38780. name: string;
  38781. shader: string;
  38782. };
  38783. }
  38784. declare module "babylonjs/Materials/standardMaterial" {
  38785. import { SmartArray } from "babylonjs/Misc/smartArray";
  38786. import { IAnimatable } from "babylonjs/Misc/tools";
  38787. import { Nullable } from "babylonjs/types";
  38788. import { Scene } from "babylonjs/scene";
  38789. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38790. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38792. import { Mesh } from "babylonjs/Meshes/mesh";
  38793. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38794. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38795. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38796. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38797. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38798. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38799. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38800. import "babylonjs/Shaders/default.fragment";
  38801. import "babylonjs/Shaders/default.vertex";
  38802. /** @hidden */
  38803. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38804. MAINUV1: boolean;
  38805. MAINUV2: boolean;
  38806. DIFFUSE: boolean;
  38807. DIFFUSEDIRECTUV: number;
  38808. AMBIENT: boolean;
  38809. AMBIENTDIRECTUV: number;
  38810. OPACITY: boolean;
  38811. OPACITYDIRECTUV: number;
  38812. OPACITYRGB: boolean;
  38813. REFLECTION: boolean;
  38814. EMISSIVE: boolean;
  38815. EMISSIVEDIRECTUV: number;
  38816. SPECULAR: boolean;
  38817. SPECULARDIRECTUV: number;
  38818. BUMP: boolean;
  38819. BUMPDIRECTUV: number;
  38820. PARALLAX: boolean;
  38821. PARALLAXOCCLUSION: boolean;
  38822. SPECULAROVERALPHA: boolean;
  38823. CLIPPLANE: boolean;
  38824. CLIPPLANE2: boolean;
  38825. CLIPPLANE3: boolean;
  38826. CLIPPLANE4: boolean;
  38827. ALPHATEST: boolean;
  38828. DEPTHPREPASS: boolean;
  38829. ALPHAFROMDIFFUSE: boolean;
  38830. POINTSIZE: boolean;
  38831. FOG: boolean;
  38832. SPECULARTERM: boolean;
  38833. DIFFUSEFRESNEL: boolean;
  38834. OPACITYFRESNEL: boolean;
  38835. REFLECTIONFRESNEL: boolean;
  38836. REFRACTIONFRESNEL: boolean;
  38837. EMISSIVEFRESNEL: boolean;
  38838. FRESNEL: boolean;
  38839. NORMAL: boolean;
  38840. UV1: boolean;
  38841. UV2: boolean;
  38842. VERTEXCOLOR: boolean;
  38843. VERTEXALPHA: boolean;
  38844. NUM_BONE_INFLUENCERS: number;
  38845. BonesPerMesh: number;
  38846. BONETEXTURE: boolean;
  38847. INSTANCES: boolean;
  38848. GLOSSINESS: boolean;
  38849. ROUGHNESS: boolean;
  38850. EMISSIVEASILLUMINATION: boolean;
  38851. LINKEMISSIVEWITHDIFFUSE: boolean;
  38852. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38853. LIGHTMAP: boolean;
  38854. LIGHTMAPDIRECTUV: number;
  38855. OBJECTSPACE_NORMALMAP: boolean;
  38856. USELIGHTMAPASSHADOWMAP: boolean;
  38857. REFLECTIONMAP_3D: boolean;
  38858. REFLECTIONMAP_SPHERICAL: boolean;
  38859. REFLECTIONMAP_PLANAR: boolean;
  38860. REFLECTIONMAP_CUBIC: boolean;
  38861. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38862. REFLECTIONMAP_PROJECTION: boolean;
  38863. REFLECTIONMAP_SKYBOX: boolean;
  38864. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38865. REFLECTIONMAP_EXPLICIT: boolean;
  38866. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38867. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38868. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38869. INVERTCUBICMAP: boolean;
  38870. LOGARITHMICDEPTH: boolean;
  38871. REFRACTION: boolean;
  38872. REFRACTIONMAP_3D: boolean;
  38873. REFLECTIONOVERALPHA: boolean;
  38874. TWOSIDEDLIGHTING: boolean;
  38875. SHADOWFLOAT: boolean;
  38876. MORPHTARGETS: boolean;
  38877. MORPHTARGETS_NORMAL: boolean;
  38878. MORPHTARGETS_TANGENT: boolean;
  38879. NUM_MORPH_INFLUENCERS: number;
  38880. NONUNIFORMSCALING: boolean;
  38881. PREMULTIPLYALPHA: boolean;
  38882. IMAGEPROCESSING: boolean;
  38883. VIGNETTE: boolean;
  38884. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38885. VIGNETTEBLENDMODEOPAQUE: boolean;
  38886. TONEMAPPING: boolean;
  38887. TONEMAPPING_ACES: boolean;
  38888. CONTRAST: boolean;
  38889. COLORCURVES: boolean;
  38890. COLORGRADING: boolean;
  38891. COLORGRADING3D: boolean;
  38892. SAMPLER3DGREENDEPTH: boolean;
  38893. SAMPLER3DBGRMAP: boolean;
  38894. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38895. /**
  38896. * If the reflection texture on this material is in linear color space
  38897. * @hidden
  38898. */
  38899. IS_REFLECTION_LINEAR: boolean;
  38900. /**
  38901. * If the refraction texture on this material is in linear color space
  38902. * @hidden
  38903. */
  38904. IS_REFRACTION_LINEAR: boolean;
  38905. EXPOSURE: boolean;
  38906. constructor();
  38907. setReflectionMode(modeToEnable: string): void;
  38908. }
  38909. /**
  38910. * This is the default material used in Babylon. It is the best trade off between quality
  38911. * and performances.
  38912. * @see http://doc.babylonjs.com/babylon101/materials
  38913. */
  38914. export class StandardMaterial extends PushMaterial {
  38915. private _diffuseTexture;
  38916. /**
  38917. * The basic texture of the material as viewed under a light.
  38918. */
  38919. diffuseTexture: Nullable<BaseTexture>;
  38920. private _ambientTexture;
  38921. /**
  38922. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38923. */
  38924. ambientTexture: Nullable<BaseTexture>;
  38925. private _opacityTexture;
  38926. /**
  38927. * Define the transparency of the material from a texture.
  38928. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38929. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38930. */
  38931. opacityTexture: Nullable<BaseTexture>;
  38932. private _reflectionTexture;
  38933. /**
  38934. * Define the texture used to display the reflection.
  38935. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38936. */
  38937. reflectionTexture: Nullable<BaseTexture>;
  38938. private _emissiveTexture;
  38939. /**
  38940. * Define texture of the material as if self lit.
  38941. * This will be mixed in the final result even in the absence of light.
  38942. */
  38943. emissiveTexture: Nullable<BaseTexture>;
  38944. private _specularTexture;
  38945. /**
  38946. * Define how the color and intensity of the highlight given by the light in the material.
  38947. */
  38948. specularTexture: Nullable<BaseTexture>;
  38949. private _bumpTexture;
  38950. /**
  38951. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38952. * 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.
  38953. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38954. */
  38955. bumpTexture: Nullable<BaseTexture>;
  38956. private _lightmapTexture;
  38957. /**
  38958. * Complex lighting can be computationally expensive to compute at runtime.
  38959. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38960. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38961. */
  38962. lightmapTexture: Nullable<BaseTexture>;
  38963. private _refractionTexture;
  38964. /**
  38965. * Define the texture used to display the refraction.
  38966. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38967. */
  38968. refractionTexture: Nullable<BaseTexture>;
  38969. /**
  38970. * The color of the material lit by the environmental background lighting.
  38971. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38972. */
  38973. ambientColor: Color3;
  38974. /**
  38975. * The basic color of the material as viewed under a light.
  38976. */
  38977. diffuseColor: Color3;
  38978. /**
  38979. * Define how the color and intensity of the highlight given by the light in the material.
  38980. */
  38981. specularColor: Color3;
  38982. /**
  38983. * Define the color of the material as if self lit.
  38984. * This will be mixed in the final result even in the absence of light.
  38985. */
  38986. emissiveColor: Color3;
  38987. /**
  38988. * Defines how sharp are the highlights in the material.
  38989. * The bigger the value the sharper giving a more glossy feeling to the result.
  38990. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38991. */
  38992. specularPower: number;
  38993. private _useAlphaFromDiffuseTexture;
  38994. /**
  38995. * Does the transparency come from the diffuse texture alpha channel.
  38996. */
  38997. useAlphaFromDiffuseTexture: boolean;
  38998. private _useEmissiveAsIllumination;
  38999. /**
  39000. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39001. */
  39002. useEmissiveAsIllumination: boolean;
  39003. private _linkEmissiveWithDiffuse;
  39004. /**
  39005. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39006. * the emissive level when the final color is close to one.
  39007. */
  39008. linkEmissiveWithDiffuse: boolean;
  39009. private _useSpecularOverAlpha;
  39010. /**
  39011. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39012. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39013. */
  39014. useSpecularOverAlpha: boolean;
  39015. private _useReflectionOverAlpha;
  39016. /**
  39017. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39018. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39019. */
  39020. useReflectionOverAlpha: boolean;
  39021. private _disableLighting;
  39022. /**
  39023. * Does lights from the scene impacts this material.
  39024. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39025. */
  39026. disableLighting: boolean;
  39027. private _useObjectSpaceNormalMap;
  39028. /**
  39029. * Allows using an object space normal map (instead of tangent space).
  39030. */
  39031. useObjectSpaceNormalMap: boolean;
  39032. private _useParallax;
  39033. /**
  39034. * Is parallax enabled or not.
  39035. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39036. */
  39037. useParallax: boolean;
  39038. private _useParallaxOcclusion;
  39039. /**
  39040. * Is parallax occlusion enabled or not.
  39041. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39042. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39043. */
  39044. useParallaxOcclusion: boolean;
  39045. /**
  39046. * 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.
  39047. */
  39048. parallaxScaleBias: number;
  39049. private _roughness;
  39050. /**
  39051. * Helps to define how blurry the reflections should appears in the material.
  39052. */
  39053. roughness: number;
  39054. /**
  39055. * In case of refraction, define the value of the indice of refraction.
  39056. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39057. */
  39058. indexOfRefraction: number;
  39059. /**
  39060. * Invert the refraction texture alongside the y axis.
  39061. * It can be useful with procedural textures or probe for instance.
  39062. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39063. */
  39064. invertRefractionY: boolean;
  39065. /**
  39066. * Defines the alpha limits in alpha test mode.
  39067. */
  39068. alphaCutOff: number;
  39069. private _useLightmapAsShadowmap;
  39070. /**
  39071. * In case of light mapping, define whether the map contains light or shadow informations.
  39072. */
  39073. useLightmapAsShadowmap: boolean;
  39074. private _diffuseFresnelParameters;
  39075. /**
  39076. * Define the diffuse fresnel parameters of the material.
  39077. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39078. */
  39079. diffuseFresnelParameters: FresnelParameters;
  39080. private _opacityFresnelParameters;
  39081. /**
  39082. * Define the opacity fresnel parameters of the material.
  39083. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39084. */
  39085. opacityFresnelParameters: FresnelParameters;
  39086. private _reflectionFresnelParameters;
  39087. /**
  39088. * Define the reflection fresnel parameters of the material.
  39089. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39090. */
  39091. reflectionFresnelParameters: FresnelParameters;
  39092. private _refractionFresnelParameters;
  39093. /**
  39094. * Define the refraction fresnel parameters of the material.
  39095. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39096. */
  39097. refractionFresnelParameters: FresnelParameters;
  39098. private _emissiveFresnelParameters;
  39099. /**
  39100. * Define the emissive fresnel parameters of the material.
  39101. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39102. */
  39103. emissiveFresnelParameters: FresnelParameters;
  39104. private _useReflectionFresnelFromSpecular;
  39105. /**
  39106. * If true automatically deducts the fresnels values from the material specularity.
  39107. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39108. */
  39109. useReflectionFresnelFromSpecular: boolean;
  39110. private _useGlossinessFromSpecularMapAlpha;
  39111. /**
  39112. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39113. */
  39114. useGlossinessFromSpecularMapAlpha: boolean;
  39115. private _maxSimultaneousLights;
  39116. /**
  39117. * Defines the maximum number of lights that can be used in the material
  39118. */
  39119. maxSimultaneousLights: number;
  39120. private _invertNormalMapX;
  39121. /**
  39122. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39123. */
  39124. invertNormalMapX: boolean;
  39125. private _invertNormalMapY;
  39126. /**
  39127. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39128. */
  39129. invertNormalMapY: boolean;
  39130. private _twoSidedLighting;
  39131. /**
  39132. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39133. */
  39134. twoSidedLighting: boolean;
  39135. /**
  39136. * Default configuration related to image processing available in the standard Material.
  39137. */
  39138. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39139. /**
  39140. * Gets the image processing configuration used either in this material.
  39141. */
  39142. /**
  39143. * Sets the Default image processing configuration used either in the this material.
  39144. *
  39145. * If sets to null, the scene one is in use.
  39146. */
  39147. imageProcessingConfiguration: ImageProcessingConfiguration;
  39148. /**
  39149. * Keep track of the image processing observer to allow dispose and replace.
  39150. */
  39151. private _imageProcessingObserver;
  39152. /**
  39153. * Attaches a new image processing configuration to the Standard Material.
  39154. * @param configuration
  39155. */
  39156. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39157. /**
  39158. * Gets wether the color curves effect is enabled.
  39159. */
  39160. /**
  39161. * Sets wether the color curves effect is enabled.
  39162. */
  39163. cameraColorCurvesEnabled: boolean;
  39164. /**
  39165. * Gets wether the color grading effect is enabled.
  39166. */
  39167. /**
  39168. * Gets wether the color grading effect is enabled.
  39169. */
  39170. cameraColorGradingEnabled: boolean;
  39171. /**
  39172. * Gets wether tonemapping is enabled or not.
  39173. */
  39174. /**
  39175. * Sets wether tonemapping is enabled or not
  39176. */
  39177. cameraToneMappingEnabled: boolean;
  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. /**
  39184. * The camera exposure used on this material.
  39185. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39186. * This corresponds to a photographic exposure.
  39187. */
  39188. cameraExposure: number;
  39189. /**
  39190. * Gets The camera contrast used on this material.
  39191. */
  39192. /**
  39193. * Sets The camera contrast used on this material.
  39194. */
  39195. cameraContrast: number;
  39196. /**
  39197. * Gets the Color Grading 2D Lookup Texture.
  39198. */
  39199. /**
  39200. * Sets the Color Grading 2D Lookup Texture.
  39201. */
  39202. cameraColorGradingTexture: Nullable<BaseTexture>;
  39203. /**
  39204. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39205. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39206. * 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;
  39207. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39208. */
  39209. /**
  39210. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39211. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39212. * 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;
  39213. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39214. */
  39215. cameraColorCurves: Nullable<ColorCurves>;
  39216. /**
  39217. * Custom callback helping to override the default shader used in the material.
  39218. */
  39219. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39220. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39221. protected _worldViewProjectionMatrix: Matrix;
  39222. protected _globalAmbientColor: Color3;
  39223. protected _useLogarithmicDepth: boolean;
  39224. /**
  39225. * Instantiates a new standard material.
  39226. * This is the default material used in Babylon. It is the best trade off between quality
  39227. * and performances.
  39228. * @see http://doc.babylonjs.com/babylon101/materials
  39229. * @param name Define the name of the material in the scene
  39230. * @param scene Define the scene the material belong to
  39231. */
  39232. constructor(name: string, scene: Scene);
  39233. /**
  39234. * Gets a boolean indicating that current material needs to register RTT
  39235. */
  39236. readonly hasRenderTargetTextures: boolean;
  39237. /**
  39238. * Gets the current class name of the material e.g. "StandardMaterial"
  39239. * Mainly use in serialization.
  39240. * @returns the class name
  39241. */
  39242. getClassName(): string;
  39243. /**
  39244. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39245. * You can try switching to logarithmic depth.
  39246. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39247. */
  39248. useLogarithmicDepth: boolean;
  39249. /**
  39250. * Specifies if the material will require alpha blending
  39251. * @returns a boolean specifying if alpha blending is needed
  39252. */
  39253. needAlphaBlending(): boolean;
  39254. /**
  39255. * Specifies if this material should be rendered in alpha test mode
  39256. * @returns a boolean specifying if an alpha test is needed.
  39257. */
  39258. needAlphaTesting(): boolean;
  39259. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39260. /**
  39261. * Get the texture used for alpha test purpose.
  39262. * @returns the diffuse texture in case of the standard material.
  39263. */
  39264. getAlphaTestTexture(): Nullable<BaseTexture>;
  39265. /**
  39266. * Get if the submesh is ready to be used and all its information available.
  39267. * Child classes can use it to update shaders
  39268. * @param mesh defines the mesh to check
  39269. * @param subMesh defines which submesh to check
  39270. * @param useInstances specifies that instances should be used
  39271. * @returns a boolean indicating that the submesh is ready or not
  39272. */
  39273. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39274. /**
  39275. * Builds the material UBO layouts.
  39276. * Used internally during the effect preparation.
  39277. */
  39278. buildUniformLayout(): void;
  39279. /**
  39280. * Unbinds the material from the mesh
  39281. */
  39282. unbind(): void;
  39283. /**
  39284. * Binds the submesh to this material by preparing the effect and shader to draw
  39285. * @param world defines the world transformation matrix
  39286. * @param mesh defines the mesh containing the submesh
  39287. * @param subMesh defines the submesh to bind the material to
  39288. */
  39289. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39290. /**
  39291. * Get the list of animatables in the material.
  39292. * @returns the list of animatables object used in the material
  39293. */
  39294. getAnimatables(): IAnimatable[];
  39295. /**
  39296. * Gets the active textures from the material
  39297. * @returns an array of textures
  39298. */
  39299. getActiveTextures(): BaseTexture[];
  39300. /**
  39301. * Specifies if the material uses a texture
  39302. * @param texture defines the texture to check against the material
  39303. * @returns a boolean specifying if the material uses the texture
  39304. */
  39305. hasTexture(texture: BaseTexture): boolean;
  39306. /**
  39307. * Disposes the material
  39308. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39309. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39310. */
  39311. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39312. /**
  39313. * Makes a duplicate of the material, and gives it a new name
  39314. * @param name defines the new name for the duplicated material
  39315. * @returns the cloned material
  39316. */
  39317. clone(name: string): StandardMaterial;
  39318. /**
  39319. * Serializes this material in a JSON representation
  39320. * @returns the serialized material object
  39321. */
  39322. serialize(): any;
  39323. /**
  39324. * Creates a standard material from parsed material data
  39325. * @param source defines the JSON representation of the material
  39326. * @param scene defines the hosting scene
  39327. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39328. * @returns a new standard material
  39329. */
  39330. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39331. /**
  39332. * Are diffuse textures enabled in the application.
  39333. */
  39334. static DiffuseTextureEnabled: boolean;
  39335. /**
  39336. * Are ambient textures enabled in the application.
  39337. */
  39338. static AmbientTextureEnabled: boolean;
  39339. /**
  39340. * Are opacity textures enabled in the application.
  39341. */
  39342. static OpacityTextureEnabled: boolean;
  39343. /**
  39344. * Are reflection textures enabled in the application.
  39345. */
  39346. static ReflectionTextureEnabled: boolean;
  39347. /**
  39348. * Are emissive textures enabled in the application.
  39349. */
  39350. static EmissiveTextureEnabled: boolean;
  39351. /**
  39352. * Are specular textures enabled in the application.
  39353. */
  39354. static SpecularTextureEnabled: boolean;
  39355. /**
  39356. * Are bump textures enabled in the application.
  39357. */
  39358. static BumpTextureEnabled: boolean;
  39359. /**
  39360. * Are lightmap textures enabled in the application.
  39361. */
  39362. static LightmapTextureEnabled: boolean;
  39363. /**
  39364. * Are refraction textures enabled in the application.
  39365. */
  39366. static RefractionTextureEnabled: boolean;
  39367. /**
  39368. * Are color grading textures enabled in the application.
  39369. */
  39370. static ColorGradingTextureEnabled: boolean;
  39371. /**
  39372. * Are fresnels enabled in the application.
  39373. */
  39374. static FresnelEnabled: boolean;
  39375. }
  39376. }
  39377. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39378. import { Scene } from "babylonjs/scene";
  39379. import { Texture } from "babylonjs/Materials/Textures/texture";
  39380. /**
  39381. * A class extending Texture allowing drawing on a texture
  39382. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39383. */
  39384. export class DynamicTexture extends Texture {
  39385. private _generateMipMaps;
  39386. private _canvas;
  39387. private _context;
  39388. private _engine;
  39389. /**
  39390. * Creates a DynamicTexture
  39391. * @param name defines the name of the texture
  39392. * @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
  39393. * @param scene defines the scene where you want the texture
  39394. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39395. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39396. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39397. */
  39398. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39399. /**
  39400. * Get the current class name of the texture useful for serialization or dynamic coding.
  39401. * @returns "DynamicTexture"
  39402. */
  39403. getClassName(): string;
  39404. /**
  39405. * Gets the current state of canRescale
  39406. */
  39407. readonly canRescale: boolean;
  39408. private _recreate;
  39409. /**
  39410. * Scales the texture
  39411. * @param ratio the scale factor to apply to both width and height
  39412. */
  39413. scale(ratio: number): void;
  39414. /**
  39415. * Resizes the texture
  39416. * @param width the new width
  39417. * @param height the new height
  39418. */
  39419. scaleTo(width: number, height: number): void;
  39420. /**
  39421. * Gets the context of the canvas used by the texture
  39422. * @returns the canvas context of the dynamic texture
  39423. */
  39424. getContext(): CanvasRenderingContext2D;
  39425. /**
  39426. * Clears the texture
  39427. */
  39428. clear(): void;
  39429. /**
  39430. * Updates the texture
  39431. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39432. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39433. */
  39434. update(invertY?: boolean, premulAlpha?: boolean): void;
  39435. /**
  39436. * Draws text onto the texture
  39437. * @param text defines the text to be drawn
  39438. * @param x defines the placement of the text from the left
  39439. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39440. * @param font defines the font to be used with font-style, font-size, font-name
  39441. * @param color defines the color used for the text
  39442. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39443. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39444. * @param update defines whether texture is immediately update (default is true)
  39445. */
  39446. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39447. /**
  39448. * Clones the texture
  39449. * @returns the clone of the texture.
  39450. */
  39451. clone(): DynamicTexture;
  39452. /**
  39453. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39454. * @returns a serialized dynamic texture object
  39455. */
  39456. serialize(): any;
  39457. /** @hidden */
  39458. _rebuild(): void;
  39459. }
  39460. }
  39461. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39462. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39463. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39464. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39465. /** @hidden */
  39466. export var imageProcessingPixelShader: {
  39467. name: string;
  39468. shader: string;
  39469. };
  39470. }
  39471. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39472. import { Nullable } from "babylonjs/types";
  39473. import { Color4 } from "babylonjs/Maths/math";
  39474. import { Camera } from "babylonjs/Cameras/camera";
  39475. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39476. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39477. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39479. import { Engine } from "babylonjs/Engines/engine";
  39480. import "babylonjs/Shaders/imageProcessing.fragment";
  39481. import "babylonjs/Shaders/postprocess.vertex";
  39482. /**
  39483. * ImageProcessingPostProcess
  39484. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39485. */
  39486. export class ImageProcessingPostProcess extends PostProcess {
  39487. /**
  39488. * Default configuration related to image processing available in the PBR Material.
  39489. */
  39490. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39491. /**
  39492. * Gets the image processing configuration used either in this material.
  39493. */
  39494. /**
  39495. * Sets the Default image processing configuration used either in the this material.
  39496. *
  39497. * If sets to null, the scene one is in use.
  39498. */
  39499. imageProcessingConfiguration: ImageProcessingConfiguration;
  39500. /**
  39501. * Keep track of the image processing observer to allow dispose and replace.
  39502. */
  39503. private _imageProcessingObserver;
  39504. /**
  39505. * Attaches a new image processing configuration to the PBR Material.
  39506. * @param configuration
  39507. */
  39508. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39509. /**
  39510. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39511. */
  39512. /**
  39513. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39514. */
  39515. colorCurves: Nullable<ColorCurves>;
  39516. /**
  39517. * Gets wether the color curves effect is enabled.
  39518. */
  39519. /**
  39520. * Sets wether the color curves effect is enabled.
  39521. */
  39522. colorCurvesEnabled: boolean;
  39523. /**
  39524. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39525. */
  39526. /**
  39527. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39528. */
  39529. colorGradingTexture: Nullable<BaseTexture>;
  39530. /**
  39531. * Gets wether the color grading effect is enabled.
  39532. */
  39533. /**
  39534. * Gets wether the color grading effect is enabled.
  39535. */
  39536. colorGradingEnabled: boolean;
  39537. /**
  39538. * Gets exposure used in the effect.
  39539. */
  39540. /**
  39541. * Sets exposure used in the effect.
  39542. */
  39543. exposure: number;
  39544. /**
  39545. * Gets wether tonemapping is enabled or not.
  39546. */
  39547. /**
  39548. * Sets wether tonemapping is enabled or not
  39549. */
  39550. toneMappingEnabled: boolean;
  39551. /**
  39552. * Gets the type of tone mapping effect.
  39553. */
  39554. /**
  39555. * Sets the type of tone mapping effect.
  39556. */
  39557. toneMappingType: number;
  39558. /**
  39559. * Gets contrast used in the effect.
  39560. */
  39561. /**
  39562. * Sets contrast used in the effect.
  39563. */
  39564. contrast: number;
  39565. /**
  39566. * Gets Vignette stretch size.
  39567. */
  39568. /**
  39569. * Sets Vignette stretch size.
  39570. */
  39571. vignetteStretch: number;
  39572. /**
  39573. * Gets Vignette centre X Offset.
  39574. */
  39575. /**
  39576. * Sets Vignette centre X Offset.
  39577. */
  39578. vignetteCentreX: number;
  39579. /**
  39580. * Gets Vignette centre Y Offset.
  39581. */
  39582. /**
  39583. * Sets Vignette centre Y Offset.
  39584. */
  39585. vignetteCentreY: number;
  39586. /**
  39587. * Gets Vignette weight or intensity of the vignette effect.
  39588. */
  39589. /**
  39590. * Sets Vignette weight or intensity of the vignette effect.
  39591. */
  39592. vignetteWeight: number;
  39593. /**
  39594. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39595. * if vignetteEnabled is set to true.
  39596. */
  39597. /**
  39598. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39599. * if vignetteEnabled is set to true.
  39600. */
  39601. vignetteColor: Color4;
  39602. /**
  39603. * Gets Camera field of view used by the Vignette effect.
  39604. */
  39605. /**
  39606. * Sets Camera field of view used by the Vignette effect.
  39607. */
  39608. vignetteCameraFov: number;
  39609. /**
  39610. * Gets the vignette blend mode allowing different kind of effect.
  39611. */
  39612. /**
  39613. * Sets the vignette blend mode allowing different kind of effect.
  39614. */
  39615. vignetteBlendMode: number;
  39616. /**
  39617. * Gets wether the vignette effect is enabled.
  39618. */
  39619. /**
  39620. * Sets wether the vignette effect is enabled.
  39621. */
  39622. vignetteEnabled: boolean;
  39623. private _fromLinearSpace;
  39624. /**
  39625. * Gets wether the input of the processing is in Gamma or Linear Space.
  39626. */
  39627. /**
  39628. * Sets wether the input of the processing is in Gamma or Linear Space.
  39629. */
  39630. fromLinearSpace: boolean;
  39631. /**
  39632. * Defines cache preventing GC.
  39633. */
  39634. private _defines;
  39635. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39636. /**
  39637. * "ImageProcessingPostProcess"
  39638. * @returns "ImageProcessingPostProcess"
  39639. */
  39640. getClassName(): string;
  39641. protected _updateParameters(): void;
  39642. dispose(camera?: Camera): void;
  39643. }
  39644. }
  39645. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39646. import { Scene } from "babylonjs/scene";
  39647. import { Color3 } from "babylonjs/Maths/math";
  39648. import { Mesh } from "babylonjs/Meshes/mesh";
  39649. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39650. /**
  39651. * Class containing static functions to help procedurally build meshes
  39652. */
  39653. export class GroundBuilder {
  39654. /**
  39655. * Creates a ground mesh
  39656. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39657. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39659. * @param name defines the name of the mesh
  39660. * @param options defines the options used to create the mesh
  39661. * @param scene defines the hosting scene
  39662. * @returns the ground mesh
  39663. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39664. */
  39665. static CreateGround(name: string, options: {
  39666. width?: number;
  39667. height?: number;
  39668. subdivisions?: number;
  39669. subdivisionsX?: number;
  39670. subdivisionsY?: number;
  39671. updatable?: boolean;
  39672. }, scene: any): Mesh;
  39673. /**
  39674. * Creates a tiled ground mesh
  39675. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39676. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39677. * * 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
  39678. * * 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
  39679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39680. * @param name defines the name of the mesh
  39681. * @param options defines the options used to create the mesh
  39682. * @param scene defines the hosting scene
  39683. * @returns the tiled ground mesh
  39684. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39685. */
  39686. static CreateTiledGround(name: string, options: {
  39687. xmin: number;
  39688. zmin: number;
  39689. xmax: number;
  39690. zmax: number;
  39691. subdivisions?: {
  39692. w: number;
  39693. h: number;
  39694. };
  39695. precision?: {
  39696. w: number;
  39697. h: number;
  39698. };
  39699. updatable?: boolean;
  39700. }, scene: Scene): Mesh;
  39701. /**
  39702. * Creates a ground mesh from a height map
  39703. * * The parameter `url` sets the URL of the height map image resource.
  39704. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39705. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39706. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39707. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39708. * * 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.
  39709. * * 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).
  39710. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39712. * @param name defines the name of the mesh
  39713. * @param url defines the url to the height map
  39714. * @param options defines the options used to create the mesh
  39715. * @param scene defines the hosting scene
  39716. * @returns the ground mesh
  39717. * @see https://doc.babylonjs.com/babylon101/height_map
  39718. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39719. */
  39720. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39721. width?: number;
  39722. height?: number;
  39723. subdivisions?: number;
  39724. minHeight?: number;
  39725. maxHeight?: number;
  39726. colorFilter?: Color3;
  39727. alphaFilter?: number;
  39728. updatable?: boolean;
  39729. onReady?: (mesh: GroundMesh) => void;
  39730. }, scene: Scene): GroundMesh;
  39731. }
  39732. }
  39733. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39734. import { Vector4 } from "babylonjs/Maths/math";
  39735. import { Mesh } from "babylonjs/Meshes/mesh";
  39736. /**
  39737. * Class containing static functions to help procedurally build meshes
  39738. */
  39739. export class TorusBuilder {
  39740. /**
  39741. * Creates a torus mesh
  39742. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39743. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39744. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39748. * @param name defines the name of the mesh
  39749. * @param options defines the options used to create the mesh
  39750. * @param scene defines the hosting scene
  39751. * @returns the torus mesh
  39752. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39753. */
  39754. static CreateTorus(name: string, options: {
  39755. diameter?: number;
  39756. thickness?: number;
  39757. tessellation?: number;
  39758. updatable?: boolean;
  39759. sideOrientation?: number;
  39760. frontUVs?: Vector4;
  39761. backUVs?: Vector4;
  39762. }, scene: any): Mesh;
  39763. }
  39764. }
  39765. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39766. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39767. import { Mesh } from "babylonjs/Meshes/mesh";
  39768. /**
  39769. * Class containing static functions to help procedurally build meshes
  39770. */
  39771. export class CylinderBuilder {
  39772. /**
  39773. * Creates a cylinder or a cone mesh
  39774. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39775. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39776. * * 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.
  39777. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39778. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39779. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39780. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39781. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39782. * * 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).
  39783. * * 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
  39784. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39785. * * 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
  39786. * * 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.
  39787. * * If `enclose` is false, a ring surface is one element.
  39788. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39789. * * 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
  39790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39793. * @param name defines the name of the mesh
  39794. * @param options defines the options used to create the mesh
  39795. * @param scene defines the hosting scene
  39796. * @returns the cylinder mesh
  39797. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39798. */
  39799. static CreateCylinder(name: string, options: {
  39800. height?: number;
  39801. diameterTop?: number;
  39802. diameterBottom?: number;
  39803. diameter?: number;
  39804. tessellation?: number;
  39805. subdivisions?: number;
  39806. arc?: number;
  39807. faceColors?: Color4[];
  39808. faceUV?: Vector4[];
  39809. updatable?: boolean;
  39810. hasRings?: boolean;
  39811. enclose?: boolean;
  39812. sideOrientation?: number;
  39813. frontUVs?: Vector4;
  39814. backUVs?: Vector4;
  39815. }, scene: any): Mesh;
  39816. }
  39817. }
  39818. declare module "babylonjs/Gamepads/gamepadManager" {
  39819. import { Observable } from "babylonjs/Misc/observable";
  39820. import { Nullable } from "babylonjs/types";
  39821. import { Scene } from "babylonjs/scene";
  39822. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39823. /**
  39824. * Manager for handling gamepads
  39825. */
  39826. export class GamepadManager {
  39827. private _scene?;
  39828. private _babylonGamepads;
  39829. private _oneGamepadConnected;
  39830. /** @hidden */
  39831. _isMonitoring: boolean;
  39832. private _gamepadEventSupported;
  39833. private _gamepadSupport;
  39834. /**
  39835. * observable to be triggered when the gamepad controller has been connected
  39836. */
  39837. onGamepadConnectedObservable: Observable<Gamepad>;
  39838. /**
  39839. * observable to be triggered when the gamepad controller has been disconnected
  39840. */
  39841. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39842. private _onGamepadConnectedEvent;
  39843. private _onGamepadDisconnectedEvent;
  39844. /**
  39845. * Initializes the gamepad manager
  39846. * @param _scene BabylonJS scene
  39847. */
  39848. constructor(_scene?: Scene | undefined);
  39849. /**
  39850. * The gamepads in the game pad manager
  39851. */
  39852. readonly gamepads: Gamepad[];
  39853. /**
  39854. * Get the gamepad controllers based on type
  39855. * @param type The type of gamepad controller
  39856. * @returns Nullable gamepad
  39857. */
  39858. getGamepadByType(type?: number): Nullable<Gamepad>;
  39859. /**
  39860. * Disposes the gamepad manager
  39861. */
  39862. dispose(): void;
  39863. private _addNewGamepad;
  39864. private _startMonitoringGamepads;
  39865. private _stopMonitoringGamepads;
  39866. /** @hidden */
  39867. _checkGamepadsStatus(): void;
  39868. private _updateGamepadObjects;
  39869. }
  39870. }
  39871. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39872. import { Nullable } from "babylonjs/types";
  39873. import { Scene } from "babylonjs/scene";
  39874. import { ISceneComponent } from "babylonjs/sceneComponent";
  39875. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39876. module "babylonjs/scene" {
  39877. interface Scene {
  39878. /** @hidden */
  39879. _gamepadManager: Nullable<GamepadManager>;
  39880. /**
  39881. * Gets the gamepad manager associated with the scene
  39882. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39883. */
  39884. gamepadManager: GamepadManager;
  39885. }
  39886. }
  39887. module "babylonjs/Cameras/freeCameraInputsManager" {
  39888. /**
  39889. * Interface representing a free camera inputs manager
  39890. */
  39891. interface FreeCameraInputsManager {
  39892. /**
  39893. * Adds gamepad input support to the FreeCameraInputsManager.
  39894. * @returns the FreeCameraInputsManager
  39895. */
  39896. addGamepad(): FreeCameraInputsManager;
  39897. }
  39898. }
  39899. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39900. /**
  39901. * Interface representing an arc rotate camera inputs manager
  39902. */
  39903. interface ArcRotateCameraInputsManager {
  39904. /**
  39905. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39906. * @returns the camera inputs manager
  39907. */
  39908. addGamepad(): ArcRotateCameraInputsManager;
  39909. }
  39910. }
  39911. /**
  39912. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39913. */
  39914. export class GamepadSystemSceneComponent implements ISceneComponent {
  39915. /**
  39916. * The component name helpfull to identify the component in the list of scene components.
  39917. */
  39918. readonly name: string;
  39919. /**
  39920. * The scene the component belongs to.
  39921. */
  39922. scene: Scene;
  39923. /**
  39924. * Creates a new instance of the component for the given scene
  39925. * @param scene Defines the scene to register the component in
  39926. */
  39927. constructor(scene: Scene);
  39928. /**
  39929. * Registers the component in a given scene
  39930. */
  39931. register(): void;
  39932. /**
  39933. * Rebuilds the elements related to this component in case of
  39934. * context lost for instance.
  39935. */
  39936. rebuild(): void;
  39937. /**
  39938. * Disposes the component and the associated ressources
  39939. */
  39940. dispose(): void;
  39941. private _beforeCameraUpdate;
  39942. }
  39943. }
  39944. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39945. import { Observable } from "babylonjs/Misc/observable";
  39946. import { Nullable } from "babylonjs/types";
  39947. import { Camera } from "babylonjs/Cameras/camera";
  39948. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39949. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39950. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39951. import { Scene } from "babylonjs/scene";
  39952. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39953. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39955. import { Mesh } from "babylonjs/Meshes/mesh";
  39956. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39957. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39958. import "babylonjs/Meshes/Builders/groundBuilder";
  39959. import "babylonjs/Meshes/Builders/torusBuilder";
  39960. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39961. import "babylonjs/Gamepads/gamepadSceneComponent";
  39962. import "babylonjs/Animations/animatable";
  39963. /**
  39964. * Options to modify the vr teleportation behavior.
  39965. */
  39966. export interface VRTeleportationOptions {
  39967. /**
  39968. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39969. */
  39970. floorMeshName?: string;
  39971. /**
  39972. * A list of meshes to be used as the teleportation floor. (default: empty)
  39973. */
  39974. floorMeshes?: Mesh[];
  39975. }
  39976. /**
  39977. * Options to modify the vr experience helper's behavior.
  39978. */
  39979. export interface VRExperienceHelperOptions extends WebVROptions {
  39980. /**
  39981. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39982. */
  39983. createDeviceOrientationCamera?: boolean;
  39984. /**
  39985. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39986. */
  39987. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39988. /**
  39989. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39990. */
  39991. laserToggle?: boolean;
  39992. /**
  39993. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39994. */
  39995. floorMeshes?: Mesh[];
  39996. /**
  39997. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39998. */
  39999. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40000. }
  40001. /**
  40002. * Event containing information after VR has been entered
  40003. */
  40004. export class OnAfterEnteringVRObservableEvent {
  40005. /**
  40006. * If entering vr was successful
  40007. */
  40008. success: boolean;
  40009. }
  40010. /**
  40011. * Helps to quickly add VR support to an existing scene.
  40012. * See http://doc.babylonjs.com/how_to/webvr_helper
  40013. */
  40014. export class VRExperienceHelper {
  40015. /** Options to modify the vr experience helper's behavior. */
  40016. webVROptions: VRExperienceHelperOptions;
  40017. private _scene;
  40018. private _position;
  40019. private _btnVR;
  40020. private _btnVRDisplayed;
  40021. private _webVRsupported;
  40022. private _webVRready;
  40023. private _webVRrequesting;
  40024. private _webVRpresenting;
  40025. private _hasEnteredVR;
  40026. private _fullscreenVRpresenting;
  40027. private _canvas;
  40028. private _webVRCamera;
  40029. private _vrDeviceOrientationCamera;
  40030. private _deviceOrientationCamera;
  40031. private _existingCamera;
  40032. private _onKeyDown;
  40033. private _onVrDisplayPresentChange;
  40034. private _onVRDisplayChanged;
  40035. private _onVRRequestPresentStart;
  40036. private _onVRRequestPresentComplete;
  40037. /**
  40038. * Observable raised right before entering VR.
  40039. */
  40040. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40041. /**
  40042. * Observable raised when entering VR has completed.
  40043. */
  40044. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40045. /**
  40046. * Observable raised when exiting VR.
  40047. */
  40048. onExitingVRObservable: Observable<VRExperienceHelper>;
  40049. /**
  40050. * Observable raised when controller mesh is loaded.
  40051. */
  40052. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40053. /** Return this.onEnteringVRObservable
  40054. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40055. */
  40056. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40057. /** Return this.onExitingVRObservable
  40058. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40059. */
  40060. readonly onExitingVR: Observable<VRExperienceHelper>;
  40061. /** Return this.onControllerMeshLoadedObservable
  40062. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40063. */
  40064. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40065. private _rayLength;
  40066. private _useCustomVRButton;
  40067. private _teleportationRequested;
  40068. private _teleportActive;
  40069. private _floorMeshName;
  40070. private _floorMeshesCollection;
  40071. private _rotationAllowed;
  40072. private _teleportBackwardsVector;
  40073. private _teleportationTarget;
  40074. private _isDefaultTeleportationTarget;
  40075. private _postProcessMove;
  40076. private _teleportationFillColor;
  40077. private _teleportationBorderColor;
  40078. private _rotationAngle;
  40079. private _haloCenter;
  40080. private _cameraGazer;
  40081. private _padSensibilityUp;
  40082. private _padSensibilityDown;
  40083. private _leftController;
  40084. private _rightController;
  40085. /**
  40086. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40087. */
  40088. onNewMeshSelected: Observable<AbstractMesh>;
  40089. /**
  40090. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40091. */
  40092. onNewMeshPicked: Observable<PickingInfo>;
  40093. private _circleEase;
  40094. /**
  40095. * Observable raised before camera teleportation
  40096. */
  40097. onBeforeCameraTeleport: Observable<Vector3>;
  40098. /**
  40099. * Observable raised after camera teleportation
  40100. */
  40101. onAfterCameraTeleport: Observable<Vector3>;
  40102. /**
  40103. * Observable raised when current selected mesh gets unselected
  40104. */
  40105. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40106. private _raySelectionPredicate;
  40107. /**
  40108. * To be optionaly changed by user to define custom ray selection
  40109. */
  40110. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40111. /**
  40112. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40113. */
  40114. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40115. /**
  40116. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40117. */
  40118. teleportationEnabled: boolean;
  40119. private _defaultHeight;
  40120. private _teleportationInitialized;
  40121. private _interactionsEnabled;
  40122. private _interactionsRequested;
  40123. private _displayGaze;
  40124. private _displayLaserPointer;
  40125. /**
  40126. * The mesh used to display where the user is going to teleport.
  40127. */
  40128. /**
  40129. * Sets the mesh to be used to display where the user is going to teleport.
  40130. */
  40131. teleportationTarget: Mesh;
  40132. /**
  40133. * 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
  40134. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40135. * See http://doc.babylonjs.com/resources/baking_transformations
  40136. */
  40137. gazeTrackerMesh: Mesh;
  40138. /**
  40139. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40140. */
  40141. updateGazeTrackerScale: boolean;
  40142. /**
  40143. * If the gaze trackers color should be updated when selecting meshes
  40144. */
  40145. updateGazeTrackerColor: boolean;
  40146. /**
  40147. * The gaze tracking mesh corresponding to the left controller
  40148. */
  40149. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40150. /**
  40151. * The gaze tracking mesh corresponding to the right controller
  40152. */
  40153. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40154. /**
  40155. * If the ray of the gaze should be displayed.
  40156. */
  40157. /**
  40158. * Sets if the ray of the gaze should be displayed.
  40159. */
  40160. displayGaze: boolean;
  40161. /**
  40162. * If the ray of the LaserPointer should be displayed.
  40163. */
  40164. /**
  40165. * Sets if the ray of the LaserPointer should be displayed.
  40166. */
  40167. displayLaserPointer: boolean;
  40168. /**
  40169. * The deviceOrientationCamera used as the camera when not in VR.
  40170. */
  40171. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40172. /**
  40173. * Based on the current WebVR support, returns the current VR camera used.
  40174. */
  40175. readonly currentVRCamera: Nullable<Camera>;
  40176. /**
  40177. * The webVRCamera which is used when in VR.
  40178. */
  40179. readonly webVRCamera: WebVRFreeCamera;
  40180. /**
  40181. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40182. */
  40183. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40184. private readonly _teleportationRequestInitiated;
  40185. /**
  40186. * Defines wether or not Pointer lock should be requested when switching to
  40187. * full screen.
  40188. */
  40189. requestPointerLockOnFullScreen: boolean;
  40190. /**
  40191. * Instantiates a VRExperienceHelper.
  40192. * Helps to quickly add VR support to an existing scene.
  40193. * @param scene The scene the VRExperienceHelper belongs to.
  40194. * @param webVROptions Options to modify the vr experience helper's behavior.
  40195. */
  40196. constructor(scene: Scene,
  40197. /** Options to modify the vr experience helper's behavior. */
  40198. webVROptions?: VRExperienceHelperOptions);
  40199. private _onDefaultMeshLoaded;
  40200. private _onResize;
  40201. private _onFullscreenChange;
  40202. /**
  40203. * Gets a value indicating if we are currently in VR mode.
  40204. */
  40205. readonly isInVRMode: boolean;
  40206. private onVrDisplayPresentChange;
  40207. private onVRDisplayChanged;
  40208. private moveButtonToBottomRight;
  40209. private displayVRButton;
  40210. private updateButtonVisibility;
  40211. private _cachedAngularSensibility;
  40212. /**
  40213. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40214. * Otherwise, will use the fullscreen API.
  40215. */
  40216. enterVR(): void;
  40217. /**
  40218. * Attempt to exit VR, or fullscreen.
  40219. */
  40220. exitVR(): void;
  40221. /**
  40222. * The position of the vr experience helper.
  40223. */
  40224. /**
  40225. * Sets the position of the vr experience helper.
  40226. */
  40227. position: Vector3;
  40228. /**
  40229. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40230. */
  40231. enableInteractions(): void;
  40232. private readonly _noControllerIsActive;
  40233. private beforeRender;
  40234. private _isTeleportationFloor;
  40235. /**
  40236. * Adds a floor mesh to be used for teleportation.
  40237. * @param floorMesh the mesh to be used for teleportation.
  40238. */
  40239. addFloorMesh(floorMesh: Mesh): void;
  40240. /**
  40241. * Removes a floor mesh from being used for teleportation.
  40242. * @param floorMesh the mesh to be removed.
  40243. */
  40244. removeFloorMesh(floorMesh: Mesh): void;
  40245. /**
  40246. * Enables interactions and teleportation using the VR controllers and gaze.
  40247. * @param vrTeleportationOptions options to modify teleportation behavior.
  40248. */
  40249. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40250. private _onNewGamepadConnected;
  40251. private _tryEnableInteractionOnController;
  40252. private _onNewGamepadDisconnected;
  40253. private _enableInteractionOnController;
  40254. private _checkTeleportWithRay;
  40255. private _checkRotate;
  40256. private _checkTeleportBackwards;
  40257. private _enableTeleportationOnController;
  40258. private _createTeleportationCircles;
  40259. private _displayTeleportationTarget;
  40260. private _hideTeleportationTarget;
  40261. private _rotateCamera;
  40262. private _moveTeleportationSelectorTo;
  40263. private _workingVector;
  40264. private _workingQuaternion;
  40265. private _workingMatrix;
  40266. /**
  40267. * Teleports the users feet to the desired location
  40268. * @param location The location where the user's feet should be placed
  40269. */
  40270. teleportCamera(location: Vector3): void;
  40271. private _convertNormalToDirectionOfRay;
  40272. private _castRayAndSelectObject;
  40273. private _notifySelectedMeshUnselected;
  40274. /**
  40275. * Sets the color of the laser ray from the vr controllers.
  40276. * @param color new color for the ray.
  40277. */
  40278. changeLaserColor(color: Color3): void;
  40279. /**
  40280. * Sets the color of the ray from the vr headsets gaze.
  40281. * @param color new color for the ray.
  40282. */
  40283. changeGazeColor(color: Color3): void;
  40284. /**
  40285. * Exits VR and disposes of the vr experience helper
  40286. */
  40287. dispose(): void;
  40288. /**
  40289. * Gets the name of the VRExperienceHelper class
  40290. * @returns "VRExperienceHelper"
  40291. */
  40292. getClassName(): string;
  40293. }
  40294. }
  40295. declare module "babylonjs/Cameras/VR/index" {
  40296. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40297. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40298. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40299. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40300. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40301. export * from "babylonjs/Cameras/VR/webVRCamera";
  40302. }
  40303. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40304. import { Observable } from "babylonjs/Misc/observable";
  40305. import { Nullable } from "babylonjs/types";
  40306. import { IDisposable, Scene } from "babylonjs/scene";
  40307. import { Vector3 } from "babylonjs/Maths/math";
  40308. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40309. import { Ray } from "babylonjs/Culling/ray";
  40310. /**
  40311. * Manages an XRSession
  40312. * @see https://doc.babylonjs.com/how_to/webxr
  40313. */
  40314. export class WebXRSessionManager implements IDisposable {
  40315. private scene;
  40316. /**
  40317. * Fires every time a new xrFrame arrives which can be used to update the camera
  40318. */
  40319. onXRFrameObservable: Observable<any>;
  40320. /**
  40321. * Fires when the xr session is ended either by the device or manually done
  40322. */
  40323. onXRSessionEnded: Observable<any>;
  40324. /** @hidden */
  40325. _xrSession: XRSession;
  40326. /** @hidden */
  40327. _frameOfReference: XRFrameOfReference;
  40328. /** @hidden */
  40329. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40330. /** @hidden */
  40331. _currentXRFrame: Nullable<XRFrame>;
  40332. private _xrNavigator;
  40333. private _xrDevice;
  40334. private _tmpMatrix;
  40335. /**
  40336. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40337. * @param scene The scene which the session should be created for
  40338. */
  40339. constructor(scene: Scene);
  40340. /**
  40341. * Initializes the manager
  40342. * After initialization enterXR can be called to start an XR session
  40343. * @returns Promise which resolves after it is initialized
  40344. */
  40345. initializeAsync(): Promise<void>;
  40346. /**
  40347. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40348. * @param sessionCreationOptions xr options to create the session with
  40349. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40350. * @returns Promise which resolves after it enters XR
  40351. */
  40352. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40353. /**
  40354. * Stops the xrSession and restores the renderloop
  40355. * @returns Promise which resolves after it exits XR
  40356. */
  40357. exitXRAsync(): Promise<void>;
  40358. /**
  40359. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40360. * @param ray ray to cast into the environment
  40361. * @returns Promise which resolves with a collision point in the environment if it exists
  40362. */
  40363. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40364. /**
  40365. * Checks if a session would be supported for the creation options specified
  40366. * @param options creation options to check if they are supported
  40367. * @returns true if supported
  40368. */
  40369. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40370. /**
  40371. * @hidden
  40372. * Converts the render layer of xrSession to a render target
  40373. * @param session session to create render target for
  40374. * @param scene scene the new render target should be created for
  40375. */
  40376. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40377. /**
  40378. * Disposes of the session manager
  40379. */
  40380. dispose(): void;
  40381. }
  40382. }
  40383. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40384. import { Scene } from "babylonjs/scene";
  40385. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40386. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40387. /**
  40388. * WebXR Camera which holds the views for the xrSession
  40389. * @see https://doc.babylonjs.com/how_to/webxr
  40390. */
  40391. export class WebXRCamera extends FreeCamera {
  40392. private static _TmpMatrix;
  40393. /**
  40394. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40395. * @param name the name of the camera
  40396. * @param scene the scene to add the camera to
  40397. */
  40398. constructor(name: string, scene: Scene);
  40399. private _updateNumberOfRigCameras;
  40400. /** @hidden */
  40401. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40402. /**
  40403. * Updates the cameras position from the current pose information of the XR session
  40404. * @param xrSessionManager the session containing pose information
  40405. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40406. */
  40407. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40408. }
  40409. }
  40410. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40411. import { Nullable } from "babylonjs/types";
  40412. import { Observable } from "babylonjs/Misc/observable";
  40413. import { IDisposable, Scene } from "babylonjs/scene";
  40414. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40416. import { Ray } from "babylonjs/Culling/ray";
  40417. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40418. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40419. /**
  40420. * States of the webXR experience
  40421. */
  40422. export enum WebXRState {
  40423. /**
  40424. * Transitioning to being in XR mode
  40425. */
  40426. ENTERING_XR = 0,
  40427. /**
  40428. * Transitioning to non XR mode
  40429. */
  40430. EXITING_XR = 1,
  40431. /**
  40432. * In XR mode and presenting
  40433. */
  40434. IN_XR = 2,
  40435. /**
  40436. * Not entered XR mode
  40437. */
  40438. NOT_IN_XR = 3
  40439. }
  40440. /**
  40441. * Helper class used to enable XR
  40442. * @see https://doc.babylonjs.com/how_to/webxr
  40443. */
  40444. export class WebXRExperienceHelper implements IDisposable {
  40445. private scene;
  40446. /**
  40447. * 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
  40448. */
  40449. container: AbstractMesh;
  40450. /**
  40451. * Camera used to render xr content
  40452. */
  40453. camera: WebXRCamera;
  40454. /**
  40455. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40456. */
  40457. state: WebXRState;
  40458. private _setState;
  40459. private static _TmpVector;
  40460. /**
  40461. * Fires when the state of the experience helper has changed
  40462. */
  40463. onStateChangedObservable: Observable<WebXRState>;
  40464. /** @hidden */
  40465. _sessionManager: WebXRSessionManager;
  40466. private _nonVRCamera;
  40467. private _originalSceneAutoClear;
  40468. private _supported;
  40469. /**
  40470. * Creates the experience helper
  40471. * @param scene the scene to attach the experience helper to
  40472. * @returns a promise for the experience helper
  40473. */
  40474. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40475. /**
  40476. * Creates a WebXRExperienceHelper
  40477. * @param scene The scene the helper should be created in
  40478. */
  40479. private constructor();
  40480. /**
  40481. * Exits XR mode and returns the scene to its original state
  40482. * @returns promise that resolves after xr mode has exited
  40483. */
  40484. exitXRAsync(): Promise<void>;
  40485. /**
  40486. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40487. * @param sessionCreationOptions options for the XR session
  40488. * @param frameOfReference frame of reference of the XR session
  40489. * @returns promise that resolves after xr mode has entered
  40490. */
  40491. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40492. /**
  40493. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40494. * @param ray ray to cast into the environment
  40495. * @returns Promise which resolves with a collision point in the environment if it exists
  40496. */
  40497. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40498. /**
  40499. * Updates the global position of the camera by moving the camera's container
  40500. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40501. * @param position The desired global position of the camera
  40502. */
  40503. setPositionOfCameraUsingContainer(position: Vector3): void;
  40504. /**
  40505. * Rotates the xr camera by rotating the camera's container around the camera's position
  40506. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40507. * @param rotation the desired quaternion rotation to apply to the camera
  40508. */
  40509. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40510. /**
  40511. * Checks if the creation options are supported by the xr session
  40512. * @param options creation options
  40513. * @returns true if supported
  40514. */
  40515. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40516. /**
  40517. * Disposes of the experience helper
  40518. */
  40519. dispose(): void;
  40520. }
  40521. }
  40522. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40523. import { Nullable } from "babylonjs/types";
  40524. import { Observable } from "babylonjs/Misc/observable";
  40525. import { IDisposable, Scene } from "babylonjs/scene";
  40526. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40527. /**
  40528. * Button which can be used to enter a different mode of XR
  40529. */
  40530. export class WebXREnterExitUIButton {
  40531. /** button element */
  40532. element: HTMLElement;
  40533. /** XR initialization options for the button */
  40534. initializationOptions: XRSessionCreationOptions;
  40535. /**
  40536. * Creates a WebXREnterExitUIButton
  40537. * @param element button element
  40538. * @param initializationOptions XR initialization options for the button
  40539. */
  40540. constructor(
  40541. /** button element */
  40542. element: HTMLElement,
  40543. /** XR initialization options for the button */
  40544. initializationOptions: XRSessionCreationOptions);
  40545. /**
  40546. * Overwritable function which can be used to update the button's visuals when the state changes
  40547. * @param activeButton the current active button in the UI
  40548. */
  40549. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40550. }
  40551. /**
  40552. * Options to create the webXR UI
  40553. */
  40554. export class WebXREnterExitUIOptions {
  40555. /**
  40556. * Context to enter xr with
  40557. */
  40558. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40559. /**
  40560. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40561. */
  40562. customButtons?: Array<WebXREnterExitUIButton>;
  40563. }
  40564. /**
  40565. * UI to allow the user to enter/exit XR mode
  40566. */
  40567. export class WebXREnterExitUI implements IDisposable {
  40568. private scene;
  40569. private _overlay;
  40570. private _buttons;
  40571. private _activeButton;
  40572. /**
  40573. * Fired every time the active button is changed.
  40574. *
  40575. * When xr is entered via a button that launches xr that button will be the callback parameter
  40576. *
  40577. * When exiting xr the callback parameter will be null)
  40578. */
  40579. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40580. /**
  40581. * Creates UI to allow the user to enter/exit XR mode
  40582. * @param scene the scene to add the ui to
  40583. * @param helper the xr experience helper to enter/exit xr with
  40584. * @param options options to configure the UI
  40585. * @returns the created ui
  40586. */
  40587. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40588. private constructor();
  40589. private _updateButtons;
  40590. /**
  40591. * Disposes of the object
  40592. */
  40593. dispose(): void;
  40594. }
  40595. }
  40596. declare module "babylonjs/Cameras/XR/webXRInput" {
  40597. import { IDisposable, Scene } from "babylonjs/scene";
  40598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40599. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40600. /**
  40601. * Represents an XR input
  40602. */
  40603. export class WebXRController {
  40604. /**
  40605. * 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
  40606. */
  40607. grip?: AbstractMesh;
  40608. /**
  40609. * Pointer which can be used to select objects or attach a visible laser to
  40610. */
  40611. pointer: AbstractMesh;
  40612. /**
  40613. * Creates the controller
  40614. * @see https://doc.babylonjs.com/how_to/webxr
  40615. * @param scene the scene which the controller should be associated to
  40616. */
  40617. constructor(scene: Scene);
  40618. /**
  40619. * Disposes of the object
  40620. */
  40621. dispose(): void;
  40622. }
  40623. /**
  40624. * XR input used to track XR inputs such as controllers/rays
  40625. */
  40626. export class WebXRInput implements IDisposable {
  40627. private helper;
  40628. /**
  40629. * XR controllers being tracked
  40630. */
  40631. controllers: Array<WebXRController>;
  40632. private _tmpMatrix;
  40633. private _frameObserver;
  40634. /**
  40635. * Initializes the WebXRInput
  40636. * @param helper experience helper which the input should be created for
  40637. */
  40638. constructor(helper: WebXRExperienceHelper);
  40639. /**
  40640. * Disposes of the object
  40641. */
  40642. dispose(): void;
  40643. }
  40644. }
  40645. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40646. import { Nullable } from "babylonjs/types";
  40647. import { IDisposable } from "babylonjs/scene";
  40648. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40649. /**
  40650. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40651. */
  40652. export class WebXRManagedOutputCanvas implements IDisposable {
  40653. private _canvas;
  40654. /**
  40655. * xrpresent context of the canvas which can be used to display/mirror xr content
  40656. */
  40657. canvasContext: Nullable<WebGLRenderingContext>;
  40658. /**
  40659. * Initializes the canvas to be added/removed upon entering/exiting xr
  40660. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40661. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40662. */
  40663. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40664. /**
  40665. * Disposes of the object
  40666. */
  40667. dispose(): void;
  40668. private _setManagedOutputCanvas;
  40669. private _addCanvas;
  40670. private _removeCanvas;
  40671. }
  40672. }
  40673. declare module "babylonjs/Cameras/XR/index" {
  40674. export * from "babylonjs/Cameras/XR/webXRCamera";
  40675. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40676. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40677. export * from "babylonjs/Cameras/XR/webXRInput";
  40678. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40679. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40680. }
  40681. declare module "babylonjs/Cameras/RigModes/index" {
  40682. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40683. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40684. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40685. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40686. }
  40687. declare module "babylonjs/Cameras/index" {
  40688. export * from "babylonjs/Cameras/Inputs/index";
  40689. export * from "babylonjs/Cameras/cameraInputsManager";
  40690. export * from "babylonjs/Cameras/camera";
  40691. export * from "babylonjs/Cameras/targetCamera";
  40692. export * from "babylonjs/Cameras/freeCamera";
  40693. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40694. export * from "babylonjs/Cameras/touchCamera";
  40695. export * from "babylonjs/Cameras/arcRotateCamera";
  40696. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40697. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40698. export * from "babylonjs/Cameras/flyCamera";
  40699. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40700. export * from "babylonjs/Cameras/followCamera";
  40701. export * from "babylonjs/Cameras/gamepadCamera";
  40702. export * from "babylonjs/Cameras/Stereoscopic/index";
  40703. export * from "babylonjs/Cameras/universalCamera";
  40704. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40705. export * from "babylonjs/Cameras/VR/index";
  40706. export * from "babylonjs/Cameras/XR/index";
  40707. export * from "babylonjs/Cameras/RigModes/index";
  40708. }
  40709. declare module "babylonjs/Collisions/index" {
  40710. export * from "babylonjs/Collisions/collider";
  40711. export * from "babylonjs/Collisions/collisionCoordinator";
  40712. export * from "babylonjs/Collisions/pickingInfo";
  40713. export * from "babylonjs/Collisions/intersectionInfo";
  40714. }
  40715. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40716. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40717. import { Vector3, Plane } from "babylonjs/Maths/math";
  40718. import { Ray } from "babylonjs/Culling/ray";
  40719. /**
  40720. * Contains an array of blocks representing the octree
  40721. */
  40722. export interface IOctreeContainer<T> {
  40723. /**
  40724. * Blocks within the octree
  40725. */
  40726. blocks: Array<OctreeBlock<T>>;
  40727. }
  40728. /**
  40729. * Class used to store a cell in an octree
  40730. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40731. */
  40732. export class OctreeBlock<T> {
  40733. /**
  40734. * Gets the content of the current block
  40735. */
  40736. entries: T[];
  40737. /**
  40738. * Gets the list of block children
  40739. */
  40740. blocks: Array<OctreeBlock<T>>;
  40741. private _depth;
  40742. private _maxDepth;
  40743. private _capacity;
  40744. private _minPoint;
  40745. private _maxPoint;
  40746. private _boundingVectors;
  40747. private _creationFunc;
  40748. /**
  40749. * Creates a new block
  40750. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40751. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40752. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40753. * @param depth defines the current depth of this block in the octree
  40754. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40755. * @param creationFunc defines a callback to call when an element is added to the block
  40756. */
  40757. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40758. /**
  40759. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40760. */
  40761. readonly capacity: number;
  40762. /**
  40763. * Gets the minimum vector (in world space) of the block's bounding box
  40764. */
  40765. readonly minPoint: Vector3;
  40766. /**
  40767. * Gets the maximum vector (in world space) of the block's bounding box
  40768. */
  40769. readonly maxPoint: Vector3;
  40770. /**
  40771. * Add a new element to this block
  40772. * @param entry defines the element to add
  40773. */
  40774. addEntry(entry: T): void;
  40775. /**
  40776. * Remove an element from this block
  40777. * @param entry defines the element to remove
  40778. */
  40779. removeEntry(entry: T): void;
  40780. /**
  40781. * Add an array of elements to this block
  40782. * @param entries defines the array of elements to add
  40783. */
  40784. addEntries(entries: T[]): void;
  40785. /**
  40786. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40787. * @param frustumPlanes defines the frustum planes to test
  40788. * @param selection defines the array to store current content if selection is positive
  40789. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40790. */
  40791. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40792. /**
  40793. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40794. * @param sphereCenter defines the bounding sphere center
  40795. * @param sphereRadius defines the bounding sphere radius
  40796. * @param selection defines the array to store current content if selection is positive
  40797. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40798. */
  40799. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40800. /**
  40801. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40802. * @param ray defines the ray to test with
  40803. * @param selection defines the array to store current content if selection is positive
  40804. */
  40805. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40806. /**
  40807. * Subdivide the content into child blocks (this block will then be empty)
  40808. */
  40809. createInnerBlocks(): void;
  40810. /**
  40811. * @hidden
  40812. */
  40813. 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;
  40814. }
  40815. }
  40816. declare module "babylonjs/Culling/Octrees/octree" {
  40817. import { SmartArray } from "babylonjs/Misc/smartArray";
  40818. import { Vector3, Plane } from "babylonjs/Maths/math";
  40819. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40821. import { Ray } from "babylonjs/Culling/ray";
  40822. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40823. /**
  40824. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40825. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40826. */
  40827. export class Octree<T> {
  40828. /** 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.) */
  40829. maxDepth: number;
  40830. /**
  40831. * Blocks within the octree containing objects
  40832. */
  40833. blocks: Array<OctreeBlock<T>>;
  40834. /**
  40835. * Content stored in the octree
  40836. */
  40837. dynamicContent: T[];
  40838. private _maxBlockCapacity;
  40839. private _selectionContent;
  40840. private _creationFunc;
  40841. /**
  40842. * Creates a octree
  40843. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40844. * @param creationFunc function to be used to instatiate the octree
  40845. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40846. * @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.)
  40847. */
  40848. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40849. /** 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.) */
  40850. maxDepth?: number);
  40851. /**
  40852. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40853. * @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);
  40854. * @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);
  40855. * @param entries meshes to be added to the octree blocks
  40856. */
  40857. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40858. /**
  40859. * Adds a mesh to the octree
  40860. * @param entry Mesh to add to the octree
  40861. */
  40862. addMesh(entry: T): void;
  40863. /**
  40864. * Remove an element from the octree
  40865. * @param entry defines the element to remove
  40866. */
  40867. removeMesh(entry: T): void;
  40868. /**
  40869. * Selects an array of meshes within the frustum
  40870. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40871. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40872. * @returns array of meshes within the frustum
  40873. */
  40874. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40875. /**
  40876. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40877. * @param sphereCenter defines the bounding sphere center
  40878. * @param sphereRadius defines the bounding sphere radius
  40879. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40880. * @returns an array of objects that intersect the sphere
  40881. */
  40882. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40883. /**
  40884. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40885. * @param ray defines the ray to test with
  40886. * @returns array of intersected objects
  40887. */
  40888. intersectsRay(ray: Ray): SmartArray<T>;
  40889. /**
  40890. * Adds a mesh into the octree block if it intersects the block
  40891. */
  40892. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40893. /**
  40894. * Adds a submesh into the octree block if it intersects the block
  40895. */
  40896. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40897. }
  40898. }
  40899. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40900. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40901. import { Scene } from "babylonjs/scene";
  40902. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40904. import { Ray } from "babylonjs/Culling/ray";
  40905. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40906. import { Collider } from "babylonjs/Collisions/collider";
  40907. module "babylonjs/scene" {
  40908. interface Scene {
  40909. /**
  40910. * @hidden
  40911. * Backing Filed
  40912. */
  40913. _selectionOctree: Octree<AbstractMesh>;
  40914. /**
  40915. * Gets the octree used to boost mesh selection (picking)
  40916. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40917. */
  40918. selectionOctree: Octree<AbstractMesh>;
  40919. /**
  40920. * Creates or updates the octree used to boost selection (picking)
  40921. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40922. * @param maxCapacity defines the maximum capacity per leaf
  40923. * @param maxDepth defines the maximum depth of the octree
  40924. * @returns an octree of AbstractMesh
  40925. */
  40926. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40927. }
  40928. }
  40929. module "babylonjs/Meshes/abstractMesh" {
  40930. interface AbstractMesh {
  40931. /**
  40932. * @hidden
  40933. * Backing Field
  40934. */
  40935. _submeshesOctree: Octree<SubMesh>;
  40936. /**
  40937. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40938. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40939. * @param maxCapacity defines the maximum size of each block (64 by default)
  40940. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40941. * @returns the new octree
  40942. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40943. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40944. */
  40945. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40946. }
  40947. }
  40948. /**
  40949. * Defines the octree scene component responsible to manage any octrees
  40950. * in a given scene.
  40951. */
  40952. export class OctreeSceneComponent {
  40953. /**
  40954. * The component name helpfull to identify the component in the list of scene components.
  40955. */
  40956. readonly name: string;
  40957. /**
  40958. * The scene the component belongs to.
  40959. */
  40960. scene: Scene;
  40961. /**
  40962. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40963. */
  40964. readonly checksIsEnabled: boolean;
  40965. /**
  40966. * Creates a new instance of the component for the given scene
  40967. * @param scene Defines the scene to register the component in
  40968. */
  40969. constructor(scene: Scene);
  40970. /**
  40971. * Registers the component in a given scene
  40972. */
  40973. register(): void;
  40974. /**
  40975. * Return the list of active meshes
  40976. * @returns the list of active meshes
  40977. */
  40978. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40979. /**
  40980. * Return the list of active sub meshes
  40981. * @param mesh The mesh to get the candidates sub meshes from
  40982. * @returns the list of active sub meshes
  40983. */
  40984. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40985. private _tempRay;
  40986. /**
  40987. * Return the list of sub meshes intersecting with a given local ray
  40988. * @param mesh defines the mesh to find the submesh for
  40989. * @param localRay defines the ray in local space
  40990. * @returns the list of intersecting sub meshes
  40991. */
  40992. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40993. /**
  40994. * Return the list of sub meshes colliding with a collider
  40995. * @param mesh defines the mesh to find the submesh for
  40996. * @param collider defines the collider to evaluate the collision against
  40997. * @returns the list of colliding sub meshes
  40998. */
  40999. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41000. /**
  41001. * Rebuilds the elements related to this component in case of
  41002. * context lost for instance.
  41003. */
  41004. rebuild(): void;
  41005. /**
  41006. * Disposes the component and the associated ressources.
  41007. */
  41008. dispose(): void;
  41009. }
  41010. }
  41011. declare module "babylonjs/Culling/Octrees/index" {
  41012. export * from "babylonjs/Culling/Octrees/octree";
  41013. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41014. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41015. }
  41016. declare module "babylonjs/Culling/index" {
  41017. export * from "babylonjs/Culling/boundingBox";
  41018. export * from "babylonjs/Culling/boundingInfo";
  41019. export * from "babylonjs/Culling/boundingSphere";
  41020. export * from "babylonjs/Culling/Octrees/index";
  41021. export * from "babylonjs/Culling/ray";
  41022. }
  41023. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41024. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41025. import { Nullable } from "babylonjs/types";
  41026. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41027. import { Scene } from "babylonjs/scene";
  41028. /**
  41029. * Class containing static functions to help procedurally build meshes
  41030. */
  41031. export class LinesBuilder {
  41032. /**
  41033. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41034. * * 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
  41035. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41036. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41037. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41038. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41039. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41040. * * 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
  41041. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41044. * @param name defines the name of the new line system
  41045. * @param options defines the options used to create the line system
  41046. * @param scene defines the hosting scene
  41047. * @returns a new line system mesh
  41048. */
  41049. static CreateLineSystem(name: string, options: {
  41050. lines: Vector3[][];
  41051. updatable?: boolean;
  41052. instance?: Nullable<LinesMesh>;
  41053. colors?: Nullable<Color4[][]>;
  41054. useVertexAlpha?: boolean;
  41055. }, scene: Nullable<Scene>): LinesMesh;
  41056. /**
  41057. * Creates a line mesh
  41058. * 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
  41059. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41060. * * The parameter `points` is an array successive Vector3
  41061. * * 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
  41062. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41063. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41064. * * When updating an instance, remember that only point positions can change, not the number of points
  41065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41067. * @param name defines the name of the new line system
  41068. * @param options defines the options used to create the line system
  41069. * @param scene defines the hosting scene
  41070. * @returns a new line mesh
  41071. */
  41072. static CreateLines(name: string, options: {
  41073. points: Vector3[];
  41074. updatable?: boolean;
  41075. instance?: Nullable<LinesMesh>;
  41076. colors?: Color4[];
  41077. useVertexAlpha?: boolean;
  41078. }, scene?: Nullable<Scene>): LinesMesh;
  41079. /**
  41080. * Creates a dashed line mesh
  41081. * * 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
  41082. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41083. * * The parameter `points` is an array successive Vector3
  41084. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41085. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41086. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41087. * * 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
  41088. * * When updating an instance, remember that only point positions can change, not the number of points
  41089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41090. * @param name defines the name of the mesh
  41091. * @param options defines the options used to create the mesh
  41092. * @param scene defines the hosting scene
  41093. * @returns the dashed line mesh
  41094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41095. */
  41096. static CreateDashedLines(name: string, options: {
  41097. points: Vector3[];
  41098. dashSize?: number;
  41099. gapSize?: number;
  41100. dashNb?: number;
  41101. updatable?: boolean;
  41102. instance?: LinesMesh;
  41103. }, scene?: Nullable<Scene>): LinesMesh;
  41104. }
  41105. }
  41106. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41107. import { IDisposable, Scene } from "babylonjs/scene";
  41108. import { Nullable } from "babylonjs/types";
  41109. import { Observable } from "babylonjs/Misc/observable";
  41110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41111. /**
  41112. * Renders a layer on top of an existing scene
  41113. */
  41114. export class UtilityLayerRenderer implements IDisposable {
  41115. /** the original scene that will be rendered on top of */
  41116. originalScene: Scene;
  41117. private _pointerCaptures;
  41118. private _lastPointerEvents;
  41119. private static _DefaultUtilityLayer;
  41120. private static _DefaultKeepDepthUtilityLayer;
  41121. /**
  41122. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41123. */
  41124. pickUtilitySceneFirst: boolean;
  41125. /**
  41126. * 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)
  41127. */
  41128. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41129. /**
  41130. * 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)
  41131. */
  41132. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41133. /**
  41134. * The scene that is rendered on top of the original scene
  41135. */
  41136. utilityLayerScene: Scene;
  41137. /**
  41138. * If the utility layer should automatically be rendered on top of existing scene
  41139. */
  41140. shouldRender: boolean;
  41141. /**
  41142. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41143. */
  41144. onlyCheckPointerDownEvents: boolean;
  41145. /**
  41146. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41147. */
  41148. processAllEvents: boolean;
  41149. /**
  41150. * Observable raised when the pointer move from the utility layer scene to the main scene
  41151. */
  41152. onPointerOutObservable: Observable<number>;
  41153. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41154. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41155. private _afterRenderObserver;
  41156. private _sceneDisposeObserver;
  41157. private _originalPointerObserver;
  41158. /**
  41159. * Instantiates a UtilityLayerRenderer
  41160. * @param originalScene the original scene that will be rendered on top of
  41161. * @param handleEvents boolean indicating if the utility layer should handle events
  41162. */
  41163. constructor(
  41164. /** the original scene that will be rendered on top of */
  41165. originalScene: Scene, handleEvents?: boolean);
  41166. private _notifyObservers;
  41167. /**
  41168. * Renders the utility layers scene on top of the original scene
  41169. */
  41170. render(): void;
  41171. /**
  41172. * Disposes of the renderer
  41173. */
  41174. dispose(): void;
  41175. private _updateCamera;
  41176. }
  41177. }
  41178. declare module "babylonjs/Gizmos/gizmo" {
  41179. import { Nullable } from "babylonjs/types";
  41180. import { IDisposable } from "babylonjs/scene";
  41181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41182. import { Mesh } from "babylonjs/Meshes/mesh";
  41183. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41184. /**
  41185. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41186. */
  41187. export class Gizmo implements IDisposable {
  41188. /** The utility layer the gizmo will be added to */
  41189. gizmoLayer: UtilityLayerRenderer;
  41190. /**
  41191. * The root mesh of the gizmo
  41192. */
  41193. _rootMesh: Mesh;
  41194. private _attachedMesh;
  41195. /**
  41196. * Ratio for the scale of the gizmo (Default: 1)
  41197. */
  41198. scaleRatio: number;
  41199. private _tmpMatrix;
  41200. /**
  41201. * If a custom mesh has been set (Default: false)
  41202. */
  41203. protected _customMeshSet: boolean;
  41204. /**
  41205. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41206. * * When set, interactions will be enabled
  41207. */
  41208. attachedMesh: Nullable<AbstractMesh>;
  41209. /**
  41210. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41211. * @param mesh The mesh to replace the default mesh of the gizmo
  41212. */
  41213. setCustomMesh(mesh: Mesh): void;
  41214. /**
  41215. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41216. */
  41217. updateGizmoRotationToMatchAttachedMesh: boolean;
  41218. /**
  41219. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41220. */
  41221. updateGizmoPositionToMatchAttachedMesh: boolean;
  41222. /**
  41223. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41224. */
  41225. protected _updateScale: boolean;
  41226. protected _interactionsEnabled: boolean;
  41227. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41228. private _beforeRenderObserver;
  41229. /**
  41230. * Creates a gizmo
  41231. * @param gizmoLayer The utility layer the gizmo will be added to
  41232. */
  41233. constructor(
  41234. /** The utility layer the gizmo will be added to */
  41235. gizmoLayer?: UtilityLayerRenderer);
  41236. private _tempVector;
  41237. /**
  41238. * @hidden
  41239. * Updates the gizmo to match the attached mesh's position/rotation
  41240. */
  41241. protected _update(): void;
  41242. /**
  41243. * Disposes of the gizmo
  41244. */
  41245. dispose(): void;
  41246. }
  41247. }
  41248. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41249. import { Observable } from "babylonjs/Misc/observable";
  41250. import { Nullable } from "babylonjs/types";
  41251. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41252. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41254. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41255. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41256. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41257. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41258. import { Scene } from "babylonjs/scene";
  41259. /**
  41260. * Single axis drag gizmo
  41261. */
  41262. export class AxisDragGizmo extends Gizmo {
  41263. /**
  41264. * Drag behavior responsible for the gizmos dragging interactions
  41265. */
  41266. dragBehavior: PointerDragBehavior;
  41267. private _pointerObserver;
  41268. /**
  41269. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41270. */
  41271. snapDistance: number;
  41272. /**
  41273. * Event that fires each time the gizmo snaps to a new location.
  41274. * * snapDistance is the the change in distance
  41275. */
  41276. onSnapObservable: Observable<{
  41277. snapDistance: number;
  41278. }>;
  41279. /** @hidden */
  41280. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41281. /** @hidden */
  41282. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41283. /**
  41284. * Creates an AxisDragGizmo
  41285. * @param gizmoLayer The utility layer the gizmo will be added to
  41286. * @param dragAxis The axis which the gizmo will be able to drag on
  41287. * @param color The color of the gizmo
  41288. */
  41289. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41290. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41291. /**
  41292. * Disposes of the gizmo
  41293. */
  41294. dispose(): void;
  41295. }
  41296. }
  41297. declare module "babylonjs/Debug/axesViewer" {
  41298. import { Vector3 } from "babylonjs/Maths/math";
  41299. import { Nullable } from "babylonjs/types";
  41300. import { Scene } from "babylonjs/scene";
  41301. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41302. /**
  41303. * The Axes viewer will show 3 axes in a specific point in space
  41304. */
  41305. export class AxesViewer {
  41306. private _xAxis;
  41307. private _yAxis;
  41308. private _zAxis;
  41309. private _scaleLinesFactor;
  41310. private _instanced;
  41311. /**
  41312. * Gets the hosting scene
  41313. */
  41314. scene: Scene;
  41315. /**
  41316. * Gets or sets a number used to scale line length
  41317. */
  41318. scaleLines: number;
  41319. /** Gets the node hierarchy used to render x-axis */
  41320. readonly xAxis: TransformNode;
  41321. /** Gets the node hierarchy used to render y-axis */
  41322. readonly yAxis: TransformNode;
  41323. /** Gets the node hierarchy used to render z-axis */
  41324. readonly zAxis: TransformNode;
  41325. /**
  41326. * Creates a new AxesViewer
  41327. * @param scene defines the hosting scene
  41328. * @param scaleLines defines a number used to scale line length (1 by default)
  41329. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41330. * @param xAxis defines the node hierarchy used to render the x-axis
  41331. * @param yAxis defines the node hierarchy used to render the y-axis
  41332. * @param zAxis defines the node hierarchy used to render the z-axis
  41333. */
  41334. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41335. /**
  41336. * Force the viewer to update
  41337. * @param position defines the position of the viewer
  41338. * @param xaxis defines the x axis of the viewer
  41339. * @param yaxis defines the y axis of the viewer
  41340. * @param zaxis defines the z axis of the viewer
  41341. */
  41342. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41343. /**
  41344. * Creates an instance of this axes viewer.
  41345. * @returns a new axes viewer with instanced meshes
  41346. */
  41347. createInstance(): AxesViewer;
  41348. /** Releases resources */
  41349. dispose(): void;
  41350. private static _SetRenderingGroupId;
  41351. }
  41352. }
  41353. declare module "babylonjs/Debug/boneAxesViewer" {
  41354. import { Nullable } from "babylonjs/types";
  41355. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41356. import { Vector3 } from "babylonjs/Maths/math";
  41357. import { Mesh } from "babylonjs/Meshes/mesh";
  41358. import { Bone } from "babylonjs/Bones/bone";
  41359. import { Scene } from "babylonjs/scene";
  41360. /**
  41361. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41362. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41363. */
  41364. export class BoneAxesViewer extends AxesViewer {
  41365. /**
  41366. * Gets or sets the target mesh where to display the axes viewer
  41367. */
  41368. mesh: Nullable<Mesh>;
  41369. /**
  41370. * Gets or sets the target bone where to display the axes viewer
  41371. */
  41372. bone: Nullable<Bone>;
  41373. /** Gets current position */
  41374. pos: Vector3;
  41375. /** Gets direction of X axis */
  41376. xaxis: Vector3;
  41377. /** Gets direction of Y axis */
  41378. yaxis: Vector3;
  41379. /** Gets direction of Z axis */
  41380. zaxis: Vector3;
  41381. /**
  41382. * Creates a new BoneAxesViewer
  41383. * @param scene defines the hosting scene
  41384. * @param bone defines the target bone
  41385. * @param mesh defines the target mesh
  41386. * @param scaleLines defines a scaling factor for line length (1 by default)
  41387. */
  41388. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41389. /**
  41390. * Force the viewer to update
  41391. */
  41392. update(): void;
  41393. /** Releases resources */
  41394. dispose(): void;
  41395. }
  41396. }
  41397. declare module "babylonjs/Debug/debugLayer" {
  41398. import { Observable } from "babylonjs/Misc/observable";
  41399. import { Scene } from "babylonjs/scene";
  41400. /**
  41401. * Interface used to define scene explorer extensibility option
  41402. */
  41403. export interface IExplorerExtensibilityOption {
  41404. /**
  41405. * Define the option label
  41406. */
  41407. label: string;
  41408. /**
  41409. * Defines the action to execute on click
  41410. */
  41411. action: (entity: any) => void;
  41412. }
  41413. /**
  41414. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41415. */
  41416. export interface IExplorerExtensibilityGroup {
  41417. /**
  41418. * Defines a predicate to test if a given type mut be extended
  41419. */
  41420. predicate: (entity: any) => boolean;
  41421. /**
  41422. * Gets the list of options added to a type
  41423. */
  41424. entries: IExplorerExtensibilityOption[];
  41425. }
  41426. /**
  41427. * Interface used to define the options to use to create the Inspector
  41428. */
  41429. export interface IInspectorOptions {
  41430. /**
  41431. * Display in overlay mode (default: false)
  41432. */
  41433. overlay?: boolean;
  41434. /**
  41435. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41436. */
  41437. globalRoot?: HTMLElement;
  41438. /**
  41439. * Display the Scene explorer
  41440. */
  41441. showExplorer?: boolean;
  41442. /**
  41443. * Display the property inspector
  41444. */
  41445. showInspector?: boolean;
  41446. /**
  41447. * Display in embed mode (both panes on the right)
  41448. */
  41449. embedMode?: boolean;
  41450. /**
  41451. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41452. */
  41453. handleResize?: boolean;
  41454. /**
  41455. * Allow the panes to popup (default: true)
  41456. */
  41457. enablePopup?: boolean;
  41458. /**
  41459. * Allow the panes to be closed by users (default: true)
  41460. */
  41461. enableClose?: boolean;
  41462. /**
  41463. * Optional list of extensibility entries
  41464. */
  41465. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41466. /**
  41467. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41468. */
  41469. inspectorURL?: string;
  41470. }
  41471. module "babylonjs/scene" {
  41472. interface Scene {
  41473. /**
  41474. * @hidden
  41475. * Backing field
  41476. */
  41477. _debugLayer: DebugLayer;
  41478. /**
  41479. * Gets the debug layer (aka Inspector) associated with the scene
  41480. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41481. */
  41482. debugLayer: DebugLayer;
  41483. }
  41484. }
  41485. /**
  41486. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41487. * what is happening in your scene
  41488. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41489. */
  41490. export class DebugLayer {
  41491. /**
  41492. * Define the url to get the inspector script from.
  41493. * By default it uses the babylonjs CDN.
  41494. * @ignoreNaming
  41495. */
  41496. static InspectorURL: string;
  41497. private _scene;
  41498. private BJSINSPECTOR;
  41499. /**
  41500. * Observable triggered when a property is changed through the inspector.
  41501. */
  41502. onPropertyChangedObservable: Observable<{
  41503. object: any;
  41504. property: string;
  41505. value: any;
  41506. initialValue: any;
  41507. }>;
  41508. /**
  41509. * Instantiates a new debug layer.
  41510. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41511. * what is happening in your scene
  41512. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41513. * @param scene Defines the scene to inspect
  41514. */
  41515. constructor(scene: Scene);
  41516. /** Creates the inspector window. */
  41517. private _createInspector;
  41518. /**
  41519. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41520. * @param entity defines the entity to select
  41521. * @param lineContainerTitle defines the specific block to highlight
  41522. */
  41523. select(entity: any, lineContainerTitle?: string): void;
  41524. /** Get the inspector from bundle or global */
  41525. private _getGlobalInspector;
  41526. /**
  41527. * Get if the inspector is visible or not.
  41528. * @returns true if visible otherwise, false
  41529. */
  41530. isVisible(): boolean;
  41531. /**
  41532. * Hide the inspector and close its window.
  41533. */
  41534. hide(): void;
  41535. /**
  41536. * Launch the debugLayer.
  41537. * @param config Define the configuration of the inspector
  41538. * @return a promise fulfilled when the debug layer is visible
  41539. */
  41540. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41541. }
  41542. }
  41543. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41544. import { Nullable } from "babylonjs/types";
  41545. import { Scene } from "babylonjs/scene";
  41546. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41547. import { Mesh } from "babylonjs/Meshes/mesh";
  41548. /**
  41549. * Class containing static functions to help procedurally build meshes
  41550. */
  41551. export class BoxBuilder {
  41552. /**
  41553. * Creates a box mesh
  41554. * * The parameter `size` sets the size (float) of each box side (default 1)
  41555. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41556. * * 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)
  41557. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41561. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41562. * @param name defines the name of the mesh
  41563. * @param options defines the options used to create the mesh
  41564. * @param scene defines the hosting scene
  41565. * @returns the box mesh
  41566. */
  41567. static CreateBox(name: string, options: {
  41568. size?: number;
  41569. width?: number;
  41570. height?: number;
  41571. depth?: number;
  41572. faceUV?: Vector4[];
  41573. faceColors?: Color4[];
  41574. sideOrientation?: number;
  41575. frontUVs?: Vector4;
  41576. backUVs?: Vector4;
  41577. updatable?: boolean;
  41578. }, scene?: Nullable<Scene>): Mesh;
  41579. }
  41580. }
  41581. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41582. import { Vector4 } from "babylonjs/Maths/math";
  41583. import { Mesh } from "babylonjs/Meshes/mesh";
  41584. /**
  41585. * Class containing static functions to help procedurally build meshes
  41586. */
  41587. export class SphereBuilder {
  41588. /**
  41589. * Creates a sphere mesh
  41590. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41591. * * 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`)
  41592. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41593. * * 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
  41594. * * 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)
  41595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41598. * @param name defines the name of the mesh
  41599. * @param options defines the options used to create the mesh
  41600. * @param scene defines the hosting scene
  41601. * @returns the sphere mesh
  41602. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41603. */
  41604. static CreateSphere(name: string, options: {
  41605. segments?: number;
  41606. diameter?: number;
  41607. diameterX?: number;
  41608. diameterY?: number;
  41609. diameterZ?: number;
  41610. arc?: number;
  41611. slice?: number;
  41612. sideOrientation?: number;
  41613. frontUVs?: Vector4;
  41614. backUVs?: Vector4;
  41615. updatable?: boolean;
  41616. }, scene: any): Mesh;
  41617. }
  41618. }
  41619. declare module "babylonjs/Debug/physicsViewer" {
  41620. import { Nullable } from "babylonjs/types";
  41621. import { Scene } from "babylonjs/scene";
  41622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41623. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41624. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41625. /**
  41626. * Used to show the physics impostor around the specific mesh
  41627. */
  41628. export class PhysicsViewer {
  41629. /** @hidden */
  41630. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41631. /** @hidden */
  41632. protected _meshes: Array<Nullable<AbstractMesh>>;
  41633. /** @hidden */
  41634. protected _scene: Nullable<Scene>;
  41635. /** @hidden */
  41636. protected _numMeshes: number;
  41637. /** @hidden */
  41638. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41639. private _renderFunction;
  41640. private _utilityLayer;
  41641. private _debugBoxMesh;
  41642. private _debugSphereMesh;
  41643. private _debugMaterial;
  41644. /**
  41645. * Creates a new PhysicsViewer
  41646. * @param scene defines the hosting scene
  41647. */
  41648. constructor(scene: Scene);
  41649. /** @hidden */
  41650. protected _updateDebugMeshes(): void;
  41651. /**
  41652. * Renders a specified physic impostor
  41653. * @param impostor defines the impostor to render
  41654. * @returns the new debug mesh used to render the impostor
  41655. */
  41656. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41657. /**
  41658. * Hides a specified physic impostor
  41659. * @param impostor defines the impostor to hide
  41660. */
  41661. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41662. private _getDebugMaterial;
  41663. private _getDebugBoxMesh;
  41664. private _getDebugSphereMesh;
  41665. private _getDebugMesh;
  41666. /** Releases all resources */
  41667. dispose(): void;
  41668. }
  41669. }
  41670. declare module "babylonjs/Debug/rayHelper" {
  41671. import { Nullable } from "babylonjs/types";
  41672. import { Ray } from "babylonjs/Culling/ray";
  41673. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41674. import { Scene } from "babylonjs/scene";
  41675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41676. import "babylonjs/Meshes/Builders/linesBuilder";
  41677. /**
  41678. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41679. * in order to better appreciate the issue one might have.
  41680. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41681. */
  41682. export class RayHelper {
  41683. /**
  41684. * Defines the ray we are currently tryin to visualize.
  41685. */
  41686. ray: Nullable<Ray>;
  41687. private _renderPoints;
  41688. private _renderLine;
  41689. private _renderFunction;
  41690. private _scene;
  41691. private _updateToMeshFunction;
  41692. private _attachedToMesh;
  41693. private _meshSpaceDirection;
  41694. private _meshSpaceOrigin;
  41695. /**
  41696. * Helper function to create a colored helper in a scene in one line.
  41697. * @param ray Defines the ray we are currently tryin to visualize
  41698. * @param scene Defines the scene the ray is used in
  41699. * @param color Defines the color we want to see the ray in
  41700. * @returns The newly created ray helper.
  41701. */
  41702. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41703. /**
  41704. * Instantiate a new ray helper.
  41705. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41706. * in order to better appreciate the issue one might have.
  41707. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41708. * @param ray Defines the ray we are currently tryin to visualize
  41709. */
  41710. constructor(ray: Ray);
  41711. /**
  41712. * Shows the ray we are willing to debug.
  41713. * @param scene Defines the scene the ray needs to be rendered in
  41714. * @param color Defines the color the ray needs to be rendered in
  41715. */
  41716. show(scene: Scene, color?: Color3): void;
  41717. /**
  41718. * Hides the ray we are debugging.
  41719. */
  41720. hide(): void;
  41721. private _render;
  41722. /**
  41723. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41724. * @param mesh Defines the mesh we want the helper attached to
  41725. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41726. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41727. * @param length Defines the length of the ray
  41728. */
  41729. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41730. /**
  41731. * Detach the ray helper from the mesh it has previously been attached to.
  41732. */
  41733. detachFromMesh(): void;
  41734. private _updateToMesh;
  41735. /**
  41736. * Dispose the helper and release its associated resources.
  41737. */
  41738. dispose(): void;
  41739. }
  41740. }
  41741. declare module "babylonjs/Debug/skeletonViewer" {
  41742. import { Color3 } from "babylonjs/Maths/math";
  41743. import { Scene } from "babylonjs/scene";
  41744. import { Nullable } from "babylonjs/types";
  41745. import { Skeleton } from "babylonjs/Bones/skeleton";
  41746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41747. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41748. /**
  41749. * Class used to render a debug view of a given skeleton
  41750. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41751. */
  41752. export class SkeletonViewer {
  41753. /** defines the skeleton to render */
  41754. skeleton: Skeleton;
  41755. /** defines the mesh attached to the skeleton */
  41756. mesh: AbstractMesh;
  41757. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41758. autoUpdateBonesMatrices: boolean;
  41759. /** defines the rendering group id to use with the viewer */
  41760. renderingGroupId: number;
  41761. /** Gets or sets the color used to render the skeleton */
  41762. color: Color3;
  41763. private _scene;
  41764. private _debugLines;
  41765. private _debugMesh;
  41766. private _isEnabled;
  41767. private _renderFunction;
  41768. private _utilityLayer;
  41769. /**
  41770. * Returns the mesh used to render the bones
  41771. */
  41772. readonly debugMesh: Nullable<LinesMesh>;
  41773. /**
  41774. * Creates a new SkeletonViewer
  41775. * @param skeleton defines the skeleton to render
  41776. * @param mesh defines the mesh attached to the skeleton
  41777. * @param scene defines the hosting scene
  41778. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41779. * @param renderingGroupId defines the rendering group id to use with the viewer
  41780. */
  41781. constructor(
  41782. /** defines the skeleton to render */
  41783. skeleton: Skeleton,
  41784. /** defines the mesh attached to the skeleton */
  41785. mesh: AbstractMesh, scene: Scene,
  41786. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41787. autoUpdateBonesMatrices?: boolean,
  41788. /** defines the rendering group id to use with the viewer */
  41789. renderingGroupId?: number);
  41790. /** Gets or sets a boolean indicating if the viewer is enabled */
  41791. isEnabled: boolean;
  41792. private _getBonePosition;
  41793. private _getLinesForBonesWithLength;
  41794. private _getLinesForBonesNoLength;
  41795. /** Update the viewer to sync with current skeleton state */
  41796. update(): void;
  41797. /** Release associated resources */
  41798. dispose(): void;
  41799. }
  41800. }
  41801. declare module "babylonjs/Debug/index" {
  41802. export * from "babylonjs/Debug/axesViewer";
  41803. export * from "babylonjs/Debug/boneAxesViewer";
  41804. export * from "babylonjs/Debug/debugLayer";
  41805. export * from "babylonjs/Debug/physicsViewer";
  41806. export * from "babylonjs/Debug/rayHelper";
  41807. export * from "babylonjs/Debug/skeletonViewer";
  41808. }
  41809. declare module "babylonjs/Engines/nullEngine" {
  41810. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41811. import { Scene } from "babylonjs/scene";
  41812. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41813. import { Engine } from "babylonjs/Engines/engine";
  41814. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41815. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41817. import { Effect } from "babylonjs/Materials/effect";
  41818. /**
  41819. * Options to create the null engine
  41820. */
  41821. export class NullEngineOptions {
  41822. /**
  41823. * Render width (Default: 512)
  41824. */
  41825. renderWidth: number;
  41826. /**
  41827. * Render height (Default: 256)
  41828. */
  41829. renderHeight: number;
  41830. /**
  41831. * Texture size (Default: 512)
  41832. */
  41833. textureSize: number;
  41834. /**
  41835. * If delta time between frames should be constant
  41836. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41837. */
  41838. deterministicLockstep: boolean;
  41839. /**
  41840. * Maximum about of steps between frames (Default: 4)
  41841. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41842. */
  41843. lockstepMaxSteps: number;
  41844. }
  41845. /**
  41846. * The null engine class provides support for headless version of babylon.js.
  41847. * This can be used in server side scenario or for testing purposes
  41848. */
  41849. export class NullEngine extends Engine {
  41850. private _options;
  41851. /**
  41852. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41853. */
  41854. isDeterministicLockStep(): boolean;
  41855. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41856. getLockstepMaxSteps(): number;
  41857. /**
  41858. * Sets hardware scaling, used to save performance if needed
  41859. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41860. */
  41861. getHardwareScalingLevel(): number;
  41862. constructor(options?: NullEngineOptions);
  41863. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41864. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41865. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41866. getRenderWidth(useScreen?: boolean): number;
  41867. getRenderHeight(useScreen?: boolean): number;
  41868. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41869. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41870. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41871. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41872. bindSamplers(effect: Effect): void;
  41873. enableEffect(effect: Effect): void;
  41874. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41875. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41876. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41877. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41878. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41879. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41880. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41881. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41882. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41883. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41884. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41885. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41886. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41887. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41888. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41889. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41890. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41891. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41892. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41893. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41894. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41895. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41896. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41897. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41898. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41899. bindBuffers(vertexBuffers: {
  41900. [key: string]: VertexBuffer;
  41901. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41902. wipeCaches(bruteForce?: boolean): void;
  41903. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41904. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41905. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41906. /** @hidden */
  41907. _createTexture(): WebGLTexture;
  41908. /** @hidden */
  41909. _releaseTexture(texture: InternalTexture): void;
  41910. 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;
  41911. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41912. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41913. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41914. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41915. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41916. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41917. areAllEffectsReady(): boolean;
  41918. /**
  41919. * @hidden
  41920. * Get the current error code of the webGL context
  41921. * @returns the error code
  41922. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41923. */
  41924. getError(): number;
  41925. /** @hidden */
  41926. _getUnpackAlignement(): number;
  41927. /** @hidden */
  41928. _unpackFlipY(value: boolean): void;
  41929. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41930. /**
  41931. * Updates a dynamic vertex buffer.
  41932. * @param vertexBuffer the vertex buffer to update
  41933. * @param data the data used to update the vertex buffer
  41934. * @param byteOffset the byte offset of the data (optional)
  41935. * @param byteLength the byte length of the data (optional)
  41936. */
  41937. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41938. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41939. /** @hidden */
  41940. _bindTexture(channel: number, texture: InternalTexture): void;
  41941. /** @hidden */
  41942. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41943. releaseEffects(): void;
  41944. displayLoadingUI(): void;
  41945. hideLoadingUI(): void;
  41946. /** @hidden */
  41947. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41948. /** @hidden */
  41949. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41950. /** @hidden */
  41951. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41952. /** @hidden */
  41953. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41954. }
  41955. }
  41956. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41957. import { Nullable, int } from "babylonjs/types";
  41958. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41959. /** @hidden */
  41960. export class _OcclusionDataStorage {
  41961. /** @hidden */
  41962. occlusionInternalRetryCounter: number;
  41963. /** @hidden */
  41964. isOcclusionQueryInProgress: boolean;
  41965. /** @hidden */
  41966. isOccluded: boolean;
  41967. /** @hidden */
  41968. occlusionRetryCount: number;
  41969. /** @hidden */
  41970. occlusionType: number;
  41971. /** @hidden */
  41972. occlusionQueryAlgorithmType: number;
  41973. }
  41974. module "babylonjs/Engines/engine" {
  41975. interface Engine {
  41976. /**
  41977. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41978. * @return the new query
  41979. */
  41980. createQuery(): WebGLQuery;
  41981. /**
  41982. * Delete and release a webGL query
  41983. * @param query defines the query to delete
  41984. * @return the current engine
  41985. */
  41986. deleteQuery(query: WebGLQuery): Engine;
  41987. /**
  41988. * Check if a given query has resolved and got its value
  41989. * @param query defines the query to check
  41990. * @returns true if the query got its value
  41991. */
  41992. isQueryResultAvailable(query: WebGLQuery): boolean;
  41993. /**
  41994. * Gets the value of a given query
  41995. * @param query defines the query to check
  41996. * @returns the value of the query
  41997. */
  41998. getQueryResult(query: WebGLQuery): number;
  41999. /**
  42000. * Initiates an occlusion query
  42001. * @param algorithmType defines the algorithm to use
  42002. * @param query defines the query to use
  42003. * @returns the current engine
  42004. * @see http://doc.babylonjs.com/features/occlusionquery
  42005. */
  42006. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42007. /**
  42008. * Ends an occlusion query
  42009. * @see http://doc.babylonjs.com/features/occlusionquery
  42010. * @param algorithmType defines the algorithm to use
  42011. * @returns the current engine
  42012. */
  42013. endOcclusionQuery(algorithmType: number): Engine;
  42014. /**
  42015. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42016. * Please note that only one query can be issued at a time
  42017. * @returns a time token used to track the time span
  42018. */
  42019. startTimeQuery(): Nullable<_TimeToken>;
  42020. /**
  42021. * Ends a time query
  42022. * @param token defines the token used to measure the time span
  42023. * @returns the time spent (in ns)
  42024. */
  42025. endTimeQuery(token: _TimeToken): int;
  42026. /** @hidden */
  42027. _currentNonTimestampToken: Nullable<_TimeToken>;
  42028. /** @hidden */
  42029. _createTimeQuery(): WebGLQuery;
  42030. /** @hidden */
  42031. _deleteTimeQuery(query: WebGLQuery): void;
  42032. /** @hidden */
  42033. _getGlAlgorithmType(algorithmType: number): number;
  42034. /** @hidden */
  42035. _getTimeQueryResult(query: WebGLQuery): any;
  42036. /** @hidden */
  42037. _getTimeQueryAvailability(query: WebGLQuery): any;
  42038. }
  42039. }
  42040. module "babylonjs/Meshes/abstractMesh" {
  42041. interface AbstractMesh {
  42042. /**
  42043. * Backing filed
  42044. * @hidden
  42045. */
  42046. __occlusionDataStorage: _OcclusionDataStorage;
  42047. /**
  42048. * Access property
  42049. * @hidden
  42050. */
  42051. _occlusionDataStorage: _OcclusionDataStorage;
  42052. /**
  42053. * 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.
  42054. * The default value is -1 which means don't break the query and wait till the result
  42055. * @see http://doc.babylonjs.com/features/occlusionquery
  42056. */
  42057. occlusionRetryCount: number;
  42058. /**
  42059. * 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:
  42060. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42061. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42062. * * 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.
  42063. * @see http://doc.babylonjs.com/features/occlusionquery
  42064. */
  42065. occlusionType: number;
  42066. /**
  42067. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42068. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42069. * * 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.
  42070. * @see http://doc.babylonjs.com/features/occlusionquery
  42071. */
  42072. occlusionQueryAlgorithmType: number;
  42073. /**
  42074. * 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
  42075. * @see http://doc.babylonjs.com/features/occlusionquery
  42076. */
  42077. isOccluded: boolean;
  42078. /**
  42079. * Flag to check the progress status of the query
  42080. * @see http://doc.babylonjs.com/features/occlusionquery
  42081. */
  42082. isOcclusionQueryInProgress: boolean;
  42083. }
  42084. }
  42085. }
  42086. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42087. import { Nullable } from "babylonjs/types";
  42088. /** @hidden */
  42089. export var _forceTransformFeedbackToBundle: boolean;
  42090. module "babylonjs/Engines/engine" {
  42091. interface Engine {
  42092. /**
  42093. * Creates a webGL transform feedback object
  42094. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42095. * @returns the webGL transform feedback object
  42096. */
  42097. createTransformFeedback(): WebGLTransformFeedback;
  42098. /**
  42099. * Delete a webGL transform feedback object
  42100. * @param value defines the webGL transform feedback object to delete
  42101. */
  42102. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42103. /**
  42104. * Bind a webGL transform feedback object to the webgl context
  42105. * @param value defines the webGL transform feedback object to bind
  42106. */
  42107. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42108. /**
  42109. * Begins a transform feedback operation
  42110. * @param usePoints defines if points or triangles must be used
  42111. */
  42112. beginTransformFeedback(usePoints: boolean): void;
  42113. /**
  42114. * Ends a transform feedback operation
  42115. */
  42116. endTransformFeedback(): void;
  42117. /**
  42118. * Specify the varyings to use with transform feedback
  42119. * @param program defines the associated webGL program
  42120. * @param value defines the list of strings representing the varying names
  42121. */
  42122. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42123. /**
  42124. * Bind a webGL buffer for a transform feedback operation
  42125. * @param value defines the webGL buffer to bind
  42126. */
  42127. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42128. }
  42129. }
  42130. }
  42131. declare module "babylonjs/Engines/Extensions/index" {
  42132. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42133. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42134. }
  42135. declare module "babylonjs/Engines/index" {
  42136. export * from "babylonjs/Engines/constants";
  42137. export * from "babylonjs/Engines/engine";
  42138. export * from "babylonjs/Engines/engineStore";
  42139. export * from "babylonjs/Engines/nullEngine";
  42140. export * from "babylonjs/Engines/Extensions/index";
  42141. }
  42142. declare module "babylonjs/Events/clipboardEvents" {
  42143. /**
  42144. * Gather the list of clipboard event types as constants.
  42145. */
  42146. export class ClipboardEventTypes {
  42147. /**
  42148. * The clipboard event is fired when a copy command is active (pressed).
  42149. */
  42150. static readonly COPY: number;
  42151. /**
  42152. * The clipboard event is fired when a cut command is active (pressed).
  42153. */
  42154. static readonly CUT: number;
  42155. /**
  42156. * The clipboard event is fired when a paste command is active (pressed).
  42157. */
  42158. static readonly PASTE: number;
  42159. }
  42160. /**
  42161. * This class is used to store clipboard related info for the onClipboardObservable event.
  42162. */
  42163. export class ClipboardInfo {
  42164. /**
  42165. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42166. */
  42167. type: number;
  42168. /**
  42169. * Defines the related dom event
  42170. */
  42171. event: ClipboardEvent;
  42172. /**
  42173. *Creates an instance of ClipboardInfo.
  42174. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42175. * @param event Defines the related dom event
  42176. */
  42177. constructor(
  42178. /**
  42179. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42180. */
  42181. type: number,
  42182. /**
  42183. * Defines the related dom event
  42184. */
  42185. event: ClipboardEvent);
  42186. /**
  42187. * Get the clipboard event's type from the keycode.
  42188. * @param keyCode Defines the keyCode for the current keyboard event.
  42189. * @return {number}
  42190. */
  42191. static GetTypeFromCharacter(keyCode: number): number;
  42192. }
  42193. }
  42194. declare module "babylonjs/Events/index" {
  42195. export * from "babylonjs/Events/keyboardEvents";
  42196. export * from "babylonjs/Events/pointerEvents";
  42197. export * from "babylonjs/Events/clipboardEvents";
  42198. }
  42199. declare module "babylonjs/Loading/sceneLoader" {
  42200. import { Observable } from "babylonjs/Misc/observable";
  42201. import { Nullable } from "babylonjs/types";
  42202. import { Scene } from "babylonjs/scene";
  42203. import { Engine } from "babylonjs/Engines/engine";
  42204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42205. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42206. import { AssetContainer } from "babylonjs/assetContainer";
  42207. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42208. import { Skeleton } from "babylonjs/Bones/skeleton";
  42209. /**
  42210. * Class used to represent data loading progression
  42211. */
  42212. export class SceneLoaderProgressEvent {
  42213. /** defines if data length to load can be evaluated */
  42214. readonly lengthComputable: boolean;
  42215. /** defines the loaded data length */
  42216. readonly loaded: number;
  42217. /** defines the data length to load */
  42218. readonly total: number;
  42219. /**
  42220. * Create a new progress event
  42221. * @param lengthComputable defines if data length to load can be evaluated
  42222. * @param loaded defines the loaded data length
  42223. * @param total defines the data length to load
  42224. */
  42225. constructor(
  42226. /** defines if data length to load can be evaluated */
  42227. lengthComputable: boolean,
  42228. /** defines the loaded data length */
  42229. loaded: number,
  42230. /** defines the data length to load */
  42231. total: number);
  42232. /**
  42233. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42234. * @param event defines the source event
  42235. * @returns a new SceneLoaderProgressEvent
  42236. */
  42237. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42238. }
  42239. /**
  42240. * Interface used by SceneLoader plugins to define supported file extensions
  42241. */
  42242. export interface ISceneLoaderPluginExtensions {
  42243. /**
  42244. * Defines the list of supported extensions
  42245. */
  42246. [extension: string]: {
  42247. isBinary: boolean;
  42248. };
  42249. }
  42250. /**
  42251. * Interface used by SceneLoader plugin factory
  42252. */
  42253. export interface ISceneLoaderPluginFactory {
  42254. /**
  42255. * Defines the name of the factory
  42256. */
  42257. name: string;
  42258. /**
  42259. * Function called to create a new plugin
  42260. * @return the new plugin
  42261. */
  42262. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42263. /**
  42264. * Boolean indicating if the plugin can direct load specific data
  42265. */
  42266. canDirectLoad?: (data: string) => boolean;
  42267. }
  42268. /**
  42269. * Interface used to define a SceneLoader plugin
  42270. */
  42271. export interface ISceneLoaderPlugin {
  42272. /**
  42273. * The friendly name of this plugin.
  42274. */
  42275. name: string;
  42276. /**
  42277. * The file extensions supported by this plugin.
  42278. */
  42279. extensions: string | ISceneLoaderPluginExtensions;
  42280. /**
  42281. * Import meshes into a scene.
  42282. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42283. * @param scene The scene to import into
  42284. * @param data The data to import
  42285. * @param rootUrl The root url for scene and resources
  42286. * @param meshes The meshes array to import into
  42287. * @param particleSystems The particle systems array to import into
  42288. * @param skeletons The skeletons array to import into
  42289. * @param onError The callback when import fails
  42290. * @returns True if successful or false otherwise
  42291. */
  42292. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42293. /**
  42294. * Load into a scene.
  42295. * @param scene The scene to load into
  42296. * @param data The data to import
  42297. * @param rootUrl The root url for scene and resources
  42298. * @param onError The callback when import fails
  42299. * @returns true if successful or false otherwise
  42300. */
  42301. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42302. /**
  42303. * The callback that returns true if the data can be directly loaded.
  42304. */
  42305. canDirectLoad?: (data: string) => boolean;
  42306. /**
  42307. * The callback that allows custom handling of the root url based on the response url.
  42308. */
  42309. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42310. /**
  42311. * Load into an asset container.
  42312. * @param scene The scene to load into
  42313. * @param data The data to import
  42314. * @param rootUrl The root url for scene and resources
  42315. * @param onError The callback when import fails
  42316. * @returns The loaded asset container
  42317. */
  42318. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42319. }
  42320. /**
  42321. * Interface used to define an async SceneLoader plugin
  42322. */
  42323. export interface ISceneLoaderPluginAsync {
  42324. /**
  42325. * The friendly name of this plugin.
  42326. */
  42327. name: string;
  42328. /**
  42329. * The file extensions supported by this plugin.
  42330. */
  42331. extensions: string | ISceneLoaderPluginExtensions;
  42332. /**
  42333. * Import meshes into a scene.
  42334. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42335. * @param scene The scene to import into
  42336. * @param data The data to import
  42337. * @param rootUrl The root url for scene and resources
  42338. * @param onProgress The callback when the load progresses
  42339. * @param fileName Defines the name of the file to load
  42340. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42341. */
  42342. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42343. meshes: AbstractMesh[];
  42344. particleSystems: IParticleSystem[];
  42345. skeletons: Skeleton[];
  42346. animationGroups: AnimationGroup[];
  42347. }>;
  42348. /**
  42349. * Load into a scene.
  42350. * @param scene The scene to load into
  42351. * @param data The data to import
  42352. * @param rootUrl The root url for scene and resources
  42353. * @param onProgress The callback when the load progresses
  42354. * @param fileName Defines the name of the file to load
  42355. * @returns Nothing
  42356. */
  42357. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42358. /**
  42359. * The callback that returns true if the data can be directly loaded.
  42360. */
  42361. canDirectLoad?: (data: string) => boolean;
  42362. /**
  42363. * The callback that allows custom handling of the root url based on the response url.
  42364. */
  42365. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42366. /**
  42367. * Load into an asset container.
  42368. * @param scene The scene to load into
  42369. * @param data The data to import
  42370. * @param rootUrl The root url for scene and resources
  42371. * @param onProgress The callback when the load progresses
  42372. * @param fileName Defines the name of the file to load
  42373. * @returns The loaded asset container
  42374. */
  42375. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42376. }
  42377. /**
  42378. * Class used to load scene from various file formats using registered plugins
  42379. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42380. */
  42381. export class SceneLoader {
  42382. /**
  42383. * No logging while loading
  42384. */
  42385. static readonly NO_LOGGING: number;
  42386. /**
  42387. * Minimal logging while loading
  42388. */
  42389. static readonly MINIMAL_LOGGING: number;
  42390. /**
  42391. * Summary logging while loading
  42392. */
  42393. static readonly SUMMARY_LOGGING: number;
  42394. /**
  42395. * Detailled logging while loading
  42396. */
  42397. static readonly DETAILED_LOGGING: number;
  42398. /**
  42399. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42400. */
  42401. static ForceFullSceneLoadingForIncremental: boolean;
  42402. /**
  42403. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42404. */
  42405. static ShowLoadingScreen: boolean;
  42406. /**
  42407. * Defines the current logging level (while loading the scene)
  42408. * @ignorenaming
  42409. */
  42410. static loggingLevel: number;
  42411. /**
  42412. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42413. */
  42414. static CleanBoneMatrixWeights: boolean;
  42415. /**
  42416. * Event raised when a plugin is used to load a scene
  42417. */
  42418. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42419. private static _registeredPlugins;
  42420. private static _getDefaultPlugin;
  42421. private static _getPluginForExtension;
  42422. private static _getPluginForDirectLoad;
  42423. private static _getPluginForFilename;
  42424. private static _getDirectLoad;
  42425. private static _loadData;
  42426. private static _getFileInfo;
  42427. /**
  42428. * Gets a plugin that can load the given extension
  42429. * @param extension defines the extension to load
  42430. * @returns a plugin or null if none works
  42431. */
  42432. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42433. /**
  42434. * Gets a boolean indicating that the given extension can be loaded
  42435. * @param extension defines the extension to load
  42436. * @returns true if the extension is supported
  42437. */
  42438. static IsPluginForExtensionAvailable(extension: string): boolean;
  42439. /**
  42440. * Adds a new plugin to the list of registered plugins
  42441. * @param plugin defines the plugin to add
  42442. */
  42443. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42444. /**
  42445. * Import meshes into a scene
  42446. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42447. * @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)
  42448. * @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)
  42449. * @param scene the instance of BABYLON.Scene to append to
  42450. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42451. * @param onProgress a callback with a progress event for each file being loaded
  42452. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42453. * @param pluginExtension the extension used to determine the plugin
  42454. * @returns The loaded plugin
  42455. */
  42456. 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>;
  42457. /**
  42458. * Import meshes into a scene
  42459. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42460. * @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)
  42461. * @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)
  42462. * @param scene the instance of BABYLON.Scene to append to
  42463. * @param onProgress a callback with a progress event for each file being loaded
  42464. * @param pluginExtension the extension used to determine the plugin
  42465. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42466. */
  42467. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42468. meshes: AbstractMesh[];
  42469. particleSystems: IParticleSystem[];
  42470. skeletons: Skeleton[];
  42471. animationGroups: AnimationGroup[];
  42472. }>;
  42473. /**
  42474. * Load a scene
  42475. * @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)
  42476. * @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)
  42477. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42478. * @param onSuccess a callback with the scene when import succeeds
  42479. * @param onProgress a callback with a progress event for each file being loaded
  42480. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42481. * @param pluginExtension the extension used to determine the plugin
  42482. * @returns The loaded plugin
  42483. */
  42484. 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>;
  42485. /**
  42486. * Load a scene
  42487. * @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)
  42488. * @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)
  42489. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42490. * @param onProgress a callback with a progress event for each file being loaded
  42491. * @param pluginExtension the extension used to determine the plugin
  42492. * @returns The loaded scene
  42493. */
  42494. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42495. /**
  42496. * Append a scene
  42497. * @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)
  42498. * @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)
  42499. * @param scene is the instance of BABYLON.Scene to append to
  42500. * @param onSuccess a callback with the scene when import succeeds
  42501. * @param onProgress a callback with a progress event for each file being loaded
  42502. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42503. * @param pluginExtension the extension used to determine the plugin
  42504. * @returns The loaded plugin
  42505. */
  42506. 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>;
  42507. /**
  42508. * Append a scene
  42509. * @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)
  42510. * @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)
  42511. * @param scene is the instance of BABYLON.Scene to append to
  42512. * @param onProgress a callback with a progress event for each file being loaded
  42513. * @param pluginExtension the extension used to determine the plugin
  42514. * @returns The given scene
  42515. */
  42516. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42517. /**
  42518. * Load a scene into an asset container
  42519. * @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)
  42520. * @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)
  42521. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42522. * @param onSuccess a callback with the scene when import succeeds
  42523. * @param onProgress a callback with a progress event for each file being loaded
  42524. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42525. * @param pluginExtension the extension used to determine the plugin
  42526. * @returns The loaded plugin
  42527. */
  42528. 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>;
  42529. /**
  42530. * Load a scene into an asset container
  42531. * @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)
  42532. * @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)
  42533. * @param scene is the instance of Scene to append to
  42534. * @param onProgress a callback with a progress event for each file being loaded
  42535. * @param pluginExtension the extension used to determine the plugin
  42536. * @returns The loaded asset container
  42537. */
  42538. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42539. }
  42540. }
  42541. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42542. import { Scene } from "babylonjs/scene";
  42543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42544. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42545. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42546. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42547. /**
  42548. * Google Daydream controller
  42549. */
  42550. export class DaydreamController extends WebVRController {
  42551. /**
  42552. * Base Url for the controller model.
  42553. */
  42554. static MODEL_BASE_URL: string;
  42555. /**
  42556. * File name for the controller model.
  42557. */
  42558. static MODEL_FILENAME: string;
  42559. /**
  42560. * Gamepad Id prefix used to identify Daydream Controller.
  42561. */
  42562. static readonly GAMEPAD_ID_PREFIX: string;
  42563. /**
  42564. * Creates a new DaydreamController from a gamepad
  42565. * @param vrGamepad the gamepad that the controller should be created from
  42566. */
  42567. constructor(vrGamepad: any);
  42568. /**
  42569. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42570. * @param scene scene in which to add meshes
  42571. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42572. */
  42573. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42574. /**
  42575. * Called once for each button that changed state since the last frame
  42576. * @param buttonIdx Which button index changed
  42577. * @param state New state of the button
  42578. * @param changes Which properties on the state changed since last frame
  42579. */
  42580. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42581. }
  42582. }
  42583. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42584. import { Scene } from "babylonjs/scene";
  42585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42586. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42587. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42588. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42589. /**
  42590. * Gear VR Controller
  42591. */
  42592. export class GearVRController extends WebVRController {
  42593. /**
  42594. * Base Url for the controller model.
  42595. */
  42596. static MODEL_BASE_URL: string;
  42597. /**
  42598. * File name for the controller model.
  42599. */
  42600. static MODEL_FILENAME: string;
  42601. /**
  42602. * Gamepad Id prefix used to identify this controller.
  42603. */
  42604. static readonly GAMEPAD_ID_PREFIX: string;
  42605. private readonly _buttonIndexToObservableNameMap;
  42606. /**
  42607. * Creates a new GearVRController from a gamepad
  42608. * @param vrGamepad the gamepad that the controller should be created from
  42609. */
  42610. constructor(vrGamepad: any);
  42611. /**
  42612. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42613. * @param scene scene in which to add meshes
  42614. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42615. */
  42616. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42617. /**
  42618. * Called once for each button that changed state since the last frame
  42619. * @param buttonIdx Which button index changed
  42620. * @param state New state of the button
  42621. * @param changes Which properties on the state changed since last frame
  42622. */
  42623. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42624. }
  42625. }
  42626. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42627. import { Scene } from "babylonjs/scene";
  42628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42629. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42630. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42631. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42632. /**
  42633. * Generic Controller
  42634. */
  42635. export class GenericController extends WebVRController {
  42636. /**
  42637. * Base Url for the controller model.
  42638. */
  42639. static readonly MODEL_BASE_URL: string;
  42640. /**
  42641. * File name for the controller model.
  42642. */
  42643. static readonly MODEL_FILENAME: string;
  42644. /**
  42645. * Creates a new GenericController from a gamepad
  42646. * @param vrGamepad the gamepad that the controller should be created from
  42647. */
  42648. constructor(vrGamepad: any);
  42649. /**
  42650. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42651. * @param scene scene in which to add meshes
  42652. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42653. */
  42654. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42655. /**
  42656. * Called once for each button that changed state since the last frame
  42657. * @param buttonIdx Which button index changed
  42658. * @param state New state of the button
  42659. * @param changes Which properties on the state changed since last frame
  42660. */
  42661. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42662. }
  42663. }
  42664. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42665. import { Observable } from "babylonjs/Misc/observable";
  42666. import { Scene } from "babylonjs/scene";
  42667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42668. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42669. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42670. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42671. /**
  42672. * Oculus Touch Controller
  42673. */
  42674. export class OculusTouchController extends WebVRController {
  42675. /**
  42676. * Base Url for the controller model.
  42677. */
  42678. static MODEL_BASE_URL: string;
  42679. /**
  42680. * File name for the left controller model.
  42681. */
  42682. static MODEL_LEFT_FILENAME: string;
  42683. /**
  42684. * File name for the right controller model.
  42685. */
  42686. static MODEL_RIGHT_FILENAME: string;
  42687. /**
  42688. * Fired when the secondary trigger on this controller is modified
  42689. */
  42690. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42691. /**
  42692. * Fired when the thumb rest on this controller is modified
  42693. */
  42694. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42695. /**
  42696. * Creates a new OculusTouchController from a gamepad
  42697. * @param vrGamepad the gamepad that the controller should be created from
  42698. */
  42699. constructor(vrGamepad: any);
  42700. /**
  42701. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42702. * @param scene scene in which to add meshes
  42703. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42704. */
  42705. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42706. /**
  42707. * Fired when the A button on this controller is modified
  42708. */
  42709. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42710. /**
  42711. * Fired when the B button on this controller is modified
  42712. */
  42713. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42714. /**
  42715. * Fired when the X button on this controller is modified
  42716. */
  42717. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42718. /**
  42719. * Fired when the Y button on this controller is modified
  42720. */
  42721. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42722. /**
  42723. * Called once for each button that changed state since the last frame
  42724. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42725. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42726. * 2) secondary trigger (same)
  42727. * 3) A (right) X (left), touch, pressed = value
  42728. * 4) B / Y
  42729. * 5) thumb rest
  42730. * @param buttonIdx Which button index changed
  42731. * @param state New state of the button
  42732. * @param changes Which properties on the state changed since last frame
  42733. */
  42734. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42735. }
  42736. }
  42737. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42738. import { Scene } from "babylonjs/scene";
  42739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42740. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42741. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42742. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42743. import { Observable } from "babylonjs/Misc/observable";
  42744. /**
  42745. * Vive Controller
  42746. */
  42747. export class ViveController extends WebVRController {
  42748. /**
  42749. * Base Url for the controller model.
  42750. */
  42751. static MODEL_BASE_URL: string;
  42752. /**
  42753. * File name for the controller model.
  42754. */
  42755. static MODEL_FILENAME: string;
  42756. /**
  42757. * Creates a new ViveController from a gamepad
  42758. * @param vrGamepad the gamepad that the controller should be created from
  42759. */
  42760. constructor(vrGamepad: any);
  42761. /**
  42762. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42763. * @param scene scene in which to add meshes
  42764. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42765. */
  42766. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42767. /**
  42768. * Fired when the left button on this controller is modified
  42769. */
  42770. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42771. /**
  42772. * Fired when the right button on this controller is modified
  42773. */
  42774. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42775. /**
  42776. * Fired when the menu button on this controller is modified
  42777. */
  42778. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42779. /**
  42780. * Called once for each button that changed state since the last frame
  42781. * Vive mapping:
  42782. * 0: touchpad
  42783. * 1: trigger
  42784. * 2: left AND right buttons
  42785. * 3: menu button
  42786. * @param buttonIdx Which button index changed
  42787. * @param state New state of the button
  42788. * @param changes Which properties on the state changed since last frame
  42789. */
  42790. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42791. }
  42792. }
  42793. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42794. import { Observable } from "babylonjs/Misc/observable";
  42795. import { Scene } from "babylonjs/scene";
  42796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42797. import { Ray } from "babylonjs/Culling/ray";
  42798. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42799. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42800. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42801. /**
  42802. * Defines the WindowsMotionController object that the state of the windows motion controller
  42803. */
  42804. export class WindowsMotionController extends WebVRController {
  42805. /**
  42806. * The base url used to load the left and right controller models
  42807. */
  42808. static MODEL_BASE_URL: string;
  42809. /**
  42810. * The name of the left controller model file
  42811. */
  42812. static MODEL_LEFT_FILENAME: string;
  42813. /**
  42814. * The name of the right controller model file
  42815. */
  42816. static MODEL_RIGHT_FILENAME: string;
  42817. /**
  42818. * The controller name prefix for this controller type
  42819. */
  42820. static readonly GAMEPAD_ID_PREFIX: string;
  42821. /**
  42822. * The controller id pattern for this controller type
  42823. */
  42824. private static readonly GAMEPAD_ID_PATTERN;
  42825. private _loadedMeshInfo;
  42826. private readonly _mapping;
  42827. /**
  42828. * Fired when the trackpad on this controller is clicked
  42829. */
  42830. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42831. /**
  42832. * Fired when the trackpad on this controller is modified
  42833. */
  42834. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42835. /**
  42836. * The current x and y values of this controller's trackpad
  42837. */
  42838. trackpad: StickValues;
  42839. /**
  42840. * Creates a new WindowsMotionController from a gamepad
  42841. * @param vrGamepad the gamepad that the controller should be created from
  42842. */
  42843. constructor(vrGamepad: any);
  42844. /**
  42845. * Fired when the trigger on this controller is modified
  42846. */
  42847. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42848. /**
  42849. * Fired when the menu button on this controller is modified
  42850. */
  42851. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42852. /**
  42853. * Fired when the grip button on this controller is modified
  42854. */
  42855. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42856. /**
  42857. * Fired when the thumbstick button on this controller is modified
  42858. */
  42859. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42860. /**
  42861. * Fired when the touchpad button on this controller is modified
  42862. */
  42863. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42864. /**
  42865. * Fired when the touchpad values on this controller are modified
  42866. */
  42867. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42868. private _updateTrackpad;
  42869. /**
  42870. * Called once per frame by the engine.
  42871. */
  42872. update(): void;
  42873. /**
  42874. * Called once for each button that changed state since the last frame
  42875. * @param buttonIdx Which button index changed
  42876. * @param state New state of the button
  42877. * @param changes Which properties on the state changed since last frame
  42878. */
  42879. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42880. /**
  42881. * Moves the buttons on the controller mesh based on their current state
  42882. * @param buttonName the name of the button to move
  42883. * @param buttonValue the value of the button which determines the buttons new position
  42884. */
  42885. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42886. /**
  42887. * Moves the axis on the controller mesh based on its current state
  42888. * @param axis the index of the axis
  42889. * @param axisValue the value of the axis which determines the meshes new position
  42890. * @hidden
  42891. */
  42892. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42893. /**
  42894. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42895. * @param scene scene in which to add meshes
  42896. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42897. */
  42898. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42899. /**
  42900. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42901. * can be transformed by button presses and axes values, based on this._mapping.
  42902. *
  42903. * @param scene scene in which the meshes exist
  42904. * @param meshes list of meshes that make up the controller model to process
  42905. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42906. */
  42907. private processModel;
  42908. private createMeshInfo;
  42909. /**
  42910. * Gets the ray of the controller in the direction the controller is pointing
  42911. * @param length the length the resulting ray should be
  42912. * @returns a ray in the direction the controller is pointing
  42913. */
  42914. getForwardRay(length?: number): Ray;
  42915. /**
  42916. * Disposes of the controller
  42917. */
  42918. dispose(): void;
  42919. }
  42920. }
  42921. declare module "babylonjs/Gamepads/Controllers/index" {
  42922. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42923. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42924. export * from "babylonjs/Gamepads/Controllers/genericController";
  42925. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42926. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42927. export * from "babylonjs/Gamepads/Controllers/viveController";
  42928. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42929. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42930. }
  42931. declare module "babylonjs/Gamepads/index" {
  42932. export * from "babylonjs/Gamepads/Controllers/index";
  42933. export * from "babylonjs/Gamepads/gamepad";
  42934. export * from "babylonjs/Gamepads/gamepadManager";
  42935. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42936. export * from "babylonjs/Gamepads/xboxGamepad";
  42937. }
  42938. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42939. import { Observable } from "babylonjs/Misc/observable";
  42940. import { Nullable } from "babylonjs/types";
  42941. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42943. import { Mesh } from "babylonjs/Meshes/mesh";
  42944. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42945. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42946. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42947. /**
  42948. * Single axis scale gizmo
  42949. */
  42950. export class AxisScaleGizmo extends Gizmo {
  42951. private _coloredMaterial;
  42952. /**
  42953. * Drag behavior responsible for the gizmos dragging interactions
  42954. */
  42955. dragBehavior: PointerDragBehavior;
  42956. private _pointerObserver;
  42957. /**
  42958. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42959. */
  42960. snapDistance: number;
  42961. /**
  42962. * Event that fires each time the gizmo snaps to a new location.
  42963. * * snapDistance is the the change in distance
  42964. */
  42965. onSnapObservable: Observable<{
  42966. snapDistance: number;
  42967. }>;
  42968. /**
  42969. * If the scaling operation should be done on all axis (default: false)
  42970. */
  42971. uniformScaling: boolean;
  42972. /**
  42973. * Creates an AxisScaleGizmo
  42974. * @param gizmoLayer The utility layer the gizmo will be added to
  42975. * @param dragAxis The axis which the gizmo will be able to scale on
  42976. * @param color The color of the gizmo
  42977. */
  42978. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42979. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42980. /**
  42981. * Disposes of the gizmo
  42982. */
  42983. dispose(): void;
  42984. /**
  42985. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42986. * @param mesh The mesh to replace the default mesh of the gizmo
  42987. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42988. */
  42989. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42990. }
  42991. }
  42992. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42993. import { Observable } from "babylonjs/Misc/observable";
  42994. import { Nullable } from "babylonjs/types";
  42995. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42997. import { Mesh } from "babylonjs/Meshes/mesh";
  42998. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42999. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43000. import "babylonjs/Meshes/Builders/boxBuilder";
  43001. /**
  43002. * Bounding box gizmo
  43003. */
  43004. export class BoundingBoxGizmo extends Gizmo {
  43005. private _lineBoundingBox;
  43006. private _rotateSpheresParent;
  43007. private _scaleBoxesParent;
  43008. private _boundingDimensions;
  43009. private _renderObserver;
  43010. private _pointerObserver;
  43011. private _scaleDragSpeed;
  43012. private _tmpQuaternion;
  43013. private _tmpVector;
  43014. private _tmpRotationMatrix;
  43015. /**
  43016. * 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)
  43017. */
  43018. ignoreChildren: boolean;
  43019. /**
  43020. * 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)
  43021. */
  43022. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43023. /**
  43024. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43025. */
  43026. rotationSphereSize: number;
  43027. /**
  43028. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43029. */
  43030. scaleBoxSize: number;
  43031. /**
  43032. * 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)
  43033. */
  43034. fixedDragMeshScreenSize: boolean;
  43035. /**
  43036. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43037. */
  43038. fixedDragMeshScreenSizeDistanceFactor: number;
  43039. /**
  43040. * Fired when a rotation sphere or scale box is dragged
  43041. */
  43042. onDragStartObservable: Observable<{}>;
  43043. /**
  43044. * Fired when a scale box is dragged
  43045. */
  43046. onScaleBoxDragObservable: Observable<{}>;
  43047. /**
  43048. * Fired when a scale box drag is ended
  43049. */
  43050. onScaleBoxDragEndObservable: Observable<{}>;
  43051. /**
  43052. * Fired when a rotation sphere is dragged
  43053. */
  43054. onRotationSphereDragObservable: Observable<{}>;
  43055. /**
  43056. * Fired when a rotation sphere drag is ended
  43057. */
  43058. onRotationSphereDragEndObservable: Observable<{}>;
  43059. /**
  43060. * 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)
  43061. */
  43062. scalePivot: Nullable<Vector3>;
  43063. private _anchorMesh;
  43064. private _existingMeshScale;
  43065. private _dragMesh;
  43066. private pointerDragBehavior;
  43067. private coloredMaterial;
  43068. private hoverColoredMaterial;
  43069. /**
  43070. * Sets the color of the bounding box gizmo
  43071. * @param color the color to set
  43072. */
  43073. setColor(color: Color3): void;
  43074. /**
  43075. * Creates an BoundingBoxGizmo
  43076. * @param gizmoLayer The utility layer the gizmo will be added to
  43077. * @param color The color of the gizmo
  43078. */
  43079. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43080. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43081. private _selectNode;
  43082. /**
  43083. * Updates the bounding box information for the Gizmo
  43084. */
  43085. updateBoundingBox(): void;
  43086. private _updateRotationSpheres;
  43087. private _updateScaleBoxes;
  43088. /**
  43089. * Enables rotation on the specified axis and disables rotation on the others
  43090. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43091. */
  43092. setEnabledRotationAxis(axis: string): void;
  43093. /**
  43094. * Enables/disables scaling
  43095. * @param enable if scaling should be enabled
  43096. */
  43097. setEnabledScaling(enable: boolean): void;
  43098. private _updateDummy;
  43099. /**
  43100. * Enables a pointer drag behavior on the bounding box of the gizmo
  43101. */
  43102. enableDragBehavior(): void;
  43103. /**
  43104. * Disposes of the gizmo
  43105. */
  43106. dispose(): void;
  43107. /**
  43108. * 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)
  43109. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43110. * @returns the bounding box mesh with the passed in mesh as a child
  43111. */
  43112. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43113. /**
  43114. * CustomMeshes are not supported by this gizmo
  43115. * @param mesh The mesh to replace the default mesh of the gizmo
  43116. */
  43117. setCustomMesh(mesh: Mesh): void;
  43118. }
  43119. }
  43120. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43121. import { Observable } from "babylonjs/Misc/observable";
  43122. import { Nullable } from "babylonjs/types";
  43123. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43125. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43126. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43127. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43128. import "babylonjs/Meshes/Builders/linesBuilder";
  43129. /**
  43130. * Single plane rotation gizmo
  43131. */
  43132. export class PlaneRotationGizmo extends Gizmo {
  43133. /**
  43134. * Drag behavior responsible for the gizmos dragging interactions
  43135. */
  43136. dragBehavior: PointerDragBehavior;
  43137. private _pointerObserver;
  43138. /**
  43139. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43140. */
  43141. snapDistance: number;
  43142. /**
  43143. * Event that fires each time the gizmo snaps to a new location.
  43144. * * snapDistance is the the change in distance
  43145. */
  43146. onSnapObservable: Observable<{
  43147. snapDistance: number;
  43148. }>;
  43149. /**
  43150. * Creates a PlaneRotationGizmo
  43151. * @param gizmoLayer The utility layer the gizmo will be added to
  43152. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43153. * @param color The color of the gizmo
  43154. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43155. */
  43156. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43157. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43158. /**
  43159. * Disposes of the gizmo
  43160. */
  43161. dispose(): void;
  43162. }
  43163. }
  43164. declare module "babylonjs/Gizmos/rotationGizmo" {
  43165. import { Observable } from "babylonjs/Misc/observable";
  43166. import { Nullable } from "babylonjs/types";
  43167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43168. import { Mesh } from "babylonjs/Meshes/mesh";
  43169. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43170. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43171. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43172. /**
  43173. * Gizmo that enables rotating a mesh along 3 axis
  43174. */
  43175. export class RotationGizmo extends Gizmo {
  43176. /**
  43177. * Internal gizmo used for interactions on the x axis
  43178. */
  43179. xGizmo: PlaneRotationGizmo;
  43180. /**
  43181. * Internal gizmo used for interactions on the y axis
  43182. */
  43183. yGizmo: PlaneRotationGizmo;
  43184. /**
  43185. * Internal gizmo used for interactions on the z axis
  43186. */
  43187. zGizmo: PlaneRotationGizmo;
  43188. /** Fires an event when any of it's sub gizmos are dragged */
  43189. onDragStartObservable: Observable<{}>;
  43190. /** Fires an event when any of it's sub gizmos are released from dragging */
  43191. onDragEndObservable: Observable<{}>;
  43192. attachedMesh: Nullable<AbstractMesh>;
  43193. /**
  43194. * Creates a RotationGizmo
  43195. * @param gizmoLayer The utility layer the gizmo will be added to
  43196. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43197. */
  43198. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43199. updateGizmoRotationToMatchAttachedMesh: boolean;
  43200. /**
  43201. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43202. */
  43203. snapDistance: number;
  43204. /**
  43205. * Ratio for the scale of the gizmo (Default: 1)
  43206. */
  43207. scaleRatio: number;
  43208. /**
  43209. * Disposes of the gizmo
  43210. */
  43211. dispose(): void;
  43212. /**
  43213. * CustomMeshes are not supported by this gizmo
  43214. * @param mesh The mesh to replace the default mesh of the gizmo
  43215. */
  43216. setCustomMesh(mesh: Mesh): void;
  43217. }
  43218. }
  43219. declare module "babylonjs/Gizmos/positionGizmo" {
  43220. import { Observable } from "babylonjs/Misc/observable";
  43221. import { Nullable } from "babylonjs/types";
  43222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43223. import { Mesh } from "babylonjs/Meshes/mesh";
  43224. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43225. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43226. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43227. /**
  43228. * Gizmo that enables dragging a mesh along 3 axis
  43229. */
  43230. export class PositionGizmo extends Gizmo {
  43231. /**
  43232. * Internal gizmo used for interactions on the x axis
  43233. */
  43234. xGizmo: AxisDragGizmo;
  43235. /**
  43236. * Internal gizmo used for interactions on the y axis
  43237. */
  43238. yGizmo: AxisDragGizmo;
  43239. /**
  43240. * Internal gizmo used for interactions on the z axis
  43241. */
  43242. zGizmo: AxisDragGizmo;
  43243. /** Fires an event when any of it's sub gizmos are dragged */
  43244. onDragStartObservable: Observable<{}>;
  43245. /** Fires an event when any of it's sub gizmos are released from dragging */
  43246. onDragEndObservable: Observable<{}>;
  43247. attachedMesh: Nullable<AbstractMesh>;
  43248. /**
  43249. * Creates a PositionGizmo
  43250. * @param gizmoLayer The utility layer the gizmo will be added to
  43251. */
  43252. constructor(gizmoLayer?: UtilityLayerRenderer);
  43253. updateGizmoRotationToMatchAttachedMesh: boolean;
  43254. /**
  43255. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43256. */
  43257. snapDistance: number;
  43258. /**
  43259. * Ratio for the scale of the gizmo (Default: 1)
  43260. */
  43261. scaleRatio: number;
  43262. /**
  43263. * Disposes of the gizmo
  43264. */
  43265. dispose(): void;
  43266. /**
  43267. * CustomMeshes are not supported by this gizmo
  43268. * @param mesh The mesh to replace the default mesh of the gizmo
  43269. */
  43270. setCustomMesh(mesh: Mesh): void;
  43271. }
  43272. }
  43273. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43274. import { Scene } from "babylonjs/scene";
  43275. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43276. import { Mesh } from "babylonjs/Meshes/mesh";
  43277. /**
  43278. * Class containing static functions to help procedurally build meshes
  43279. */
  43280. export class PolyhedronBuilder {
  43281. /**
  43282. * Creates a polyhedron mesh
  43283. * * 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
  43284. * * The parameter `size` (positive float, default 1) sets the polygon size
  43285. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43286. * * 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`
  43287. * * 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
  43288. * * 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)`)
  43289. * * 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
  43290. * * 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
  43291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43294. * @param name defines the name of the mesh
  43295. * @param options defines the options used to create the mesh
  43296. * @param scene defines the hosting scene
  43297. * @returns the polyhedron mesh
  43298. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43299. */
  43300. static CreatePolyhedron(name: string, options: {
  43301. type?: number;
  43302. size?: number;
  43303. sizeX?: number;
  43304. sizeY?: number;
  43305. sizeZ?: number;
  43306. custom?: any;
  43307. faceUV?: Vector4[];
  43308. faceColors?: Color4[];
  43309. flat?: boolean;
  43310. updatable?: boolean;
  43311. sideOrientation?: number;
  43312. frontUVs?: Vector4;
  43313. backUVs?: Vector4;
  43314. }, scene: Scene): Mesh;
  43315. }
  43316. }
  43317. declare module "babylonjs/Gizmos/scaleGizmo" {
  43318. import { Observable } from "babylonjs/Misc/observable";
  43319. import { Nullable } from "babylonjs/types";
  43320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43321. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43322. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43323. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43324. /**
  43325. * Gizmo that enables scaling a mesh along 3 axis
  43326. */
  43327. export class ScaleGizmo extends Gizmo {
  43328. /**
  43329. * Internal gizmo used for interactions on the x axis
  43330. */
  43331. xGizmo: AxisScaleGizmo;
  43332. /**
  43333. * Internal gizmo used for interactions on the y axis
  43334. */
  43335. yGizmo: AxisScaleGizmo;
  43336. /**
  43337. * Internal gizmo used for interactions on the z axis
  43338. */
  43339. zGizmo: AxisScaleGizmo;
  43340. /**
  43341. * Internal gizmo used to scale all axis equally
  43342. */
  43343. uniformScaleGizmo: AxisScaleGizmo;
  43344. /** Fires an event when any of it's sub gizmos are dragged */
  43345. onDragStartObservable: Observable<{}>;
  43346. /** Fires an event when any of it's sub gizmos are released from dragging */
  43347. onDragEndObservable: Observable<{}>;
  43348. attachedMesh: Nullable<AbstractMesh>;
  43349. /**
  43350. * Creates a ScaleGizmo
  43351. * @param gizmoLayer The utility layer the gizmo will be added to
  43352. */
  43353. constructor(gizmoLayer?: UtilityLayerRenderer);
  43354. updateGizmoRotationToMatchAttachedMesh: boolean;
  43355. /**
  43356. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43357. */
  43358. snapDistance: number;
  43359. /**
  43360. * Ratio for the scale of the gizmo (Default: 1)
  43361. */
  43362. scaleRatio: number;
  43363. /**
  43364. * Disposes of the gizmo
  43365. */
  43366. dispose(): void;
  43367. }
  43368. }
  43369. declare module "babylonjs/Gizmos/gizmoManager" {
  43370. import { Observable } from "babylonjs/Misc/observable";
  43371. import { Nullable } from "babylonjs/types";
  43372. import { Scene, IDisposable } from "babylonjs/scene";
  43373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43374. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43375. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43376. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43377. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43378. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43379. /**
  43380. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43381. */
  43382. export class GizmoManager implements IDisposable {
  43383. private scene;
  43384. /**
  43385. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43386. */
  43387. gizmos: {
  43388. positionGizmo: Nullable<PositionGizmo>;
  43389. rotationGizmo: Nullable<RotationGizmo>;
  43390. scaleGizmo: Nullable<ScaleGizmo>;
  43391. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43392. };
  43393. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43394. clearGizmoOnEmptyPointerEvent: boolean;
  43395. /** Fires an event when the manager is attached to a mesh */
  43396. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43397. private _gizmosEnabled;
  43398. private _pointerObserver;
  43399. private _attachedMesh;
  43400. private _boundingBoxColor;
  43401. private _defaultUtilityLayer;
  43402. private _defaultKeepDepthUtilityLayer;
  43403. /**
  43404. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43405. */
  43406. boundingBoxDragBehavior: SixDofDragBehavior;
  43407. /**
  43408. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43409. */
  43410. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43411. /**
  43412. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43413. */
  43414. usePointerToAttachGizmos: boolean;
  43415. /**
  43416. * Instatiates a gizmo manager
  43417. * @param scene the scene to overlay the gizmos on top of
  43418. */
  43419. constructor(scene: Scene);
  43420. /**
  43421. * Attaches a set of gizmos to the specified mesh
  43422. * @param mesh The mesh the gizmo's should be attached to
  43423. */
  43424. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43425. /**
  43426. * If the position gizmo is enabled
  43427. */
  43428. positionGizmoEnabled: boolean;
  43429. /**
  43430. * If the rotation gizmo is enabled
  43431. */
  43432. rotationGizmoEnabled: boolean;
  43433. /**
  43434. * If the scale gizmo is enabled
  43435. */
  43436. scaleGizmoEnabled: boolean;
  43437. /**
  43438. * If the boundingBox gizmo is enabled
  43439. */
  43440. boundingBoxGizmoEnabled: boolean;
  43441. /**
  43442. * Disposes of the gizmo manager
  43443. */
  43444. dispose(): void;
  43445. }
  43446. }
  43447. declare module "babylonjs/Gizmos/lightGizmo" {
  43448. import { Nullable } from "babylonjs/types";
  43449. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43450. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43451. import { Light } from "babylonjs/Lights/light";
  43452. /**
  43453. * Gizmo that enables viewing a light
  43454. */
  43455. export class LightGizmo extends Gizmo {
  43456. private _box;
  43457. /**
  43458. * Creates a LightGizmo
  43459. * @param gizmoLayer The utility layer the gizmo will be added to
  43460. */
  43461. constructor(gizmoLayer?: UtilityLayerRenderer);
  43462. private _light;
  43463. /**
  43464. * The light that the gizmo is attached to
  43465. */
  43466. light: Nullable<Light>;
  43467. /**
  43468. * @hidden
  43469. * Updates the gizmo to match the attached mesh's position/rotation
  43470. */
  43471. protected _update(): void;
  43472. }
  43473. }
  43474. declare module "babylonjs/Gizmos/index" {
  43475. export * from "babylonjs/Gizmos/axisDragGizmo";
  43476. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43477. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43478. export * from "babylonjs/Gizmos/gizmo";
  43479. export * from "babylonjs/Gizmos/gizmoManager";
  43480. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43481. export * from "babylonjs/Gizmos/positionGizmo";
  43482. export * from "babylonjs/Gizmos/rotationGizmo";
  43483. export * from "babylonjs/Gizmos/scaleGizmo";
  43484. export * from "babylonjs/Gizmos/lightGizmo";
  43485. }
  43486. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43487. /** @hidden */
  43488. export var backgroundFragmentDeclaration: {
  43489. name: string;
  43490. shader: string;
  43491. };
  43492. }
  43493. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43494. /** @hidden */
  43495. export var backgroundUboDeclaration: {
  43496. name: string;
  43497. shader: string;
  43498. };
  43499. }
  43500. declare module "babylonjs/Shaders/background.fragment" {
  43501. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43502. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43503. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43504. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43505. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43506. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43507. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43508. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43509. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43510. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43511. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43512. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43513. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43514. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43515. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43516. /** @hidden */
  43517. export var backgroundPixelShader: {
  43518. name: string;
  43519. shader: string;
  43520. };
  43521. }
  43522. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43523. /** @hidden */
  43524. export var backgroundVertexDeclaration: {
  43525. name: string;
  43526. shader: string;
  43527. };
  43528. }
  43529. declare module "babylonjs/Shaders/background.vertex" {
  43530. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43531. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43532. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43533. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43534. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43535. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43536. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43537. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43538. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43539. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43540. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43541. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43542. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43543. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43544. /** @hidden */
  43545. export var backgroundVertexShader: {
  43546. name: string;
  43547. shader: string;
  43548. };
  43549. }
  43550. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43551. import { Nullable, int, float } from "babylonjs/types";
  43552. import { Scene } from "babylonjs/scene";
  43553. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43554. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43556. import { Mesh } from "babylonjs/Meshes/mesh";
  43557. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43558. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43559. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43561. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43562. import "babylonjs/Shaders/background.fragment";
  43563. import "babylonjs/Shaders/background.vertex";
  43564. /**
  43565. * Background material used to create an efficient environement around your scene.
  43566. */
  43567. export class BackgroundMaterial extends PushMaterial {
  43568. /**
  43569. * Standard reflectance value at parallel view angle.
  43570. */
  43571. static StandardReflectance0: number;
  43572. /**
  43573. * Standard reflectance value at grazing angle.
  43574. */
  43575. static StandardReflectance90: number;
  43576. protected _primaryColor: Color3;
  43577. /**
  43578. * Key light Color (multiply against the environement texture)
  43579. */
  43580. primaryColor: Color3;
  43581. protected __perceptualColor: Nullable<Color3>;
  43582. /**
  43583. * Experimental Internal Use Only.
  43584. *
  43585. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43586. * This acts as a helper to set the primary color to a more "human friendly" value.
  43587. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43588. * output color as close as possible from the chosen value.
  43589. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43590. * part of lighting setup.)
  43591. */
  43592. _perceptualColor: Nullable<Color3>;
  43593. protected _primaryColorShadowLevel: float;
  43594. /**
  43595. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43596. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43597. */
  43598. primaryColorShadowLevel: float;
  43599. protected _primaryColorHighlightLevel: float;
  43600. /**
  43601. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43602. * The primary color is used at the level chosen to define what the white area would look.
  43603. */
  43604. primaryColorHighlightLevel: float;
  43605. protected _reflectionTexture: Nullable<BaseTexture>;
  43606. /**
  43607. * Reflection Texture used in the material.
  43608. * Should be author in a specific way for the best result (refer to the documentation).
  43609. */
  43610. reflectionTexture: Nullable<BaseTexture>;
  43611. protected _reflectionBlur: float;
  43612. /**
  43613. * Reflection Texture level of blur.
  43614. *
  43615. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43616. * texture twice.
  43617. */
  43618. reflectionBlur: float;
  43619. protected _diffuseTexture: Nullable<BaseTexture>;
  43620. /**
  43621. * Diffuse Texture used in the material.
  43622. * Should be author in a specific way for the best result (refer to the documentation).
  43623. */
  43624. diffuseTexture: Nullable<BaseTexture>;
  43625. protected _shadowLights: Nullable<IShadowLight[]>;
  43626. /**
  43627. * Specify the list of lights casting shadow on the material.
  43628. * All scene shadow lights will be included if null.
  43629. */
  43630. shadowLights: Nullable<IShadowLight[]>;
  43631. protected _shadowLevel: float;
  43632. /**
  43633. * Helps adjusting the shadow to a softer level if required.
  43634. * 0 means black shadows and 1 means no shadows.
  43635. */
  43636. shadowLevel: float;
  43637. protected _sceneCenter: Vector3;
  43638. /**
  43639. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43640. * It is usually zero but might be interesting to modify according to your setup.
  43641. */
  43642. sceneCenter: Vector3;
  43643. protected _opacityFresnel: boolean;
  43644. /**
  43645. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43646. * This helps ensuring a nice transition when the camera goes under the ground.
  43647. */
  43648. opacityFresnel: boolean;
  43649. protected _reflectionFresnel: boolean;
  43650. /**
  43651. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43652. * This helps adding a mirror texture on the ground.
  43653. */
  43654. reflectionFresnel: boolean;
  43655. protected _reflectionFalloffDistance: number;
  43656. /**
  43657. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43658. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43659. */
  43660. reflectionFalloffDistance: number;
  43661. protected _reflectionAmount: number;
  43662. /**
  43663. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43664. */
  43665. reflectionAmount: number;
  43666. protected _reflectionReflectance0: number;
  43667. /**
  43668. * This specifies the weight of the reflection at grazing angle.
  43669. */
  43670. reflectionReflectance0: number;
  43671. protected _reflectionReflectance90: number;
  43672. /**
  43673. * This specifies the weight of the reflection at a perpendicular point of view.
  43674. */
  43675. reflectionReflectance90: number;
  43676. /**
  43677. * Sets the reflection reflectance fresnel values according to the default standard
  43678. * empirically know to work well :-)
  43679. */
  43680. reflectionStandardFresnelWeight: number;
  43681. protected _useRGBColor: boolean;
  43682. /**
  43683. * Helps to directly use the maps channels instead of their level.
  43684. */
  43685. useRGBColor: boolean;
  43686. protected _enableNoise: boolean;
  43687. /**
  43688. * This helps reducing the banding effect that could occur on the background.
  43689. */
  43690. enableNoise: boolean;
  43691. /**
  43692. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43693. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43694. * Recommended to be keep at 1.0 except for special cases.
  43695. */
  43696. fovMultiplier: number;
  43697. private _fovMultiplier;
  43698. /**
  43699. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43700. */
  43701. useEquirectangularFOV: boolean;
  43702. private _maxSimultaneousLights;
  43703. /**
  43704. * Number of Simultaneous lights allowed on the material.
  43705. */
  43706. maxSimultaneousLights: int;
  43707. /**
  43708. * Default configuration related to image processing available in the Background Material.
  43709. */
  43710. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43711. /**
  43712. * Keep track of the image processing observer to allow dispose and replace.
  43713. */
  43714. private _imageProcessingObserver;
  43715. /**
  43716. * Attaches a new image processing configuration to the PBR Material.
  43717. * @param configuration (if null the scene configuration will be use)
  43718. */
  43719. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43720. /**
  43721. * Gets the image processing configuration used either in this material.
  43722. */
  43723. /**
  43724. * Sets the Default image processing configuration used either in the this material.
  43725. *
  43726. * If sets to null, the scene one is in use.
  43727. */
  43728. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43729. /**
  43730. * Gets wether the color curves effect is enabled.
  43731. */
  43732. /**
  43733. * Sets wether the color curves effect is enabled.
  43734. */
  43735. cameraColorCurvesEnabled: boolean;
  43736. /**
  43737. * Gets wether the color grading effect is enabled.
  43738. */
  43739. /**
  43740. * Gets wether the color grading effect is enabled.
  43741. */
  43742. cameraColorGradingEnabled: boolean;
  43743. /**
  43744. * Gets wether tonemapping is enabled or not.
  43745. */
  43746. /**
  43747. * Sets wether tonemapping is enabled or not
  43748. */
  43749. cameraToneMappingEnabled: boolean;
  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. /**
  43756. * The camera exposure used on this material.
  43757. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43758. * This corresponds to a photographic exposure.
  43759. */
  43760. cameraExposure: float;
  43761. /**
  43762. * Gets The camera contrast used on this material.
  43763. */
  43764. /**
  43765. * Sets The camera contrast used on this material.
  43766. */
  43767. cameraContrast: float;
  43768. /**
  43769. * Gets the Color Grading 2D Lookup Texture.
  43770. */
  43771. /**
  43772. * Sets the Color Grading 2D Lookup Texture.
  43773. */
  43774. cameraColorGradingTexture: Nullable<BaseTexture>;
  43775. /**
  43776. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43777. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43778. * 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;
  43779. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43780. */
  43781. /**
  43782. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43783. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43784. * 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;
  43785. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43786. */
  43787. cameraColorCurves: Nullable<ColorCurves>;
  43788. /**
  43789. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43790. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43791. */
  43792. switchToBGR: boolean;
  43793. private _renderTargets;
  43794. private _reflectionControls;
  43795. private _white;
  43796. private _primaryShadowColor;
  43797. private _primaryHighlightColor;
  43798. /**
  43799. * Instantiates a Background Material in the given scene
  43800. * @param name The friendly name of the material
  43801. * @param scene The scene to add the material to
  43802. */
  43803. constructor(name: string, scene: Scene);
  43804. /**
  43805. * Gets a boolean indicating that current material needs to register RTT
  43806. */
  43807. readonly hasRenderTargetTextures: boolean;
  43808. /**
  43809. * The entire material has been created in order to prevent overdraw.
  43810. * @returns false
  43811. */
  43812. needAlphaTesting(): boolean;
  43813. /**
  43814. * The entire material has been created in order to prevent overdraw.
  43815. * @returns true if blending is enable
  43816. */
  43817. needAlphaBlending(): boolean;
  43818. /**
  43819. * Checks wether the material is ready to be rendered for a given mesh.
  43820. * @param mesh The mesh to render
  43821. * @param subMesh The submesh to check against
  43822. * @param useInstances Specify wether or not the material is used with instances
  43823. * @returns true if all the dependencies are ready (Textures, Effects...)
  43824. */
  43825. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43826. /**
  43827. * Compute the primary color according to the chosen perceptual color.
  43828. */
  43829. private _computePrimaryColorFromPerceptualColor;
  43830. /**
  43831. * Compute the highlights and shadow colors according to their chosen levels.
  43832. */
  43833. private _computePrimaryColors;
  43834. /**
  43835. * Build the uniform buffer used in the material.
  43836. */
  43837. buildUniformLayout(): void;
  43838. /**
  43839. * Unbind the material.
  43840. */
  43841. unbind(): void;
  43842. /**
  43843. * Bind only the world matrix to the material.
  43844. * @param world The world matrix to bind.
  43845. */
  43846. bindOnlyWorldMatrix(world: Matrix): void;
  43847. /**
  43848. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43849. * @param world The world matrix to bind.
  43850. * @param subMesh The submesh to bind for.
  43851. */
  43852. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43853. /**
  43854. * Dispose the material.
  43855. * @param forceDisposeEffect Force disposal of the associated effect.
  43856. * @param forceDisposeTextures Force disposal of the associated textures.
  43857. */
  43858. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43859. /**
  43860. * Clones the material.
  43861. * @param name The cloned name.
  43862. * @returns The cloned material.
  43863. */
  43864. clone(name: string): BackgroundMaterial;
  43865. /**
  43866. * Serializes the current material to its JSON representation.
  43867. * @returns The JSON representation.
  43868. */
  43869. serialize(): any;
  43870. /**
  43871. * Gets the class name of the material
  43872. * @returns "BackgroundMaterial"
  43873. */
  43874. getClassName(): string;
  43875. /**
  43876. * Parse a JSON input to create back a background material.
  43877. * @param source The JSON data to parse
  43878. * @param scene The scene to create the parsed material in
  43879. * @param rootUrl The root url of the assets the material depends upon
  43880. * @returns the instantiated BackgroundMaterial.
  43881. */
  43882. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43883. }
  43884. }
  43885. declare module "babylonjs/Helpers/environmentHelper" {
  43886. import { Observable } from "babylonjs/Misc/observable";
  43887. import { Nullable } from "babylonjs/types";
  43888. import { Scene } from "babylonjs/scene";
  43889. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43891. import { Mesh } from "babylonjs/Meshes/mesh";
  43892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43893. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43894. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43895. import "babylonjs/Meshes/Builders/planeBuilder";
  43896. import "babylonjs/Meshes/Builders/boxBuilder";
  43897. /**
  43898. * Represents the different options available during the creation of
  43899. * a Environment helper.
  43900. *
  43901. * This can control the default ground, skybox and image processing setup of your scene.
  43902. */
  43903. export interface IEnvironmentHelperOptions {
  43904. /**
  43905. * Specifies wether or not to create a ground.
  43906. * True by default.
  43907. */
  43908. createGround: boolean;
  43909. /**
  43910. * Specifies the ground size.
  43911. * 15 by default.
  43912. */
  43913. groundSize: number;
  43914. /**
  43915. * The texture used on the ground for the main color.
  43916. * Comes from the BabylonJS CDN by default.
  43917. *
  43918. * Remarks: Can be either a texture or a url.
  43919. */
  43920. groundTexture: string | BaseTexture;
  43921. /**
  43922. * The color mixed in the ground texture by default.
  43923. * BabylonJS clearColor by default.
  43924. */
  43925. groundColor: Color3;
  43926. /**
  43927. * Specifies the ground opacity.
  43928. * 1 by default.
  43929. */
  43930. groundOpacity: number;
  43931. /**
  43932. * Enables the ground to receive shadows.
  43933. * True by default.
  43934. */
  43935. enableGroundShadow: boolean;
  43936. /**
  43937. * Helps preventing the shadow to be fully black on the ground.
  43938. * 0.5 by default.
  43939. */
  43940. groundShadowLevel: number;
  43941. /**
  43942. * Creates a mirror texture attach to the ground.
  43943. * false by default.
  43944. */
  43945. enableGroundMirror: boolean;
  43946. /**
  43947. * Specifies the ground mirror size ratio.
  43948. * 0.3 by default as the default kernel is 64.
  43949. */
  43950. groundMirrorSizeRatio: number;
  43951. /**
  43952. * Specifies the ground mirror blur kernel size.
  43953. * 64 by default.
  43954. */
  43955. groundMirrorBlurKernel: number;
  43956. /**
  43957. * Specifies the ground mirror visibility amount.
  43958. * 1 by default
  43959. */
  43960. groundMirrorAmount: number;
  43961. /**
  43962. * Specifies the ground mirror reflectance weight.
  43963. * This uses the standard weight of the background material to setup the fresnel effect
  43964. * of the mirror.
  43965. * 1 by default.
  43966. */
  43967. groundMirrorFresnelWeight: number;
  43968. /**
  43969. * Specifies the ground mirror Falloff distance.
  43970. * This can helps reducing the size of the reflection.
  43971. * 0 by Default.
  43972. */
  43973. groundMirrorFallOffDistance: number;
  43974. /**
  43975. * Specifies the ground mirror texture type.
  43976. * Unsigned Int by Default.
  43977. */
  43978. groundMirrorTextureType: number;
  43979. /**
  43980. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43981. * the shown objects.
  43982. */
  43983. groundYBias: number;
  43984. /**
  43985. * Specifies wether or not to create a skybox.
  43986. * True by default.
  43987. */
  43988. createSkybox: boolean;
  43989. /**
  43990. * Specifies the skybox size.
  43991. * 20 by default.
  43992. */
  43993. skyboxSize: number;
  43994. /**
  43995. * The texture used on the skybox for the main color.
  43996. * Comes from the BabylonJS CDN by default.
  43997. *
  43998. * Remarks: Can be either a texture or a url.
  43999. */
  44000. skyboxTexture: string | BaseTexture;
  44001. /**
  44002. * The color mixed in the skybox texture by default.
  44003. * BabylonJS clearColor by default.
  44004. */
  44005. skyboxColor: Color3;
  44006. /**
  44007. * The background rotation around the Y axis of the scene.
  44008. * This helps aligning the key lights of your scene with the background.
  44009. * 0 by default.
  44010. */
  44011. backgroundYRotation: number;
  44012. /**
  44013. * Compute automatically the size of the elements to best fit with the scene.
  44014. */
  44015. sizeAuto: boolean;
  44016. /**
  44017. * Default position of the rootMesh if autoSize is not true.
  44018. */
  44019. rootPosition: Vector3;
  44020. /**
  44021. * Sets up the image processing in the scene.
  44022. * true by default.
  44023. */
  44024. setupImageProcessing: boolean;
  44025. /**
  44026. * The texture used as your environment texture in the scene.
  44027. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44028. *
  44029. * Remarks: Can be either a texture or a url.
  44030. */
  44031. environmentTexture: string | BaseTexture;
  44032. /**
  44033. * The value of the exposure to apply to the scene.
  44034. * 0.6 by default if setupImageProcessing is true.
  44035. */
  44036. cameraExposure: number;
  44037. /**
  44038. * The value of the contrast to apply to the scene.
  44039. * 1.6 by default if setupImageProcessing is true.
  44040. */
  44041. cameraContrast: number;
  44042. /**
  44043. * Specifies wether or not tonemapping should be enabled in the scene.
  44044. * true by default if setupImageProcessing is true.
  44045. */
  44046. toneMappingEnabled: boolean;
  44047. }
  44048. /**
  44049. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44050. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44051. * It also helps with the default setup of your imageProcessing configuration.
  44052. */
  44053. export class EnvironmentHelper {
  44054. /**
  44055. * Default ground texture URL.
  44056. */
  44057. private static _groundTextureCDNUrl;
  44058. /**
  44059. * Default skybox texture URL.
  44060. */
  44061. private static _skyboxTextureCDNUrl;
  44062. /**
  44063. * Default environment texture URL.
  44064. */
  44065. private static _environmentTextureCDNUrl;
  44066. /**
  44067. * Creates the default options for the helper.
  44068. */
  44069. private static _getDefaultOptions;
  44070. private _rootMesh;
  44071. /**
  44072. * Gets the root mesh created by the helper.
  44073. */
  44074. readonly rootMesh: Mesh;
  44075. private _skybox;
  44076. /**
  44077. * Gets the skybox created by the helper.
  44078. */
  44079. readonly skybox: Nullable<Mesh>;
  44080. private _skyboxTexture;
  44081. /**
  44082. * Gets the skybox texture created by the helper.
  44083. */
  44084. readonly skyboxTexture: Nullable<BaseTexture>;
  44085. private _skyboxMaterial;
  44086. /**
  44087. * Gets the skybox material created by the helper.
  44088. */
  44089. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44090. private _ground;
  44091. /**
  44092. * Gets the ground mesh created by the helper.
  44093. */
  44094. readonly ground: Nullable<Mesh>;
  44095. private _groundTexture;
  44096. /**
  44097. * Gets the ground texture created by the helper.
  44098. */
  44099. readonly groundTexture: Nullable<BaseTexture>;
  44100. private _groundMirror;
  44101. /**
  44102. * Gets the ground mirror created by the helper.
  44103. */
  44104. readonly groundMirror: Nullable<MirrorTexture>;
  44105. /**
  44106. * Gets the ground mirror render list to helps pushing the meshes
  44107. * you wish in the ground reflection.
  44108. */
  44109. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44110. private _groundMaterial;
  44111. /**
  44112. * Gets the ground material created by the helper.
  44113. */
  44114. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44115. /**
  44116. * Stores the creation options.
  44117. */
  44118. private readonly _scene;
  44119. private _options;
  44120. /**
  44121. * This observable will be notified with any error during the creation of the environment,
  44122. * mainly texture creation errors.
  44123. */
  44124. onErrorObservable: Observable<{
  44125. message?: string;
  44126. exception?: any;
  44127. }>;
  44128. /**
  44129. * constructor
  44130. * @param options Defines the options we want to customize the helper
  44131. * @param scene The scene to add the material to
  44132. */
  44133. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44134. /**
  44135. * Updates the background according to the new options
  44136. * @param options
  44137. */
  44138. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44139. /**
  44140. * Sets the primary color of all the available elements.
  44141. * @param color the main color to affect to the ground and the background
  44142. */
  44143. setMainColor(color: Color3): void;
  44144. /**
  44145. * Setup the image processing according to the specified options.
  44146. */
  44147. private _setupImageProcessing;
  44148. /**
  44149. * Setup the environment texture according to the specified options.
  44150. */
  44151. private _setupEnvironmentTexture;
  44152. /**
  44153. * Setup the background according to the specified options.
  44154. */
  44155. private _setupBackground;
  44156. /**
  44157. * Get the scene sizes according to the setup.
  44158. */
  44159. private _getSceneSize;
  44160. /**
  44161. * Setup the ground according to the specified options.
  44162. */
  44163. private _setupGround;
  44164. /**
  44165. * Setup the ground material according to the specified options.
  44166. */
  44167. private _setupGroundMaterial;
  44168. /**
  44169. * Setup the ground diffuse texture according to the specified options.
  44170. */
  44171. private _setupGroundDiffuseTexture;
  44172. /**
  44173. * Setup the ground mirror texture according to the specified options.
  44174. */
  44175. private _setupGroundMirrorTexture;
  44176. /**
  44177. * Setup the ground to receive the mirror texture.
  44178. */
  44179. private _setupMirrorInGroundMaterial;
  44180. /**
  44181. * Setup the skybox according to the specified options.
  44182. */
  44183. private _setupSkybox;
  44184. /**
  44185. * Setup the skybox material according to the specified options.
  44186. */
  44187. private _setupSkyboxMaterial;
  44188. /**
  44189. * Setup the skybox reflection texture according to the specified options.
  44190. */
  44191. private _setupSkyboxReflectionTexture;
  44192. private _errorHandler;
  44193. /**
  44194. * Dispose all the elements created by the Helper.
  44195. */
  44196. dispose(): void;
  44197. }
  44198. }
  44199. declare module "babylonjs/Helpers/photoDome" {
  44200. import { Observable } from "babylonjs/Misc/observable";
  44201. import { Nullable } from "babylonjs/types";
  44202. import { Scene } from "babylonjs/scene";
  44203. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44204. import { Mesh } from "babylonjs/Meshes/mesh";
  44205. import { Texture } from "babylonjs/Materials/Textures/texture";
  44206. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44207. import "babylonjs/Meshes/Builders/sphereBuilder";
  44208. /**
  44209. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44210. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44211. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44212. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44213. */
  44214. export class PhotoDome extends TransformNode {
  44215. private _useDirectMapping;
  44216. /**
  44217. * The texture being displayed on the sphere
  44218. */
  44219. protected _photoTexture: Texture;
  44220. /**
  44221. * Gets or sets the texture being displayed on the sphere
  44222. */
  44223. photoTexture: Texture;
  44224. /**
  44225. * Observable raised when an error occured while loading the 360 image
  44226. */
  44227. onLoadErrorObservable: Observable<string>;
  44228. /**
  44229. * The skybox material
  44230. */
  44231. protected _material: BackgroundMaterial;
  44232. /**
  44233. * The surface used for the skybox
  44234. */
  44235. protected _mesh: Mesh;
  44236. /**
  44237. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44238. * Also see the options.resolution property.
  44239. */
  44240. fovMultiplier: number;
  44241. /**
  44242. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44243. * @param name Element's name, child elements will append suffixes for their own names.
  44244. * @param urlsOfPhoto defines the url of the photo to display
  44245. * @param options defines an object containing optional or exposed sub element properties
  44246. * @param onError defines a callback called when an error occured while loading the texture
  44247. */
  44248. constructor(name: string, urlOfPhoto: string, options: {
  44249. resolution?: number;
  44250. size?: number;
  44251. useDirectMapping?: boolean;
  44252. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44253. /**
  44254. * Releases resources associated with this node.
  44255. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44256. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44257. */
  44258. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44259. }
  44260. }
  44261. declare module "babylonjs/Misc/textureTools" {
  44262. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44263. import { Texture } from "babylonjs/Materials/Textures/texture";
  44264. import { Scene } from "babylonjs/scene";
  44265. /**
  44266. * Class used to host texture specific utilities
  44267. */
  44268. export class TextureTools {
  44269. /**
  44270. * Uses the GPU to create a copy texture rescaled at a given size
  44271. * @param texture Texture to copy from
  44272. * @param width defines the desired width
  44273. * @param height defines the desired height
  44274. * @param useBilinearMode defines if bilinear mode has to be used
  44275. * @return the generated texture
  44276. */
  44277. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44278. /**
  44279. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44280. * @param scene defines the hosting scene
  44281. * @returns the environment BRDF texture
  44282. */
  44283. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44284. private static _environmentBRDFBase64Texture;
  44285. }
  44286. }
  44287. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44288. import { Nullable } from "babylonjs/types";
  44289. import { IAnimatable } from "babylonjs/Misc/tools";
  44290. import { Color3 } from "babylonjs/Maths/math";
  44291. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44292. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44293. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44294. import { Engine } from "babylonjs/Engines/engine";
  44295. import { Scene } from "babylonjs/scene";
  44296. /**
  44297. * @hidden
  44298. */
  44299. export interface IMaterialClearCoatDefines {
  44300. CLEARCOAT: boolean;
  44301. CLEARCOAT_DEFAULTIOR: boolean;
  44302. CLEARCOAT_TEXTURE: boolean;
  44303. CLEARCOAT_TEXTUREDIRECTUV: number;
  44304. CLEARCOAT_BUMP: boolean;
  44305. CLEARCOAT_BUMPDIRECTUV: number;
  44306. CLEARCOAT_TINT: boolean;
  44307. CLEARCOAT_TINT_TEXTURE: boolean;
  44308. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44309. /** @hidden */
  44310. _areTexturesDirty: boolean;
  44311. }
  44312. /**
  44313. * Define the code related to the clear coat parameters of the pbr material.
  44314. */
  44315. export class PBRClearCoatConfiguration {
  44316. /**
  44317. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44318. * The default fits with a polyurethane material.
  44319. */
  44320. private static readonly _DefaultIndiceOfRefraction;
  44321. private _isEnabled;
  44322. /**
  44323. * Defines if the clear coat is enabled in the material.
  44324. */
  44325. isEnabled: boolean;
  44326. /**
  44327. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44328. */
  44329. intensity: number;
  44330. /**
  44331. * Defines the clear coat layer roughness.
  44332. */
  44333. roughness: number;
  44334. private _indiceOfRefraction;
  44335. /**
  44336. * Defines the indice of refraction of the clear coat.
  44337. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44338. * The default fits with a polyurethane material.
  44339. * Changing the default value is more performance intensive.
  44340. */
  44341. indiceOfRefraction: number;
  44342. private _texture;
  44343. /**
  44344. * Stores the clear coat values in a texture.
  44345. */
  44346. texture: Nullable<BaseTexture>;
  44347. private _bumpTexture;
  44348. /**
  44349. * Define the clear coat specific bump texture.
  44350. */
  44351. bumpTexture: Nullable<BaseTexture>;
  44352. private _isTintEnabled;
  44353. /**
  44354. * Defines if the clear coat tint is enabled in the material.
  44355. */
  44356. isTintEnabled: boolean;
  44357. /**
  44358. * Defines if the clear coat tint is enabled in the material.
  44359. * This is only use if tint is enabled
  44360. */
  44361. tintColor: Color3;
  44362. /**
  44363. * Defines if the distance at which the tint color should be found in the
  44364. * clear coat media.
  44365. * This is only use if tint is enabled
  44366. */
  44367. tintColorAtDistance: number;
  44368. /**
  44369. * Defines the clear coat layer thickness.
  44370. * This is only use if tint is enabled
  44371. */
  44372. tintThickness: number;
  44373. private _tintTexture;
  44374. /**
  44375. * Stores the clear tint values in a texture.
  44376. * rgb is tint
  44377. * a is a thickness factor
  44378. */
  44379. tintTexture: Nullable<BaseTexture>;
  44380. /** @hidden */
  44381. private _internalMarkAllSubMeshesAsTexturesDirty;
  44382. /** @hidden */
  44383. _markAllSubMeshesAsTexturesDirty(): void;
  44384. /**
  44385. * Instantiate a new istance of clear coat configuration.
  44386. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44387. */
  44388. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44389. /**
  44390. * Specifies that the submesh is ready to be used.
  44391. * @param defines the list of "defines" to update.
  44392. * @param scene defines the scene the material belongs to.
  44393. * @param engine defines the engine the material belongs to.
  44394. * @param disableBumpMap defines wether the material disables bump or not.
  44395. * @returns - boolean indicating that the submesh is ready or not.
  44396. */
  44397. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44398. /**
  44399. * Checks to see if a texture is used in the material.
  44400. * @param defines the list of "defines" to update.
  44401. * @param scene defines the scene to the material belongs to.
  44402. */
  44403. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44404. /**
  44405. * Binds the material data.
  44406. * @param uniformBuffer defines the Uniform buffer to fill in.
  44407. * @param scene defines the scene the material belongs to.
  44408. * @param engine defines the engine the material belongs to.
  44409. * @param disableBumpMap defines wether the material disables bump or not.
  44410. * @param isFrozen defines wether the material is frozen or not.
  44411. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44412. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44413. */
  44414. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44415. /**
  44416. * Checks to see if a texture is used in the material.
  44417. * @param texture - Base texture to use.
  44418. * @returns - Boolean specifying if a texture is used in the material.
  44419. */
  44420. hasTexture(texture: BaseTexture): boolean;
  44421. /**
  44422. * Returns an array of the actively used textures.
  44423. * @param activeTextures Array of BaseTextures
  44424. */
  44425. getActiveTextures(activeTextures: BaseTexture[]): void;
  44426. /**
  44427. * Returns the animatable textures.
  44428. * @param animatables Array of animatable textures.
  44429. */
  44430. getAnimatables(animatables: IAnimatable[]): void;
  44431. /**
  44432. * Disposes the resources of the material.
  44433. * @param forceDisposeTextures - Forces the disposal of all textures.
  44434. */
  44435. dispose(forceDisposeTextures?: boolean): void;
  44436. /**
  44437. * Get the current class name of the texture useful for serialization or dynamic coding.
  44438. * @returns "PBRClearCoatConfiguration"
  44439. */
  44440. getClassName(): string;
  44441. /**
  44442. * Add fallbacks to the effect fallbacks list.
  44443. * @param defines defines the Base texture to use.
  44444. * @param fallbacks defines the current fallback list.
  44445. * @param currentRank defines the current fallback rank.
  44446. * @returns the new fallback rank.
  44447. */
  44448. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44449. /**
  44450. * Add the required uniforms to the current list.
  44451. * @param uniforms defines the current uniform list.
  44452. */
  44453. static AddUniforms(uniforms: string[]): void;
  44454. /**
  44455. * Add the required samplers to the current list.
  44456. * @param samplers defines the current sampler list.
  44457. */
  44458. static AddSamplers(samplers: string[]): void;
  44459. /**
  44460. * Add the required uniforms to the current buffer.
  44461. * @param uniformBuffer defines the current uniform buffer.
  44462. */
  44463. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44464. /**
  44465. * Makes a duplicate of the current configuration into another one.
  44466. * @param clearCoatConfiguration define the config where to copy the info
  44467. */
  44468. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44469. /**
  44470. * Serializes this clear coat configuration.
  44471. * @returns - An object with the serialized config.
  44472. */
  44473. serialize(): any;
  44474. /**
  44475. * Parses a Clear Coat Configuration from a serialized object.
  44476. * @param source - Serialized object.
  44477. */
  44478. parse(source: any): void;
  44479. }
  44480. }
  44481. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44482. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44483. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44485. import { Vector2 } from "babylonjs/Maths/math";
  44486. import { Scene } from "babylonjs/scene";
  44487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44488. import { IAnimatable } from "babylonjs/Misc/tools";
  44489. import { Nullable } from "babylonjs/types";
  44490. /**
  44491. * @hidden
  44492. */
  44493. export interface IMaterialAnisotropicDefines {
  44494. ANISOTROPIC: boolean;
  44495. ANISOTROPIC_TEXTURE: boolean;
  44496. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44497. MAINUV1: boolean;
  44498. _areTexturesDirty: boolean;
  44499. _needUVs: boolean;
  44500. }
  44501. /**
  44502. * Define the code related to the anisotropic parameters of the pbr material.
  44503. */
  44504. export class PBRAnisotropicConfiguration {
  44505. private _isEnabled;
  44506. /**
  44507. * Defines if the anisotropy is enabled in the material.
  44508. */
  44509. isEnabled: boolean;
  44510. /**
  44511. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44512. */
  44513. intensity: number;
  44514. /**
  44515. * Defines if the effect is along the tangents, bitangents or in between.
  44516. * By default, the effect is "strectching" the highlights along the tangents.
  44517. */
  44518. direction: Vector2;
  44519. private _texture;
  44520. /**
  44521. * Stores the anisotropy values in a texture.
  44522. * rg is direction (like normal from -1 to 1)
  44523. * b is a intensity
  44524. */
  44525. texture: Nullable<BaseTexture>;
  44526. /** @hidden */
  44527. private _internalMarkAllSubMeshesAsTexturesDirty;
  44528. /** @hidden */
  44529. _markAllSubMeshesAsTexturesDirty(): void;
  44530. /**
  44531. * Instantiate a new istance of anisotropy configuration.
  44532. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44533. */
  44534. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44535. /**
  44536. * Specifies that the submesh is ready to be used.
  44537. * @param defines the list of "defines" to update.
  44538. * @param scene defines the scene the material belongs to.
  44539. * @returns - boolean indicating that the submesh is ready or not.
  44540. */
  44541. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44542. /**
  44543. * Checks to see if a texture is used in the material.
  44544. * @param defines the list of "defines" to update.
  44545. * @param mesh the mesh we are preparing the defines for.
  44546. * @param scene defines the scene the material belongs to.
  44547. */
  44548. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44549. /**
  44550. * Binds the material data.
  44551. * @param uniformBuffer defines the Uniform buffer to fill in.
  44552. * @param scene defines the scene the material belongs to.
  44553. * @param isFrozen defines wether the material is frozen or not.
  44554. */
  44555. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44556. /**
  44557. * Checks to see if a texture is used in the material.
  44558. * @param texture - Base texture to use.
  44559. * @returns - Boolean specifying if a texture is used in the material.
  44560. */
  44561. hasTexture(texture: BaseTexture): boolean;
  44562. /**
  44563. * Returns an array of the actively used textures.
  44564. * @param activeTextures Array of BaseTextures
  44565. */
  44566. getActiveTextures(activeTextures: BaseTexture[]): void;
  44567. /**
  44568. * Returns the animatable textures.
  44569. * @param animatables Array of animatable textures.
  44570. */
  44571. getAnimatables(animatables: IAnimatable[]): void;
  44572. /**
  44573. * Disposes the resources of the material.
  44574. * @param forceDisposeTextures - Forces the disposal of all textures.
  44575. */
  44576. dispose(forceDisposeTextures?: boolean): void;
  44577. /**
  44578. * Get the current class name of the texture useful for serialization or dynamic coding.
  44579. * @returns "PBRAnisotropicConfiguration"
  44580. */
  44581. getClassName(): string;
  44582. /**
  44583. * Add fallbacks to the effect fallbacks list.
  44584. * @param defines defines the Base texture to use.
  44585. * @param fallbacks defines the current fallback list.
  44586. * @param currentRank defines the current fallback rank.
  44587. * @returns the new fallback rank.
  44588. */
  44589. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44590. /**
  44591. * Add the required uniforms to the current list.
  44592. * @param uniforms defines the current uniform list.
  44593. */
  44594. static AddUniforms(uniforms: string[]): void;
  44595. /**
  44596. * Add the required uniforms to the current buffer.
  44597. * @param uniformBuffer defines the current uniform buffer.
  44598. */
  44599. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44600. /**
  44601. * Add the required samplers to the current list.
  44602. * @param samplers defines the current sampler list.
  44603. */
  44604. static AddSamplers(samplers: string[]): void;
  44605. /**
  44606. * Makes a duplicate of the current configuration into another one.
  44607. * @param anisotropicConfiguration define the config where to copy the info
  44608. */
  44609. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44610. /**
  44611. * Serializes this anisotropy configuration.
  44612. * @returns - An object with the serialized config.
  44613. */
  44614. serialize(): any;
  44615. /**
  44616. * Parses a anisotropy Configuration from a serialized object.
  44617. * @param source - Serialized object.
  44618. */
  44619. parse(source: any): void;
  44620. }
  44621. }
  44622. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44623. /**
  44624. * @hidden
  44625. */
  44626. export interface IMaterialBRDFDefines {
  44627. BRDF_V_HEIGHT_CORRELATED: boolean;
  44628. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44629. /** @hidden */
  44630. _areMiscDirty: boolean;
  44631. }
  44632. /**
  44633. * Define the code related to the BRDF parameters of the pbr material.
  44634. */
  44635. export class PBRBRDFConfiguration {
  44636. private _useEnergyConservation;
  44637. /**
  44638. * Defines if the material uses energy conservation.
  44639. */
  44640. useEnergyConservation: boolean;
  44641. private _useSmithVisibilityHeightCorrelated;
  44642. /**
  44643. * LEGACY Mode set to false
  44644. * Defines if the material uses height smith correlated visibility term.
  44645. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44646. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44647. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44648. * Not relying on height correlated will also disable energy conservation.
  44649. */
  44650. useSmithVisibilityHeightCorrelated: boolean;
  44651. /** @hidden */
  44652. private _internalMarkAllSubMeshesAsMiscDirty;
  44653. /** @hidden */
  44654. _markAllSubMeshesAsMiscDirty(): void;
  44655. /**
  44656. * Instantiate a new istance of clear coat configuration.
  44657. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44658. */
  44659. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44660. /**
  44661. * Checks to see if a texture is used in the material.
  44662. * @param defines the list of "defines" to update.
  44663. */
  44664. prepareDefines(defines: IMaterialBRDFDefines): void;
  44665. /**
  44666. * Get the current class name of the texture useful for serialization or dynamic coding.
  44667. * @returns "PBRClearCoatConfiguration"
  44668. */
  44669. getClassName(): string;
  44670. /**
  44671. * Makes a duplicate of the current configuration into another one.
  44672. * @param brdfConfiguration define the config where to copy the info
  44673. */
  44674. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44675. /**
  44676. * Serializes this BRDF configuration.
  44677. * @returns - An object with the serialized config.
  44678. */
  44679. serialize(): any;
  44680. /**
  44681. * Parses a BRDF Configuration from a serialized object.
  44682. * @param source - Serialized object.
  44683. */
  44684. parse(source: any): void;
  44685. }
  44686. }
  44687. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  44688. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44689. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44690. import { Color3 } from "babylonjs/Maths/math";
  44691. import { Scene } from "babylonjs/scene";
  44692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44693. import { IAnimatable } from "babylonjs/Misc/tools";
  44694. import { Nullable } from "babylonjs/types";
  44695. /**
  44696. * @hidden
  44697. */
  44698. export interface IMaterialSheenDefines {
  44699. SHEEN: boolean;
  44700. SHEEN_TEXTURE: boolean;
  44701. SHEEN_TEXTUREDIRECTUV: number;
  44702. SHEEN_LINKWITHALBEDO: boolean;
  44703. /** @hidden */
  44704. _areTexturesDirty: boolean;
  44705. }
  44706. /**
  44707. * Define the code related to the Sheen parameters of the pbr material.
  44708. */
  44709. export class PBRSheenConfiguration {
  44710. private _isEnabled;
  44711. /**
  44712. * Defines if the material uses sheen.
  44713. */
  44714. isEnabled: boolean;
  44715. private _linkSheenWithAlbedo;
  44716. /**
  44717. * Defines if the sheen is linked to the sheen color.
  44718. */
  44719. linkSheenWithAlbedo: boolean;
  44720. /**
  44721. * Defines the sheen intensity.
  44722. */
  44723. intensity: number;
  44724. /**
  44725. * Defines the sheen color.
  44726. */
  44727. color: Color3;
  44728. private _texture;
  44729. /**
  44730. * Stores the sheen tint values in a texture.
  44731. * rgb is tint
  44732. * a is a intensity
  44733. */
  44734. texture: Nullable<BaseTexture>;
  44735. /** @hidden */
  44736. private _internalMarkAllSubMeshesAsTexturesDirty;
  44737. /** @hidden */
  44738. _markAllSubMeshesAsTexturesDirty(): void;
  44739. /**
  44740. * Instantiate a new istance of clear coat configuration.
  44741. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44742. */
  44743. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44744. /**
  44745. * Specifies that the submesh is ready to be used.
  44746. * @param defines the list of "defines" to update.
  44747. * @param scene defines the scene the material belongs to.
  44748. * @returns - boolean indicating that the submesh is ready or not.
  44749. */
  44750. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44751. /**
  44752. * Checks to see if a texture is used in the material.
  44753. * @param defines the list of "defines" to update.
  44754. * @param scene defines the scene the material belongs to.
  44755. */
  44756. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44757. /**
  44758. * Binds the material data.
  44759. * @param uniformBuffer defines the Uniform buffer to fill in.
  44760. * @param scene defines the scene the material belongs to.
  44761. * @param isFrozen defines wether the material is frozen or not.
  44762. */
  44763. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44764. /**
  44765. * Checks to see if a texture is used in the material.
  44766. * @param texture - Base texture to use.
  44767. * @returns - Boolean specifying if a texture is used in the material.
  44768. */
  44769. hasTexture(texture: BaseTexture): boolean;
  44770. /**
  44771. * Returns an array of the actively used textures.
  44772. * @param activeTextures Array of BaseTextures
  44773. */
  44774. getActiveTextures(activeTextures: BaseTexture[]): void;
  44775. /**
  44776. * Returns the animatable textures.
  44777. * @param animatables Array of animatable textures.
  44778. */
  44779. getAnimatables(animatables: IAnimatable[]): void;
  44780. /**
  44781. * Disposes the resources of the material.
  44782. * @param forceDisposeTextures - Forces the disposal of all textures.
  44783. */
  44784. dispose(forceDisposeTextures?: boolean): void;
  44785. /**
  44786. * Get the current class name of the texture useful for serialization or dynamic coding.
  44787. * @returns "PBRSheenConfiguration"
  44788. */
  44789. getClassName(): string;
  44790. /**
  44791. * Add fallbacks to the effect fallbacks list.
  44792. * @param defines defines the Base texture to use.
  44793. * @param fallbacks defines the current fallback list.
  44794. * @param currentRank defines the current fallback rank.
  44795. * @returns the new fallback rank.
  44796. */
  44797. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44798. /**
  44799. * Add the required uniforms to the current list.
  44800. * @param uniforms defines the current uniform list.
  44801. */
  44802. static AddUniforms(uniforms: string[]): void;
  44803. /**
  44804. * Add the required uniforms to the current buffer.
  44805. * @param uniformBuffer defines the current uniform buffer.
  44806. */
  44807. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44808. /**
  44809. * Add the required samplers to the current list.
  44810. * @param samplers defines the current sampler list.
  44811. */
  44812. static AddSamplers(samplers: string[]): void;
  44813. /**
  44814. * Makes a duplicate of the current configuration into another one.
  44815. * @param sheenConfiguration define the config where to copy the info
  44816. */
  44817. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44818. /**
  44819. * Serializes this BRDF configuration.
  44820. * @returns - An object with the serialized config.
  44821. */
  44822. serialize(): any;
  44823. /**
  44824. * Parses a Sheen Configuration from a serialized object.
  44825. * @param source - Serialized object.
  44826. */
  44827. parse(source: any): void;
  44828. }
  44829. }
  44830. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44831. /** @hidden */
  44832. export var pbrFragmentDeclaration: {
  44833. name: string;
  44834. shader: string;
  44835. };
  44836. }
  44837. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44838. /** @hidden */
  44839. export var pbrUboDeclaration: {
  44840. name: string;
  44841. shader: string;
  44842. };
  44843. }
  44844. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44845. /** @hidden */
  44846. export var pbrFunctions: {
  44847. name: string;
  44848. shader: string;
  44849. };
  44850. }
  44851. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44852. /** @hidden */
  44853. export var harmonicsFunctions: {
  44854. name: string;
  44855. shader: string;
  44856. };
  44857. }
  44858. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44859. /** @hidden */
  44860. export var pbrPreLightingFunctions: {
  44861. name: string;
  44862. shader: string;
  44863. };
  44864. }
  44865. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44866. /** @hidden */
  44867. export var pbrFalloffLightingFunctions: {
  44868. name: string;
  44869. shader: string;
  44870. };
  44871. }
  44872. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44873. /** @hidden */
  44874. export var pbrLightingFunctions: {
  44875. name: string;
  44876. shader: string;
  44877. };
  44878. }
  44879. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44880. /** @hidden */
  44881. export var pbrDebug: {
  44882. name: string;
  44883. shader: string;
  44884. };
  44885. }
  44886. declare module "babylonjs/Shaders/pbr.fragment" {
  44887. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44888. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44889. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44890. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44891. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44892. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44893. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44894. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44895. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44896. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44897. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44898. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44899. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44900. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44901. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44902. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44903. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44904. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44905. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44906. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44907. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44908. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44909. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44910. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44911. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  44912. /** @hidden */
  44913. export var pbrPixelShader: {
  44914. name: string;
  44915. shader: string;
  44916. };
  44917. }
  44918. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44919. /** @hidden */
  44920. export var pbrVertexDeclaration: {
  44921. name: string;
  44922. shader: string;
  44923. };
  44924. }
  44925. declare module "babylonjs/Shaders/pbr.vertex" {
  44926. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44927. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44928. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44929. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44930. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44931. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44932. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44933. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44934. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44935. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44936. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44937. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44938. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44939. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44940. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44941. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44942. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44943. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44944. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44945. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44946. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44947. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44948. /** @hidden */
  44949. export var pbrVertexShader: {
  44950. name: string;
  44951. shader: string;
  44952. };
  44953. }
  44954. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44955. import { IAnimatable } from "babylonjs/Misc/tools";
  44956. import { Nullable } from "babylonjs/types";
  44957. import { Scene } from "babylonjs/scene";
  44958. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44959. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44961. import { Mesh } from "babylonjs/Meshes/mesh";
  44962. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44963. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44964. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44965. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  44966. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44967. import { Material } from "babylonjs/Materials/material";
  44968. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44970. import "babylonjs/Shaders/pbr.fragment";
  44971. import "babylonjs/Shaders/pbr.vertex";
  44972. /**
  44973. * The Physically based material base class of BJS.
  44974. *
  44975. * This offers the main features of a standard PBR material.
  44976. * For more information, please refer to the documentation :
  44977. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44978. */
  44979. export abstract class PBRBaseMaterial extends PushMaterial {
  44980. /**
  44981. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44982. */
  44983. static readonly PBRMATERIAL_OPAQUE: number;
  44984. /**
  44985. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44986. */
  44987. static readonly PBRMATERIAL_ALPHATEST: number;
  44988. /**
  44989. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44990. */
  44991. static readonly PBRMATERIAL_ALPHABLEND: number;
  44992. /**
  44993. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44994. * They are also discarded below the alpha cutoff threshold to improve performances.
  44995. */
  44996. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44997. /**
  44998. * Defines the default value of how much AO map is occluding the analytical lights
  44999. * (point spot...).
  45000. */
  45001. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45002. /**
  45003. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45004. */
  45005. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45006. /**
  45007. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45008. * to enhance interoperability with other engines.
  45009. */
  45010. static readonly LIGHTFALLOFF_GLTF: number;
  45011. /**
  45012. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45013. * to enhance interoperability with other materials.
  45014. */
  45015. static readonly LIGHTFALLOFF_STANDARD: number;
  45016. /**
  45017. * Intensity of the direct lights e.g. the four lights available in your scene.
  45018. * This impacts both the direct diffuse and specular highlights.
  45019. */
  45020. protected _directIntensity: number;
  45021. /**
  45022. * Intensity of the emissive part of the material.
  45023. * This helps controlling the emissive effect without modifying the emissive color.
  45024. */
  45025. protected _emissiveIntensity: number;
  45026. /**
  45027. * Intensity of the environment e.g. how much the environment will light the object
  45028. * either through harmonics for rough material or through the refelction for shiny ones.
  45029. */
  45030. protected _environmentIntensity: number;
  45031. /**
  45032. * This is a special control allowing the reduction of the specular highlights coming from the
  45033. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45034. */
  45035. protected _specularIntensity: number;
  45036. /**
  45037. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45038. */
  45039. private _lightingInfos;
  45040. /**
  45041. * Debug Control allowing disabling the bump map on this material.
  45042. */
  45043. protected _disableBumpMap: boolean;
  45044. /**
  45045. * AKA Diffuse Texture in standard nomenclature.
  45046. */
  45047. protected _albedoTexture: BaseTexture;
  45048. /**
  45049. * AKA Occlusion Texture in other nomenclature.
  45050. */
  45051. protected _ambientTexture: BaseTexture;
  45052. /**
  45053. * AKA Occlusion Texture Intensity in other nomenclature.
  45054. */
  45055. protected _ambientTextureStrength: number;
  45056. /**
  45057. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45058. * 1 means it completely occludes it
  45059. * 0 mean it has no impact
  45060. */
  45061. protected _ambientTextureImpactOnAnalyticalLights: number;
  45062. /**
  45063. * Stores the alpha values in a texture.
  45064. */
  45065. protected _opacityTexture: BaseTexture;
  45066. /**
  45067. * Stores the reflection values in a texture.
  45068. */
  45069. protected _reflectionTexture: BaseTexture;
  45070. /**
  45071. * Stores the refraction values in a texture.
  45072. */
  45073. protected _refractionTexture: BaseTexture;
  45074. /**
  45075. * Stores the emissive values in a texture.
  45076. */
  45077. protected _emissiveTexture: BaseTexture;
  45078. /**
  45079. * AKA Specular texture in other nomenclature.
  45080. */
  45081. protected _reflectivityTexture: BaseTexture;
  45082. /**
  45083. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45084. */
  45085. protected _metallicTexture: BaseTexture;
  45086. /**
  45087. * Specifies the metallic scalar of the metallic/roughness workflow.
  45088. * Can also be used to scale the metalness values of the metallic texture.
  45089. */
  45090. protected _metallic: Nullable<number>;
  45091. /**
  45092. * Specifies the roughness scalar of the metallic/roughness workflow.
  45093. * Can also be used to scale the roughness values of the metallic texture.
  45094. */
  45095. protected _roughness: Nullable<number>;
  45096. /**
  45097. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45098. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45099. */
  45100. protected _microSurfaceTexture: BaseTexture;
  45101. /**
  45102. * Stores surface normal data used to displace a mesh in a texture.
  45103. */
  45104. protected _bumpTexture: BaseTexture;
  45105. /**
  45106. * Stores the pre-calculated light information of a mesh in a texture.
  45107. */
  45108. protected _lightmapTexture: BaseTexture;
  45109. /**
  45110. * The color of a material in ambient lighting.
  45111. */
  45112. protected _ambientColor: Color3;
  45113. /**
  45114. * AKA Diffuse Color in other nomenclature.
  45115. */
  45116. protected _albedoColor: Color3;
  45117. /**
  45118. * AKA Specular Color in other nomenclature.
  45119. */
  45120. protected _reflectivityColor: Color3;
  45121. /**
  45122. * The color applied when light is reflected from a material.
  45123. */
  45124. protected _reflectionColor: Color3;
  45125. /**
  45126. * The color applied when light is emitted from a material.
  45127. */
  45128. protected _emissiveColor: Color3;
  45129. /**
  45130. * AKA Glossiness in other nomenclature.
  45131. */
  45132. protected _microSurface: number;
  45133. /**
  45134. * source material index of refraction (IOR)' / 'destination material IOR.
  45135. */
  45136. protected _indexOfRefraction: number;
  45137. /**
  45138. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45139. */
  45140. protected _invertRefractionY: boolean;
  45141. /**
  45142. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45143. * Materials half opaque for instance using refraction could benefit from this control.
  45144. */
  45145. protected _linkRefractionWithTransparency: boolean;
  45146. /**
  45147. * Specifies that the material will use the light map as a show map.
  45148. */
  45149. protected _useLightmapAsShadowmap: boolean;
  45150. /**
  45151. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45152. * makes the reflect vector face the model (under horizon).
  45153. */
  45154. protected _useHorizonOcclusion: boolean;
  45155. /**
  45156. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45157. * too much the area relying on ambient texture to define their ambient occlusion.
  45158. */
  45159. protected _useRadianceOcclusion: boolean;
  45160. /**
  45161. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45162. */
  45163. protected _useAlphaFromAlbedoTexture: boolean;
  45164. /**
  45165. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45166. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45167. */
  45168. protected _useSpecularOverAlpha: boolean;
  45169. /**
  45170. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45171. */
  45172. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45173. /**
  45174. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45175. */
  45176. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45177. /**
  45178. * Specifies if the metallic texture contains the roughness information in its green channel.
  45179. */
  45180. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45181. /**
  45182. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45183. */
  45184. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45185. /**
  45186. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45187. */
  45188. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45189. /**
  45190. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45191. */
  45192. protected _useAmbientInGrayScale: boolean;
  45193. /**
  45194. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45195. * The material will try to infer what glossiness each pixel should be.
  45196. */
  45197. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45198. /**
  45199. * Defines the falloff type used in this material.
  45200. * It by default is Physical.
  45201. */
  45202. protected _lightFalloff: number;
  45203. /**
  45204. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45205. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45206. */
  45207. protected _useRadianceOverAlpha: boolean;
  45208. /**
  45209. * Allows using an object space normal map (instead of tangent space).
  45210. */
  45211. protected _useObjectSpaceNormalMap: boolean;
  45212. /**
  45213. * Allows using the bump map in parallax mode.
  45214. */
  45215. protected _useParallax: boolean;
  45216. /**
  45217. * Allows using the bump map in parallax occlusion mode.
  45218. */
  45219. protected _useParallaxOcclusion: boolean;
  45220. /**
  45221. * Controls the scale bias of the parallax mode.
  45222. */
  45223. protected _parallaxScaleBias: number;
  45224. /**
  45225. * If sets to true, disables all the lights affecting the material.
  45226. */
  45227. protected _disableLighting: boolean;
  45228. /**
  45229. * Number of Simultaneous lights allowed on the material.
  45230. */
  45231. protected _maxSimultaneousLights: number;
  45232. /**
  45233. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45234. */
  45235. protected _invertNormalMapX: boolean;
  45236. /**
  45237. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45238. */
  45239. protected _invertNormalMapY: boolean;
  45240. /**
  45241. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45242. */
  45243. protected _twoSidedLighting: boolean;
  45244. /**
  45245. * Defines the alpha limits in alpha test mode.
  45246. */
  45247. protected _alphaCutOff: number;
  45248. /**
  45249. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45250. */
  45251. protected _forceAlphaTest: 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 is converted to gamma to compute the fresnel)
  45255. */
  45256. protected _useAlphaFresnel: boolean;
  45257. /**
  45258. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45259. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45260. */
  45261. protected _useLinearAlphaFresnel: boolean;
  45262. /**
  45263. * The transparency mode of the material.
  45264. */
  45265. protected _transparencyMode: Nullable<number>;
  45266. /**
  45267. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45268. * from cos thetav and roughness:
  45269. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45270. */
  45271. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45272. /**
  45273. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45274. */
  45275. protected _forceIrradianceInFragment: boolean;
  45276. /**
  45277. * Force normal to face away from face.
  45278. */
  45279. protected _forceNormalForward: boolean;
  45280. /**
  45281. * Enables specular anti aliasing in the PBR shader.
  45282. * It will both interacts on the Geometry for analytical and IBL lighting.
  45283. * It also prefilter the roughness map based on the bump values.
  45284. */
  45285. protected _enableSpecularAntiAliasing: boolean;
  45286. /**
  45287. * Default configuration related to image processing available in the PBR Material.
  45288. */
  45289. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45290. /**
  45291. * Keep track of the image processing observer to allow dispose and replace.
  45292. */
  45293. private _imageProcessingObserver;
  45294. /**
  45295. * Attaches a new image processing configuration to the PBR Material.
  45296. * @param configuration
  45297. */
  45298. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45299. /**
  45300. * Stores the available render targets.
  45301. */
  45302. private _renderTargets;
  45303. /**
  45304. * Sets the global ambient color for the material used in lighting calculations.
  45305. */
  45306. private _globalAmbientColor;
  45307. /**
  45308. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45309. */
  45310. private _useLogarithmicDepth;
  45311. /**
  45312. * If set to true, no lighting calculations will be applied.
  45313. */
  45314. private _unlit;
  45315. private _debugMode;
  45316. /**
  45317. * @hidden
  45318. * This is reserved for the inspector.
  45319. * Defines the material debug mode.
  45320. * It helps seeing only some components of the material while troubleshooting.
  45321. */
  45322. debugMode: number;
  45323. /**
  45324. * @hidden
  45325. * This is reserved for the inspector.
  45326. * Specify from where on screen the debug mode should start.
  45327. * The value goes from -1 (full screen) to 1 (not visible)
  45328. * It helps with side by side comparison against the final render
  45329. * This defaults to -1
  45330. */
  45331. private debugLimit;
  45332. /**
  45333. * @hidden
  45334. * This is reserved for the inspector.
  45335. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45336. * You can use the factor to better multiply the final value.
  45337. */
  45338. private debugFactor;
  45339. /**
  45340. * Defines the clear coat layer parameters for the material.
  45341. */
  45342. readonly clearCoat: PBRClearCoatConfiguration;
  45343. /**
  45344. * Defines the anisotropic parameters for the material.
  45345. */
  45346. readonly anisotropy: PBRAnisotropicConfiguration;
  45347. /**
  45348. * Defines the BRDF parameters for the material.
  45349. */
  45350. readonly brdf: PBRBRDFConfiguration;
  45351. /**
  45352. * Defines the Sheen parameters for the material.
  45353. */
  45354. readonly sheen: PBRSheenConfiguration;
  45355. /**
  45356. * Instantiates a new PBRMaterial instance.
  45357. *
  45358. * @param name The material name
  45359. * @param scene The scene the material will be use in.
  45360. */
  45361. constructor(name: string, scene: Scene);
  45362. /**
  45363. * Gets a boolean indicating that current material needs to register RTT
  45364. */
  45365. readonly hasRenderTargetTextures: boolean;
  45366. /**
  45367. * Gets the name of the material class.
  45368. */
  45369. getClassName(): string;
  45370. /**
  45371. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45372. */
  45373. /**
  45374. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45375. */
  45376. useLogarithmicDepth: boolean;
  45377. /**
  45378. * Gets the current transparency mode.
  45379. */
  45380. /**
  45381. * Sets the transparency mode of the material.
  45382. *
  45383. * | Value | Type | Description |
  45384. * | ----- | ----------------------------------- | ----------- |
  45385. * | 0 | OPAQUE | |
  45386. * | 1 | ALPHATEST | |
  45387. * | 2 | ALPHABLEND | |
  45388. * | 3 | ALPHATESTANDBLEND | |
  45389. *
  45390. */
  45391. transparencyMode: Nullable<number>;
  45392. /**
  45393. * Returns true if alpha blending should be disabled.
  45394. */
  45395. private readonly _disableAlphaBlending;
  45396. /**
  45397. * Specifies whether or not this material should be rendered in alpha blend mode.
  45398. */
  45399. needAlphaBlending(): boolean;
  45400. /**
  45401. * Specifies if the mesh will require alpha blending.
  45402. * @param mesh - BJS mesh.
  45403. */
  45404. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45405. /**
  45406. * Specifies whether or not this material should be rendered in alpha test mode.
  45407. */
  45408. needAlphaTesting(): boolean;
  45409. /**
  45410. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45411. */
  45412. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45413. /**
  45414. * Gets the texture used for the alpha test.
  45415. */
  45416. getAlphaTestTexture(): BaseTexture;
  45417. /**
  45418. * Specifies that the submesh is ready to be used.
  45419. * @param mesh - BJS mesh.
  45420. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45421. * @param useInstances - Specifies that instances should be used.
  45422. * @returns - boolean indicating that the submesh is ready or not.
  45423. */
  45424. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45425. /**
  45426. * Specifies if the material uses metallic roughness workflow.
  45427. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45428. */
  45429. isMetallicWorkflow(): boolean;
  45430. private _prepareEffect;
  45431. private _prepareDefines;
  45432. /**
  45433. * Force shader compilation
  45434. */
  45435. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45436. clipPlane: boolean;
  45437. }>): void;
  45438. /**
  45439. * Initializes the uniform buffer layout for the shader.
  45440. */
  45441. buildUniformLayout(): void;
  45442. /**
  45443. * Unbinds the textures.
  45444. */
  45445. unbind(): void;
  45446. /**
  45447. * Binds the submesh data.
  45448. * @param world - The world matrix.
  45449. * @param mesh - The BJS mesh.
  45450. * @param subMesh - A submesh of the BJS mesh.
  45451. */
  45452. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45453. /**
  45454. * Returns the animatable textures.
  45455. * @returns - Array of animatable textures.
  45456. */
  45457. getAnimatables(): IAnimatable[];
  45458. /**
  45459. * Returns the texture used for reflections.
  45460. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45461. */
  45462. private _getReflectionTexture;
  45463. /**
  45464. * Returns the texture used for refraction or null if none is used.
  45465. * @returns - Refection texture if present. If no refraction texture and refraction
  45466. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45467. */
  45468. private _getRefractionTexture;
  45469. /**
  45470. * Returns an array of the actively used textures.
  45471. * @returns - Array of BaseTextures
  45472. */
  45473. getActiveTextures(): BaseTexture[];
  45474. /**
  45475. * Checks to see if a texture is used in the material.
  45476. * @param texture - Base texture to use.
  45477. * @returns - Boolean specifying if a texture is used in the material.
  45478. */
  45479. hasTexture(texture: BaseTexture): boolean;
  45480. /**
  45481. * Disposes the resources of the material.
  45482. * @param forceDisposeEffect - Forces the disposal of effects.
  45483. * @param forceDisposeTextures - Forces the disposal of all textures.
  45484. */
  45485. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45486. }
  45487. }
  45488. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45489. import { Nullable } from "babylonjs/types";
  45490. import { Scene } from "babylonjs/scene";
  45491. import { Color3 } from "babylonjs/Maths/math";
  45492. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45493. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45494. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45495. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45496. /**
  45497. * The Physically based material of BJS.
  45498. *
  45499. * This offers the main features of a standard PBR material.
  45500. * For more information, please refer to the documentation :
  45501. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45502. */
  45503. export class PBRMaterial extends PBRBaseMaterial {
  45504. /**
  45505. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45506. */
  45507. static readonly PBRMATERIAL_OPAQUE: number;
  45508. /**
  45509. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45510. */
  45511. static readonly PBRMATERIAL_ALPHATEST: number;
  45512. /**
  45513. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45514. */
  45515. static readonly PBRMATERIAL_ALPHABLEND: number;
  45516. /**
  45517. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45518. * They are also discarded below the alpha cutoff threshold to improve performances.
  45519. */
  45520. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45521. /**
  45522. * Defines the default value of how much AO map is occluding the analytical lights
  45523. * (point spot...).
  45524. */
  45525. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45526. /**
  45527. * Intensity of the direct lights e.g. the four lights available in your scene.
  45528. * This impacts both the direct diffuse and specular highlights.
  45529. */
  45530. directIntensity: number;
  45531. /**
  45532. * Intensity of the emissive part of the material.
  45533. * This helps controlling the emissive effect without modifying the emissive color.
  45534. */
  45535. emissiveIntensity: number;
  45536. /**
  45537. * Intensity of the environment e.g. how much the environment will light the object
  45538. * either through harmonics for rough material or through the refelction for shiny ones.
  45539. */
  45540. environmentIntensity: number;
  45541. /**
  45542. * This is a special control allowing the reduction of the specular highlights coming from the
  45543. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45544. */
  45545. specularIntensity: number;
  45546. /**
  45547. * Debug Control allowing disabling the bump map on this material.
  45548. */
  45549. disableBumpMap: boolean;
  45550. /**
  45551. * AKA Diffuse Texture in standard nomenclature.
  45552. */
  45553. albedoTexture: BaseTexture;
  45554. /**
  45555. * AKA Occlusion Texture in other nomenclature.
  45556. */
  45557. ambientTexture: BaseTexture;
  45558. /**
  45559. * AKA Occlusion Texture Intensity in other nomenclature.
  45560. */
  45561. ambientTextureStrength: number;
  45562. /**
  45563. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45564. * 1 means it completely occludes it
  45565. * 0 mean it has no impact
  45566. */
  45567. ambientTextureImpactOnAnalyticalLights: number;
  45568. /**
  45569. * Stores the alpha values in a texture.
  45570. */
  45571. opacityTexture: BaseTexture;
  45572. /**
  45573. * Stores the reflection values in a texture.
  45574. */
  45575. reflectionTexture: Nullable<BaseTexture>;
  45576. /**
  45577. * Stores the emissive values in a texture.
  45578. */
  45579. emissiveTexture: BaseTexture;
  45580. /**
  45581. * AKA Specular texture in other nomenclature.
  45582. */
  45583. reflectivityTexture: BaseTexture;
  45584. /**
  45585. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45586. */
  45587. metallicTexture: BaseTexture;
  45588. /**
  45589. * Specifies the metallic scalar of the metallic/roughness workflow.
  45590. * Can also be used to scale the metalness values of the metallic texture.
  45591. */
  45592. metallic: Nullable<number>;
  45593. /**
  45594. * Specifies the roughness scalar of the metallic/roughness workflow.
  45595. * Can also be used to scale the roughness values of the metallic texture.
  45596. */
  45597. roughness: Nullable<number>;
  45598. /**
  45599. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45600. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45601. */
  45602. microSurfaceTexture: BaseTexture;
  45603. /**
  45604. * Stores surface normal data used to displace a mesh in a texture.
  45605. */
  45606. bumpTexture: BaseTexture;
  45607. /**
  45608. * Stores the pre-calculated light information of a mesh in a texture.
  45609. */
  45610. lightmapTexture: BaseTexture;
  45611. /**
  45612. * Stores the refracted light information in a texture.
  45613. */
  45614. refractionTexture: BaseTexture;
  45615. /**
  45616. * The color of a material in ambient lighting.
  45617. */
  45618. ambientColor: Color3;
  45619. /**
  45620. * AKA Diffuse Color in other nomenclature.
  45621. */
  45622. albedoColor: Color3;
  45623. /**
  45624. * AKA Specular Color in other nomenclature.
  45625. */
  45626. reflectivityColor: Color3;
  45627. /**
  45628. * The color reflected from the material.
  45629. */
  45630. reflectionColor: Color3;
  45631. /**
  45632. * The color emitted from the material.
  45633. */
  45634. emissiveColor: Color3;
  45635. /**
  45636. * AKA Glossiness in other nomenclature.
  45637. */
  45638. microSurface: number;
  45639. /**
  45640. * source material index of refraction (IOR)' / 'destination material IOR.
  45641. */
  45642. indexOfRefraction: number;
  45643. /**
  45644. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45645. */
  45646. invertRefractionY: boolean;
  45647. /**
  45648. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45649. * Materials half opaque for instance using refraction could benefit from this control.
  45650. */
  45651. linkRefractionWithTransparency: boolean;
  45652. /**
  45653. * If true, the light map contains occlusion information instead of lighting info.
  45654. */
  45655. useLightmapAsShadowmap: boolean;
  45656. /**
  45657. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45658. */
  45659. useAlphaFromAlbedoTexture: boolean;
  45660. /**
  45661. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45662. */
  45663. forceAlphaTest: boolean;
  45664. /**
  45665. * Defines the alpha limits in alpha test mode.
  45666. */
  45667. alphaCutOff: number;
  45668. /**
  45669. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45670. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45671. */
  45672. useSpecularOverAlpha: boolean;
  45673. /**
  45674. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45675. */
  45676. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45677. /**
  45678. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45679. */
  45680. useRoughnessFromMetallicTextureAlpha: boolean;
  45681. /**
  45682. * Specifies if the metallic texture contains the roughness information in its green channel.
  45683. */
  45684. useRoughnessFromMetallicTextureGreen: boolean;
  45685. /**
  45686. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45687. */
  45688. useMetallnessFromMetallicTextureBlue: boolean;
  45689. /**
  45690. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45691. */
  45692. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45693. /**
  45694. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45695. */
  45696. useAmbientInGrayScale: boolean;
  45697. /**
  45698. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45699. * The material will try to infer what glossiness each pixel should be.
  45700. */
  45701. useAutoMicroSurfaceFromReflectivityMap: boolean;
  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. /**
  45708. * BJS is using an harcoded light falloff based on a manually sets up range.
  45709. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45710. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45711. */
  45712. usePhysicalLightFalloff: boolean;
  45713. /**
  45714. * In order to support the falloff compatibility with gltf, a special mode has been added
  45715. * to reproduce the gltf light falloff.
  45716. */
  45717. /**
  45718. * In order to support the falloff compatibility with gltf, a special mode has been added
  45719. * to reproduce the gltf light falloff.
  45720. */
  45721. useGLTFLightFalloff: boolean;
  45722. /**
  45723. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45724. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45725. */
  45726. useRadianceOverAlpha: boolean;
  45727. /**
  45728. * Allows using an object space normal map (instead of tangent space).
  45729. */
  45730. useObjectSpaceNormalMap: boolean;
  45731. /**
  45732. * Allows using the bump map in parallax mode.
  45733. */
  45734. useParallax: boolean;
  45735. /**
  45736. * Allows using the bump map in parallax occlusion mode.
  45737. */
  45738. useParallaxOcclusion: boolean;
  45739. /**
  45740. * Controls the scale bias of the parallax mode.
  45741. */
  45742. parallaxScaleBias: number;
  45743. /**
  45744. * If sets to true, disables all the lights affecting the material.
  45745. */
  45746. disableLighting: boolean;
  45747. /**
  45748. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45749. */
  45750. forceIrradianceInFragment: boolean;
  45751. /**
  45752. * Number of Simultaneous lights allowed on the material.
  45753. */
  45754. maxSimultaneousLights: number;
  45755. /**
  45756. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45757. */
  45758. invertNormalMapX: boolean;
  45759. /**
  45760. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45761. */
  45762. invertNormalMapY: boolean;
  45763. /**
  45764. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45765. */
  45766. twoSidedLighting: 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 is converted to gamma to compute the fresnel)
  45770. */
  45771. useAlphaFresnel: boolean;
  45772. /**
  45773. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45774. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45775. */
  45776. useLinearAlphaFresnel: boolean;
  45777. /**
  45778. * Let user defines the brdf lookup texture used for IBL.
  45779. * A default 8bit version is embedded but you could point at :
  45780. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45781. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45782. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45783. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45784. */
  45785. environmentBRDFTexture: Nullable<BaseTexture>;
  45786. /**
  45787. * Force normal to face away from face.
  45788. */
  45789. forceNormalForward: boolean;
  45790. /**
  45791. * Enables specular anti aliasing in the PBR shader.
  45792. * It will both interacts on the Geometry for analytical and IBL lighting.
  45793. * It also prefilter the roughness map based on the bump values.
  45794. */
  45795. enableSpecularAntiAliasing: boolean;
  45796. /**
  45797. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45798. * makes the reflect vector face the model (under horizon).
  45799. */
  45800. useHorizonOcclusion: boolean;
  45801. /**
  45802. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45803. * too much the area relying on ambient texture to define their ambient occlusion.
  45804. */
  45805. useRadianceOcclusion: boolean;
  45806. /**
  45807. * If set to true, no lighting calculations will be applied.
  45808. */
  45809. unlit: boolean;
  45810. /**
  45811. * Gets the image processing configuration used either in this material.
  45812. */
  45813. /**
  45814. * Sets the Default image processing configuration used either in the this material.
  45815. *
  45816. * If sets to null, the scene one is in use.
  45817. */
  45818. imageProcessingConfiguration: ImageProcessingConfiguration;
  45819. /**
  45820. * Gets wether the color curves effect is enabled.
  45821. */
  45822. /**
  45823. * Sets wether the color curves effect is enabled.
  45824. */
  45825. cameraColorCurvesEnabled: boolean;
  45826. /**
  45827. * Gets wether the color grading effect is enabled.
  45828. */
  45829. /**
  45830. * Gets wether the color grading effect is enabled.
  45831. */
  45832. cameraColorGradingEnabled: boolean;
  45833. /**
  45834. * Gets wether tonemapping is enabled or not.
  45835. */
  45836. /**
  45837. * Sets wether tonemapping is enabled or not
  45838. */
  45839. cameraToneMappingEnabled: boolean;
  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. /**
  45846. * The camera exposure used on this material.
  45847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45848. * This corresponds to a photographic exposure.
  45849. */
  45850. cameraExposure: number;
  45851. /**
  45852. * Gets The camera contrast used on this material.
  45853. */
  45854. /**
  45855. * Sets The camera contrast used on this material.
  45856. */
  45857. cameraContrast: number;
  45858. /**
  45859. * Gets the Color Grading 2D Lookup Texture.
  45860. */
  45861. /**
  45862. * Sets the Color Grading 2D Lookup Texture.
  45863. */
  45864. cameraColorGradingTexture: Nullable<BaseTexture>;
  45865. /**
  45866. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45868. * 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;
  45869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45870. */
  45871. /**
  45872. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45873. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45874. * 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;
  45875. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45876. */
  45877. cameraColorCurves: Nullable<ColorCurves>;
  45878. /**
  45879. * Instantiates a new PBRMaterial instance.
  45880. *
  45881. * @param name The material name
  45882. * @param scene The scene the material will be use in.
  45883. */
  45884. constructor(name: string, scene: Scene);
  45885. /**
  45886. * Returns the name of this material class.
  45887. */
  45888. getClassName(): string;
  45889. /**
  45890. * Makes a duplicate of the current material.
  45891. * @param name - name to use for the new material.
  45892. */
  45893. clone(name: string): PBRMaterial;
  45894. /**
  45895. * Serializes this PBR Material.
  45896. * @returns - An object with the serialized material.
  45897. */
  45898. serialize(): any;
  45899. /**
  45900. * Parses a PBR Material from a serialized object.
  45901. * @param source - Serialized object.
  45902. * @param scene - BJS scene instance.
  45903. * @param rootUrl - url for the scene object
  45904. * @returns - PBRMaterial
  45905. */
  45906. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45907. }
  45908. }
  45909. declare module "babylonjs/Misc/dds" {
  45910. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45911. import { Engine } from "babylonjs/Engines/engine";
  45912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45913. import { Nullable } from "babylonjs/types";
  45914. import { Scene } from "babylonjs/scene";
  45915. /**
  45916. * Direct draw surface info
  45917. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45918. */
  45919. export interface DDSInfo {
  45920. /**
  45921. * Width of the texture
  45922. */
  45923. width: number;
  45924. /**
  45925. * Width of the texture
  45926. */
  45927. height: number;
  45928. /**
  45929. * Number of Mipmaps for the texture
  45930. * @see https://en.wikipedia.org/wiki/Mipmap
  45931. */
  45932. mipmapCount: number;
  45933. /**
  45934. * If the textures format is a known fourCC format
  45935. * @see https://www.fourcc.org/
  45936. */
  45937. isFourCC: boolean;
  45938. /**
  45939. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45940. */
  45941. isRGB: boolean;
  45942. /**
  45943. * If the texture is a lumincance format
  45944. */
  45945. isLuminance: boolean;
  45946. /**
  45947. * If this is a cube texture
  45948. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45949. */
  45950. isCube: boolean;
  45951. /**
  45952. * If the texture is a compressed format eg. FOURCC_DXT1
  45953. */
  45954. isCompressed: boolean;
  45955. /**
  45956. * The dxgiFormat of the texture
  45957. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45958. */
  45959. dxgiFormat: number;
  45960. /**
  45961. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45962. */
  45963. textureType: number;
  45964. /**
  45965. * Sphericle polynomial created for the dds texture
  45966. */
  45967. sphericalPolynomial?: SphericalPolynomial;
  45968. }
  45969. /**
  45970. * Class used to provide DDS decompression tools
  45971. */
  45972. export class DDSTools {
  45973. /**
  45974. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45975. */
  45976. static StoreLODInAlphaChannel: boolean;
  45977. /**
  45978. * Gets DDS information from an array buffer
  45979. * @param arrayBuffer defines the array buffer to read data from
  45980. * @returns the DDS information
  45981. */
  45982. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45983. private static _FloatView;
  45984. private static _Int32View;
  45985. private static _ToHalfFloat;
  45986. private static _FromHalfFloat;
  45987. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45988. private static _GetHalfFloatRGBAArrayBuffer;
  45989. private static _GetFloatRGBAArrayBuffer;
  45990. private static _GetFloatAsUIntRGBAArrayBuffer;
  45991. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45992. private static _GetRGBAArrayBuffer;
  45993. private static _ExtractLongWordOrder;
  45994. private static _GetRGBArrayBuffer;
  45995. private static _GetLuminanceArrayBuffer;
  45996. /**
  45997. * Uploads DDS Levels to a Babylon Texture
  45998. * @hidden
  45999. */
  46000. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46001. }
  46002. module "babylonjs/Engines/engine" {
  46003. interface Engine {
  46004. /**
  46005. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46006. * @param rootUrl defines the url where the file to load is located
  46007. * @param scene defines the current scene
  46008. * @param lodScale defines scale to apply to the mip map selection
  46009. * @param lodOffset defines offset to apply to the mip map selection
  46010. * @param onLoad defines an optional callback raised when the texture is loaded
  46011. * @param onError defines an optional callback raised if there is an issue to load the texture
  46012. * @param format defines the format of the data
  46013. * @param forcedExtension defines the extension to use to pick the right loader
  46014. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46015. * @returns the cube texture as an InternalTexture
  46016. */
  46017. 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;
  46018. }
  46019. }
  46020. }
  46021. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46022. import { Nullable } from "babylonjs/types";
  46023. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46024. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46025. /**
  46026. * Implementation of the DDS Texture Loader.
  46027. * @hidden
  46028. */
  46029. export class _DDSTextureLoader implements IInternalTextureLoader {
  46030. /**
  46031. * Defines wether the loader supports cascade loading the different faces.
  46032. */
  46033. readonly supportCascades: boolean;
  46034. /**
  46035. * This returns if the loader support the current file information.
  46036. * @param extension defines the file extension of the file being loaded
  46037. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46038. * @param fallback defines the fallback internal texture if any
  46039. * @param isBase64 defines whether the texture is encoded as a base64
  46040. * @param isBuffer defines whether the texture data are stored as a buffer
  46041. * @returns true if the loader can load the specified file
  46042. */
  46043. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46044. /**
  46045. * Transform the url before loading if required.
  46046. * @param rootUrl the url of the texture
  46047. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46048. * @returns the transformed texture
  46049. */
  46050. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46051. /**
  46052. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46053. * @param rootUrl the url of the texture
  46054. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46055. * @returns the fallback texture
  46056. */
  46057. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46058. /**
  46059. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46060. * @param data contains the texture data
  46061. * @param texture defines the BabylonJS internal texture
  46062. * @param createPolynomials will be true if polynomials have been requested
  46063. * @param onLoad defines the callback to trigger once the texture is ready
  46064. * @param onError defines the callback to trigger in case of error
  46065. */
  46066. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46067. /**
  46068. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46069. * @param data contains the texture data
  46070. * @param texture defines the BabylonJS internal texture
  46071. * @param callback defines the method to call once ready to upload
  46072. */
  46073. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46074. }
  46075. }
  46076. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46077. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46078. /** @hidden */
  46079. export var rgbdEncodePixelShader: {
  46080. name: string;
  46081. shader: string;
  46082. };
  46083. }
  46084. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46085. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46086. /** @hidden */
  46087. export var rgbdDecodePixelShader: {
  46088. name: string;
  46089. shader: string;
  46090. };
  46091. }
  46092. declare module "babylonjs/Misc/environmentTextureTools" {
  46093. import { Nullable } from "babylonjs/types";
  46094. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46096. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46097. import "babylonjs/Shaders/rgbdEncode.fragment";
  46098. import "babylonjs/Shaders/rgbdDecode.fragment";
  46099. /**
  46100. * Raw texture data and descriptor sufficient for WebGL texture upload
  46101. */
  46102. export interface EnvironmentTextureInfo {
  46103. /**
  46104. * Version of the environment map
  46105. */
  46106. version: number;
  46107. /**
  46108. * Width of image
  46109. */
  46110. width: number;
  46111. /**
  46112. * Irradiance information stored in the file.
  46113. */
  46114. irradiance: any;
  46115. /**
  46116. * Specular information stored in the file.
  46117. */
  46118. specular: any;
  46119. }
  46120. /**
  46121. * Sets of helpers addressing the serialization and deserialization of environment texture
  46122. * stored in a BabylonJS env file.
  46123. * Those files are usually stored as .env files.
  46124. */
  46125. export class EnvironmentTextureTools {
  46126. /**
  46127. * Magic number identifying the env file.
  46128. */
  46129. private static _MagicBytes;
  46130. /**
  46131. * Gets the environment info from an env file.
  46132. * @param data The array buffer containing the .env bytes.
  46133. * @returns the environment file info (the json header) if successfully parsed.
  46134. */
  46135. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46136. /**
  46137. * Creates an environment texture from a loaded cube texture.
  46138. * @param texture defines the cube texture to convert in env file
  46139. * @return a promise containing the environment data if succesfull.
  46140. */
  46141. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46142. /**
  46143. * Creates a JSON representation of the spherical data.
  46144. * @param texture defines the texture containing the polynomials
  46145. * @return the JSON representation of the spherical info
  46146. */
  46147. private static _CreateEnvTextureIrradiance;
  46148. /**
  46149. * Uploads the texture info contained in the env file to the GPU.
  46150. * @param texture defines the internal texture to upload to
  46151. * @param arrayBuffer defines the buffer cotaining the data to load
  46152. * @param info defines the texture info retrieved through the GetEnvInfo method
  46153. * @returns a promise
  46154. */
  46155. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46156. /**
  46157. * Uploads the levels of image data to the GPU.
  46158. * @param texture defines the internal texture to upload to
  46159. * @param imageData defines the array buffer views of image data [mipmap][face]
  46160. * @returns a promise
  46161. */
  46162. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46163. /**
  46164. * Uploads spherical polynomials information to the texture.
  46165. * @param texture defines the texture we are trying to upload the information to
  46166. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46167. */
  46168. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46169. /** @hidden */
  46170. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46171. }
  46172. }
  46173. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46174. import { Nullable } from "babylonjs/types";
  46175. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46176. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46177. /**
  46178. * Implementation of the ENV Texture Loader.
  46179. * @hidden
  46180. */
  46181. export class _ENVTextureLoader implements IInternalTextureLoader {
  46182. /**
  46183. * Defines wether the loader supports cascade loading the different faces.
  46184. */
  46185. readonly supportCascades: boolean;
  46186. /**
  46187. * This returns if the loader support the current file information.
  46188. * @param extension defines the file extension of the file being loaded
  46189. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46190. * @param fallback defines the fallback internal texture if any
  46191. * @param isBase64 defines whether the texture is encoded as a base64
  46192. * @param isBuffer defines whether the texture data are stored as a buffer
  46193. * @returns true if the loader can load the specified file
  46194. */
  46195. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46196. /**
  46197. * Transform the url before loading if required.
  46198. * @param rootUrl the url of the texture
  46199. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46200. * @returns the transformed texture
  46201. */
  46202. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46203. /**
  46204. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46205. * @param rootUrl the url of the texture
  46206. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46207. * @returns the fallback texture
  46208. */
  46209. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46210. /**
  46211. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46212. * @param data contains the texture data
  46213. * @param texture defines the BabylonJS internal texture
  46214. * @param createPolynomials will be true if polynomials have been requested
  46215. * @param onLoad defines the callback to trigger once the texture is ready
  46216. * @param onError defines the callback to trigger in case of error
  46217. */
  46218. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46219. /**
  46220. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46221. * @param data contains the texture data
  46222. * @param texture defines the BabylonJS internal texture
  46223. * @param callback defines the method to call once ready to upload
  46224. */
  46225. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46226. }
  46227. }
  46228. declare module "babylonjs/Misc/khronosTextureContainer" {
  46229. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46230. /**
  46231. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46232. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46233. */
  46234. export class KhronosTextureContainer {
  46235. /** contents of the KTX container file */
  46236. arrayBuffer: any;
  46237. private static HEADER_LEN;
  46238. private static COMPRESSED_2D;
  46239. private static COMPRESSED_3D;
  46240. private static TEX_2D;
  46241. private static TEX_3D;
  46242. /**
  46243. * Gets the openGL type
  46244. */
  46245. glType: number;
  46246. /**
  46247. * Gets the openGL type size
  46248. */
  46249. glTypeSize: number;
  46250. /**
  46251. * Gets the openGL format
  46252. */
  46253. glFormat: number;
  46254. /**
  46255. * Gets the openGL internal format
  46256. */
  46257. glInternalFormat: number;
  46258. /**
  46259. * Gets the base internal format
  46260. */
  46261. glBaseInternalFormat: number;
  46262. /**
  46263. * Gets image width in pixel
  46264. */
  46265. pixelWidth: number;
  46266. /**
  46267. * Gets image height in pixel
  46268. */
  46269. pixelHeight: number;
  46270. /**
  46271. * Gets image depth in pixels
  46272. */
  46273. pixelDepth: number;
  46274. /**
  46275. * Gets the number of array elements
  46276. */
  46277. numberOfArrayElements: number;
  46278. /**
  46279. * Gets the number of faces
  46280. */
  46281. numberOfFaces: number;
  46282. /**
  46283. * Gets the number of mipmap levels
  46284. */
  46285. numberOfMipmapLevels: number;
  46286. /**
  46287. * Gets the bytes of key value data
  46288. */
  46289. bytesOfKeyValueData: number;
  46290. /**
  46291. * Gets the load type
  46292. */
  46293. loadType: number;
  46294. /**
  46295. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46296. */
  46297. isInvalid: boolean;
  46298. /**
  46299. * Creates a new KhronosTextureContainer
  46300. * @param arrayBuffer contents of the KTX container file
  46301. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46302. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46303. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46304. */
  46305. constructor(
  46306. /** contents of the KTX container file */
  46307. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46308. /**
  46309. * Uploads KTX content to a Babylon Texture.
  46310. * It is assumed that the texture has already been created & is currently bound
  46311. * @hidden
  46312. */
  46313. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46314. private _upload2DCompressedLevels;
  46315. }
  46316. }
  46317. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46318. import { Nullable } from "babylonjs/types";
  46319. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46320. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46321. /**
  46322. * Implementation of the KTX Texture Loader.
  46323. * @hidden
  46324. */
  46325. export class _KTXTextureLoader implements IInternalTextureLoader {
  46326. /**
  46327. * Defines wether the loader supports cascade loading the different faces.
  46328. */
  46329. readonly supportCascades: boolean;
  46330. /**
  46331. * This returns if the loader support the current file information.
  46332. * @param extension defines the file extension of the file being loaded
  46333. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46334. * @param fallback defines the fallback internal texture if any
  46335. * @param isBase64 defines whether the texture is encoded as a base64
  46336. * @param isBuffer defines whether the texture data are stored as a buffer
  46337. * @returns true if the loader can load the specified file
  46338. */
  46339. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46340. /**
  46341. * Transform the url before loading if required.
  46342. * @param rootUrl the url of the texture
  46343. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46344. * @returns the transformed texture
  46345. */
  46346. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46347. /**
  46348. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46349. * @param rootUrl the url of the texture
  46350. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46351. * @returns the fallback texture
  46352. */
  46353. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46354. /**
  46355. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46356. * @param data contains the texture data
  46357. * @param texture defines the BabylonJS internal texture
  46358. * @param createPolynomials will be true if polynomials have been requested
  46359. * @param onLoad defines the callback to trigger once the texture is ready
  46360. * @param onError defines the callback to trigger in case of error
  46361. */
  46362. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46363. /**
  46364. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46365. * @param data contains the texture data
  46366. * @param texture defines the BabylonJS internal texture
  46367. * @param callback defines the method to call once ready to upload
  46368. */
  46369. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46370. }
  46371. }
  46372. declare module "babylonjs/Helpers/sceneHelpers" {
  46373. import { Nullable } from "babylonjs/types";
  46374. import { Mesh } from "babylonjs/Meshes/mesh";
  46375. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46376. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46377. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46378. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46379. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46380. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46381. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46382. import "babylonjs/Meshes/Builders/boxBuilder";
  46383. /** @hidden */
  46384. export var _forceSceneHelpersToBundle: boolean;
  46385. module "babylonjs/scene" {
  46386. interface Scene {
  46387. /**
  46388. * Creates a default light for the scene.
  46389. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46390. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46391. */
  46392. createDefaultLight(replace?: boolean): void;
  46393. /**
  46394. * Creates a default camera for the scene.
  46395. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46396. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46397. * @param replace has default false, when true replaces the active camera in the scene
  46398. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46399. */
  46400. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46401. /**
  46402. * Creates a default camera and a default light.
  46403. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46404. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46405. * @param replace has the default false, when true replaces the active camera/light in the scene
  46406. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46407. */
  46408. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46409. /**
  46410. * Creates a new sky box
  46411. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46412. * @param environmentTexture defines the texture to use as environment texture
  46413. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46414. * @param scale defines the overall scale of the skybox
  46415. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46416. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46417. * @returns a new mesh holding the sky box
  46418. */
  46419. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46420. /**
  46421. * Creates a new environment
  46422. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46423. * @param options defines the options you can use to configure the environment
  46424. * @returns the new EnvironmentHelper
  46425. */
  46426. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46427. /**
  46428. * Creates a new VREXperienceHelper
  46429. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46430. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46431. * @returns a new VREXperienceHelper
  46432. */
  46433. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46434. /**
  46435. * Creates a new XREXperienceHelper
  46436. * @see http://doc.babylonjs.com/how_to/webxr
  46437. * @returns a promise for a new XREXperienceHelper
  46438. */
  46439. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46440. }
  46441. }
  46442. }
  46443. declare module "babylonjs/Helpers/videoDome" {
  46444. import { Scene } from "babylonjs/scene";
  46445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46446. import { Mesh } from "babylonjs/Meshes/mesh";
  46447. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46448. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46449. import "babylonjs/Meshes/Builders/sphereBuilder";
  46450. /**
  46451. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46452. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46453. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46454. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46455. */
  46456. export class VideoDome extends TransformNode {
  46457. /**
  46458. * Define the video source as a Monoscopic panoramic 360 video.
  46459. */
  46460. static readonly MODE_MONOSCOPIC: number;
  46461. /**
  46462. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46463. */
  46464. static readonly MODE_TOPBOTTOM: number;
  46465. /**
  46466. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46467. */
  46468. static readonly MODE_SIDEBYSIDE: number;
  46469. private _useDirectMapping;
  46470. /**
  46471. * The video texture being displayed on the sphere
  46472. */
  46473. protected _videoTexture: VideoTexture;
  46474. /**
  46475. * Gets the video texture being displayed on the sphere
  46476. */
  46477. readonly videoTexture: VideoTexture;
  46478. /**
  46479. * The skybox material
  46480. */
  46481. protected _material: BackgroundMaterial;
  46482. /**
  46483. * The surface used for the skybox
  46484. */
  46485. protected _mesh: Mesh;
  46486. /**
  46487. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46488. * Also see the options.resolution property.
  46489. */
  46490. fovMultiplier: number;
  46491. private _videoMode;
  46492. /**
  46493. * Gets or set the current video mode for the video. It can be:
  46494. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46495. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46496. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46497. */
  46498. videoMode: number;
  46499. /**
  46500. * Oberserver used in Stereoscopic VR Mode.
  46501. */
  46502. private _onBeforeCameraRenderObserver;
  46503. /**
  46504. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46505. * @param name Element's name, child elements will append suffixes for their own names.
  46506. * @param urlsOrVideo defines the url(s) or the video element to use
  46507. * @param options An object containing optional or exposed sub element properties
  46508. */
  46509. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46510. resolution?: number;
  46511. clickToPlay?: boolean;
  46512. autoPlay?: boolean;
  46513. loop?: boolean;
  46514. size?: number;
  46515. poster?: string;
  46516. useDirectMapping?: boolean;
  46517. }, scene: Scene);
  46518. private _changeVideoMode;
  46519. /**
  46520. * Releases resources associated with this node.
  46521. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46522. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46523. */
  46524. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46525. }
  46526. }
  46527. declare module "babylonjs/Helpers/index" {
  46528. export * from "babylonjs/Helpers/environmentHelper";
  46529. export * from "babylonjs/Helpers/photoDome";
  46530. export * from "babylonjs/Helpers/sceneHelpers";
  46531. export * from "babylonjs/Helpers/videoDome";
  46532. }
  46533. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46534. import { PerfCounter } from "babylonjs/Misc/tools";
  46535. import { IDisposable } from "babylonjs/scene";
  46536. import { Engine } from "babylonjs/Engines/engine";
  46537. /**
  46538. * This class can be used to get instrumentation data from a Babylon engine
  46539. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46540. */
  46541. export class EngineInstrumentation implements IDisposable {
  46542. /**
  46543. * Define the instrumented engine.
  46544. */
  46545. engine: Engine;
  46546. private _captureGPUFrameTime;
  46547. private _gpuFrameTimeToken;
  46548. private _gpuFrameTime;
  46549. private _captureShaderCompilationTime;
  46550. private _shaderCompilationTime;
  46551. private _onBeginFrameObserver;
  46552. private _onEndFrameObserver;
  46553. private _onBeforeShaderCompilationObserver;
  46554. private _onAfterShaderCompilationObserver;
  46555. /**
  46556. * Gets the perf counter used for GPU frame time
  46557. */
  46558. readonly gpuFrameTimeCounter: PerfCounter;
  46559. /**
  46560. * Gets the GPU frame time capture status
  46561. */
  46562. /**
  46563. * Enable or disable the GPU frame time capture
  46564. */
  46565. captureGPUFrameTime: boolean;
  46566. /**
  46567. * Gets the perf counter used for shader compilation time
  46568. */
  46569. readonly shaderCompilationTimeCounter: PerfCounter;
  46570. /**
  46571. * Gets the shader compilation time capture status
  46572. */
  46573. /**
  46574. * Enable or disable the shader compilation time capture
  46575. */
  46576. captureShaderCompilationTime: boolean;
  46577. /**
  46578. * Instantiates a new engine instrumentation.
  46579. * This class can be used to get instrumentation data from a Babylon engine
  46580. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46581. * @param engine Defines the engine to instrument
  46582. */
  46583. constructor(
  46584. /**
  46585. * Define the instrumented engine.
  46586. */
  46587. engine: Engine);
  46588. /**
  46589. * Dispose and release associated resources.
  46590. */
  46591. dispose(): void;
  46592. }
  46593. }
  46594. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46595. import { PerfCounter } from "babylonjs/Misc/tools";
  46596. import { Scene, IDisposable } from "babylonjs/scene";
  46597. /**
  46598. * This class can be used to get instrumentation data from a Babylon engine
  46599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46600. */
  46601. export class SceneInstrumentation implements IDisposable {
  46602. /**
  46603. * Defines the scene to instrument
  46604. */
  46605. scene: Scene;
  46606. private _captureActiveMeshesEvaluationTime;
  46607. private _activeMeshesEvaluationTime;
  46608. private _captureRenderTargetsRenderTime;
  46609. private _renderTargetsRenderTime;
  46610. private _captureFrameTime;
  46611. private _frameTime;
  46612. private _captureRenderTime;
  46613. private _renderTime;
  46614. private _captureInterFrameTime;
  46615. private _interFrameTime;
  46616. private _captureParticlesRenderTime;
  46617. private _particlesRenderTime;
  46618. private _captureSpritesRenderTime;
  46619. private _spritesRenderTime;
  46620. private _capturePhysicsTime;
  46621. private _physicsTime;
  46622. private _captureAnimationsTime;
  46623. private _animationsTime;
  46624. private _captureCameraRenderTime;
  46625. private _cameraRenderTime;
  46626. private _onBeforeActiveMeshesEvaluationObserver;
  46627. private _onAfterActiveMeshesEvaluationObserver;
  46628. private _onBeforeRenderTargetsRenderObserver;
  46629. private _onAfterRenderTargetsRenderObserver;
  46630. private _onAfterRenderObserver;
  46631. private _onBeforeDrawPhaseObserver;
  46632. private _onAfterDrawPhaseObserver;
  46633. private _onBeforeAnimationsObserver;
  46634. private _onBeforeParticlesRenderingObserver;
  46635. private _onAfterParticlesRenderingObserver;
  46636. private _onBeforeSpritesRenderingObserver;
  46637. private _onAfterSpritesRenderingObserver;
  46638. private _onBeforePhysicsObserver;
  46639. private _onAfterPhysicsObserver;
  46640. private _onAfterAnimationsObserver;
  46641. private _onBeforeCameraRenderObserver;
  46642. private _onAfterCameraRenderObserver;
  46643. /**
  46644. * Gets the perf counter used for active meshes evaluation time
  46645. */
  46646. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46647. /**
  46648. * Gets the active meshes evaluation time capture status
  46649. */
  46650. /**
  46651. * Enable or disable the active meshes evaluation time capture
  46652. */
  46653. captureActiveMeshesEvaluationTime: boolean;
  46654. /**
  46655. * Gets the perf counter used for render targets render time
  46656. */
  46657. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46658. /**
  46659. * Gets the render targets render time capture status
  46660. */
  46661. /**
  46662. * Enable or disable the render targets render time capture
  46663. */
  46664. captureRenderTargetsRenderTime: boolean;
  46665. /**
  46666. * Gets the perf counter used for particles render time
  46667. */
  46668. readonly particlesRenderTimeCounter: PerfCounter;
  46669. /**
  46670. * Gets the particles render time capture status
  46671. */
  46672. /**
  46673. * Enable or disable the particles render time capture
  46674. */
  46675. captureParticlesRenderTime: boolean;
  46676. /**
  46677. * Gets the perf counter used for sprites render time
  46678. */
  46679. readonly spritesRenderTimeCounter: PerfCounter;
  46680. /**
  46681. * Gets the sprites render time capture status
  46682. */
  46683. /**
  46684. * Enable or disable the sprites render time capture
  46685. */
  46686. captureSpritesRenderTime: boolean;
  46687. /**
  46688. * Gets the perf counter used for physics time
  46689. */
  46690. readonly physicsTimeCounter: PerfCounter;
  46691. /**
  46692. * Gets the physics time capture status
  46693. */
  46694. /**
  46695. * Enable or disable the physics time capture
  46696. */
  46697. capturePhysicsTime: boolean;
  46698. /**
  46699. * Gets the perf counter used for animations time
  46700. */
  46701. readonly animationsTimeCounter: PerfCounter;
  46702. /**
  46703. * Gets the animations time capture status
  46704. */
  46705. /**
  46706. * Enable or disable the animations time capture
  46707. */
  46708. captureAnimationsTime: boolean;
  46709. /**
  46710. * Gets the perf counter used for frame time capture
  46711. */
  46712. readonly frameTimeCounter: PerfCounter;
  46713. /**
  46714. * Gets the frame time capture status
  46715. */
  46716. /**
  46717. * Enable or disable the frame time capture
  46718. */
  46719. captureFrameTime: boolean;
  46720. /**
  46721. * Gets the perf counter used for inter-frames time capture
  46722. */
  46723. readonly interFrameTimeCounter: PerfCounter;
  46724. /**
  46725. * Gets the inter-frames time capture status
  46726. */
  46727. /**
  46728. * Enable or disable the inter-frames time capture
  46729. */
  46730. captureInterFrameTime: boolean;
  46731. /**
  46732. * Gets the perf counter used for render time capture
  46733. */
  46734. readonly renderTimeCounter: PerfCounter;
  46735. /**
  46736. * Gets the render time capture status
  46737. */
  46738. /**
  46739. * Enable or disable the render time capture
  46740. */
  46741. captureRenderTime: boolean;
  46742. /**
  46743. * Gets the perf counter used for camera render time capture
  46744. */
  46745. readonly cameraRenderTimeCounter: PerfCounter;
  46746. /**
  46747. * Gets the camera render time capture status
  46748. */
  46749. /**
  46750. * Enable or disable the camera render time capture
  46751. */
  46752. captureCameraRenderTime: boolean;
  46753. /**
  46754. * Gets the perf counter used for draw calls
  46755. */
  46756. readonly drawCallsCounter: PerfCounter;
  46757. /**
  46758. * Gets the perf counter used for texture collisions
  46759. */
  46760. readonly textureCollisionsCounter: PerfCounter;
  46761. /**
  46762. * Instantiates a new scene instrumentation.
  46763. * This class can be used to get instrumentation data from a Babylon engine
  46764. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46765. * @param scene Defines the scene to instrument
  46766. */
  46767. constructor(
  46768. /**
  46769. * Defines the scene to instrument
  46770. */
  46771. scene: Scene);
  46772. /**
  46773. * Dispose and release associated resources.
  46774. */
  46775. dispose(): void;
  46776. }
  46777. }
  46778. declare module "babylonjs/Instrumentation/index" {
  46779. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46780. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46781. export * from "babylonjs/Instrumentation/timeToken";
  46782. }
  46783. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46784. /** @hidden */
  46785. export var glowMapGenerationPixelShader: {
  46786. name: string;
  46787. shader: string;
  46788. };
  46789. }
  46790. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46791. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46792. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46793. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46794. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46795. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46796. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46797. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46798. /** @hidden */
  46799. export var glowMapGenerationVertexShader: {
  46800. name: string;
  46801. shader: string;
  46802. };
  46803. }
  46804. declare module "babylonjs/Layers/effectLayer" {
  46805. import { Observable } from "babylonjs/Misc/observable";
  46806. import { Nullable } from "babylonjs/types";
  46807. import { Camera } from "babylonjs/Cameras/camera";
  46808. import { Scene } from "babylonjs/scene";
  46809. import { Color4, ISize } from "babylonjs/Maths/math";
  46810. import { Engine } from "babylonjs/Engines/engine";
  46811. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46813. import { Mesh } from "babylonjs/Meshes/mesh";
  46814. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46816. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46817. import { Effect } from "babylonjs/Materials/effect";
  46818. import { Material } from "babylonjs/Materials/material";
  46819. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46820. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46821. /**
  46822. * Effect layer options. This helps customizing the behaviour
  46823. * of the effect layer.
  46824. */
  46825. export interface IEffectLayerOptions {
  46826. /**
  46827. * Multiplication factor apply to the canvas size to compute the render target size
  46828. * used to generated the objects (the smaller the faster).
  46829. */
  46830. mainTextureRatio: number;
  46831. /**
  46832. * Enforces a fixed size texture to ensure effect stability across devices.
  46833. */
  46834. mainTextureFixedSize?: number;
  46835. /**
  46836. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46837. */
  46838. alphaBlendingMode: number;
  46839. /**
  46840. * The camera attached to the layer.
  46841. */
  46842. camera: Nullable<Camera>;
  46843. /**
  46844. * The rendering group to draw the layer in.
  46845. */
  46846. renderingGroupId: number;
  46847. }
  46848. /**
  46849. * The effect layer Helps adding post process effect blended with the main pass.
  46850. *
  46851. * This can be for instance use to generate glow or higlight effects on the scene.
  46852. *
  46853. * The effect layer class can not be used directly and is intented to inherited from to be
  46854. * customized per effects.
  46855. */
  46856. export abstract class EffectLayer {
  46857. private _vertexBuffers;
  46858. private _indexBuffer;
  46859. private _cachedDefines;
  46860. private _effectLayerMapGenerationEffect;
  46861. private _effectLayerOptions;
  46862. private _mergeEffect;
  46863. protected _scene: Scene;
  46864. protected _engine: Engine;
  46865. protected _maxSize: number;
  46866. protected _mainTextureDesiredSize: ISize;
  46867. protected _mainTexture: RenderTargetTexture;
  46868. protected _shouldRender: boolean;
  46869. protected _postProcesses: PostProcess[];
  46870. protected _textures: BaseTexture[];
  46871. protected _emissiveTextureAndColor: {
  46872. texture: Nullable<BaseTexture>;
  46873. color: Color4;
  46874. };
  46875. /**
  46876. * The name of the layer
  46877. */
  46878. name: string;
  46879. /**
  46880. * The clear color of the texture used to generate the glow map.
  46881. */
  46882. neutralColor: Color4;
  46883. /**
  46884. * Specifies wether the highlight layer is enabled or not.
  46885. */
  46886. isEnabled: boolean;
  46887. /**
  46888. * Gets the camera attached to the layer.
  46889. */
  46890. readonly camera: Nullable<Camera>;
  46891. /**
  46892. * Gets the rendering group id the layer should render in.
  46893. */
  46894. readonly renderingGroupId: number;
  46895. /**
  46896. * An event triggered when the effect layer has been disposed.
  46897. */
  46898. onDisposeObservable: Observable<EffectLayer>;
  46899. /**
  46900. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46901. */
  46902. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46903. /**
  46904. * An event triggered when the generated texture is being merged in the scene.
  46905. */
  46906. onBeforeComposeObservable: Observable<EffectLayer>;
  46907. /**
  46908. * An event triggered when the generated texture has been merged in the scene.
  46909. */
  46910. onAfterComposeObservable: Observable<EffectLayer>;
  46911. /**
  46912. * An event triggered when the efffect layer changes its size.
  46913. */
  46914. onSizeChangedObservable: Observable<EffectLayer>;
  46915. /** @hidden */
  46916. static _SceneComponentInitialization: (scene: Scene) => void;
  46917. /**
  46918. * Instantiates a new effect Layer and references it in the scene.
  46919. * @param name The name of the layer
  46920. * @param scene The scene to use the layer in
  46921. */
  46922. constructor(
  46923. /** The Friendly of the effect in the scene */
  46924. name: string, scene: Scene);
  46925. /**
  46926. * Get the effect name of the layer.
  46927. * @return The effect name
  46928. */
  46929. abstract getEffectName(): string;
  46930. /**
  46931. * Checks for the readiness of the element composing the layer.
  46932. * @param subMesh the mesh to check for
  46933. * @param useInstances specify wether or not to use instances to render the mesh
  46934. * @return true if ready otherwise, false
  46935. */
  46936. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46937. /**
  46938. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46939. * @returns true if the effect requires stencil during the main canvas render pass.
  46940. */
  46941. abstract needStencil(): boolean;
  46942. /**
  46943. * Create the merge effect. This is the shader use to blit the information back
  46944. * to the main canvas at the end of the scene rendering.
  46945. * @returns The effect containing the shader used to merge the effect on the main canvas
  46946. */
  46947. protected abstract _createMergeEffect(): Effect;
  46948. /**
  46949. * Creates the render target textures and post processes used in the effect layer.
  46950. */
  46951. protected abstract _createTextureAndPostProcesses(): void;
  46952. /**
  46953. * Implementation specific of rendering the generating effect on the main canvas.
  46954. * @param effect The effect used to render through
  46955. */
  46956. protected abstract _internalRender(effect: Effect): void;
  46957. /**
  46958. * Sets the required values for both the emissive texture and and the main color.
  46959. */
  46960. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46961. /**
  46962. * Free any resources and references associated to a mesh.
  46963. * Internal use
  46964. * @param mesh The mesh to free.
  46965. */
  46966. abstract _disposeMesh(mesh: Mesh): void;
  46967. /**
  46968. * Serializes this layer (Glow or Highlight for example)
  46969. * @returns a serialized layer object
  46970. */
  46971. abstract serialize?(): any;
  46972. /**
  46973. * Initializes the effect layer with the required options.
  46974. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46975. */
  46976. protected _init(options: Partial<IEffectLayerOptions>): void;
  46977. /**
  46978. * Generates the index buffer of the full screen quad blending to the main canvas.
  46979. */
  46980. private _generateIndexBuffer;
  46981. /**
  46982. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46983. */
  46984. private _genrateVertexBuffer;
  46985. /**
  46986. * Sets the main texture desired size which is the closest power of two
  46987. * of the engine canvas size.
  46988. */
  46989. private _setMainTextureSize;
  46990. /**
  46991. * Creates the main texture for the effect layer.
  46992. */
  46993. protected _createMainTexture(): void;
  46994. /**
  46995. * Adds specific effects defines.
  46996. * @param defines The defines to add specifics to.
  46997. */
  46998. protected _addCustomEffectDefines(defines: string[]): void;
  46999. /**
  47000. * Checks for the readiness of the element composing the layer.
  47001. * @param subMesh the mesh to check for
  47002. * @param useInstances specify wether or not to use instances to render the mesh
  47003. * @param emissiveTexture the associated emissive texture used to generate the glow
  47004. * @return true if ready otherwise, false
  47005. */
  47006. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47007. /**
  47008. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47009. */
  47010. render(): void;
  47011. /**
  47012. * Determine if a given mesh will be used in the current effect.
  47013. * @param mesh mesh to test
  47014. * @returns true if the mesh will be used
  47015. */
  47016. hasMesh(mesh: AbstractMesh): boolean;
  47017. /**
  47018. * Returns true if the layer contains information to display, otherwise false.
  47019. * @returns true if the glow layer should be rendered
  47020. */
  47021. shouldRender(): boolean;
  47022. /**
  47023. * Returns true if the mesh should render, otherwise false.
  47024. * @param mesh The mesh to render
  47025. * @returns true if it should render otherwise false
  47026. */
  47027. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47028. /**
  47029. * Returns true if the mesh can be rendered, otherwise false.
  47030. * @param mesh The mesh to render
  47031. * @param material The material used on the mesh
  47032. * @returns true if it can be rendered otherwise false
  47033. */
  47034. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47035. /**
  47036. * Returns true if the mesh should render, otherwise false.
  47037. * @param mesh The mesh to render
  47038. * @returns true if it should render otherwise false
  47039. */
  47040. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47041. /**
  47042. * Renders the submesh passed in parameter to the generation map.
  47043. */
  47044. protected _renderSubMesh(subMesh: SubMesh): void;
  47045. /**
  47046. * Rebuild the required buffers.
  47047. * @hidden Internal use only.
  47048. */
  47049. _rebuild(): void;
  47050. /**
  47051. * Dispose only the render target textures and post process.
  47052. */
  47053. private _disposeTextureAndPostProcesses;
  47054. /**
  47055. * Dispose the highlight layer and free resources.
  47056. */
  47057. dispose(): void;
  47058. /**
  47059. * Gets the class name of the effect layer
  47060. * @returns the string with the class name of the effect layer
  47061. */
  47062. getClassName(): string;
  47063. /**
  47064. * Creates an effect layer from parsed effect layer data
  47065. * @param parsedEffectLayer defines effect layer data
  47066. * @param scene defines the current scene
  47067. * @param rootUrl defines the root URL containing the effect layer information
  47068. * @returns a parsed effect Layer
  47069. */
  47070. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47071. }
  47072. }
  47073. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47074. import { Scene } from "babylonjs/scene";
  47075. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47076. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47077. import { AbstractScene } from "babylonjs/abstractScene";
  47078. module "babylonjs/abstractScene" {
  47079. interface AbstractScene {
  47080. /**
  47081. * The list of effect layers (highlights/glow) added to the scene
  47082. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47083. * @see http://doc.babylonjs.com/how_to/glow_layer
  47084. */
  47085. effectLayers: Array<EffectLayer>;
  47086. /**
  47087. * Removes the given effect layer from this scene.
  47088. * @param toRemove defines the effect layer to remove
  47089. * @returns the index of the removed effect layer
  47090. */
  47091. removeEffectLayer(toRemove: EffectLayer): number;
  47092. /**
  47093. * Adds the given effect layer to this scene
  47094. * @param newEffectLayer defines the effect layer to add
  47095. */
  47096. addEffectLayer(newEffectLayer: EffectLayer): void;
  47097. }
  47098. }
  47099. /**
  47100. * Defines the layer scene component responsible to manage any effect layers
  47101. * in a given scene.
  47102. */
  47103. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47104. /**
  47105. * The component name helpfull to identify the component in the list of scene components.
  47106. */
  47107. readonly name: string;
  47108. /**
  47109. * The scene the component belongs to.
  47110. */
  47111. scene: Scene;
  47112. private _engine;
  47113. private _renderEffects;
  47114. private _needStencil;
  47115. private _previousStencilState;
  47116. /**
  47117. * Creates a new instance of the component for the given scene
  47118. * @param scene Defines the scene to register the component in
  47119. */
  47120. constructor(scene: Scene);
  47121. /**
  47122. * Registers the component in a given scene
  47123. */
  47124. register(): void;
  47125. /**
  47126. * Rebuilds the elements related to this component in case of
  47127. * context lost for instance.
  47128. */
  47129. rebuild(): void;
  47130. /**
  47131. * Serializes the component data to the specified json object
  47132. * @param serializationObject The object to serialize to
  47133. */
  47134. serialize(serializationObject: any): void;
  47135. /**
  47136. * Adds all the element from the container to the scene
  47137. * @param container the container holding the elements
  47138. */
  47139. addFromContainer(container: AbstractScene): void;
  47140. /**
  47141. * Removes all the elements in the container from the scene
  47142. * @param container contains the elements to remove
  47143. */
  47144. removeFromContainer(container: AbstractScene): void;
  47145. /**
  47146. * Disposes the component and the associated ressources.
  47147. */
  47148. dispose(): void;
  47149. private _isReadyForMesh;
  47150. private _renderMainTexture;
  47151. private _setStencil;
  47152. private _setStencilBack;
  47153. private _draw;
  47154. private _drawCamera;
  47155. private _drawRenderingGroup;
  47156. }
  47157. }
  47158. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47159. /** @hidden */
  47160. export var glowMapMergePixelShader: {
  47161. name: string;
  47162. shader: string;
  47163. };
  47164. }
  47165. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47166. /** @hidden */
  47167. export var glowMapMergeVertexShader: {
  47168. name: string;
  47169. shader: string;
  47170. };
  47171. }
  47172. declare module "babylonjs/Layers/glowLayer" {
  47173. import { Nullable } from "babylonjs/types";
  47174. import { Camera } from "babylonjs/Cameras/camera";
  47175. import { Scene } from "babylonjs/scene";
  47176. import { Color4 } from "babylonjs/Maths/math";
  47177. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47179. import { Mesh } from "babylonjs/Meshes/mesh";
  47180. import { Texture } from "babylonjs/Materials/Textures/texture";
  47181. import { Effect } from "babylonjs/Materials/effect";
  47182. import { Material } from "babylonjs/Materials/material";
  47183. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47184. import "babylonjs/Shaders/glowMapMerge.fragment";
  47185. import "babylonjs/Shaders/glowMapMerge.vertex";
  47186. import "babylonjs/Layers/effectLayerSceneComponent";
  47187. module "babylonjs/abstractScene" {
  47188. interface AbstractScene {
  47189. /**
  47190. * Return a the first highlight layer of the scene with a given name.
  47191. * @param name The name of the highlight layer to look for.
  47192. * @return The highlight layer if found otherwise null.
  47193. */
  47194. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47195. }
  47196. }
  47197. /**
  47198. * Glow layer options. This helps customizing the behaviour
  47199. * of the glow layer.
  47200. */
  47201. export interface IGlowLayerOptions {
  47202. /**
  47203. * Multiplication factor apply to the canvas size to compute the render target size
  47204. * used to generated the glowing objects (the smaller the faster).
  47205. */
  47206. mainTextureRatio: number;
  47207. /**
  47208. * Enforces a fixed size texture to ensure resize independant blur.
  47209. */
  47210. mainTextureFixedSize?: number;
  47211. /**
  47212. * How big is the kernel of the blur texture.
  47213. */
  47214. blurKernelSize: number;
  47215. /**
  47216. * The camera attached to the layer.
  47217. */
  47218. camera: Nullable<Camera>;
  47219. /**
  47220. * Enable MSAA by chosing the number of samples.
  47221. */
  47222. mainTextureSamples?: number;
  47223. /**
  47224. * The rendering group to draw the layer in.
  47225. */
  47226. renderingGroupId: number;
  47227. }
  47228. /**
  47229. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47230. *
  47231. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47232. * glowy meshes to your scene.
  47233. *
  47234. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47235. */
  47236. export class GlowLayer extends EffectLayer {
  47237. /**
  47238. * Effect Name of the layer.
  47239. */
  47240. static readonly EffectName: string;
  47241. /**
  47242. * The default blur kernel size used for the glow.
  47243. */
  47244. static DefaultBlurKernelSize: number;
  47245. /**
  47246. * The default texture size ratio used for the glow.
  47247. */
  47248. static DefaultTextureRatio: number;
  47249. /**
  47250. * Sets the kernel size of the blur.
  47251. */
  47252. /**
  47253. * Gets the kernel size of the blur.
  47254. */
  47255. blurKernelSize: number;
  47256. /**
  47257. * Sets the glow intensity.
  47258. */
  47259. /**
  47260. * Gets the glow intensity.
  47261. */
  47262. intensity: number;
  47263. private _options;
  47264. private _intensity;
  47265. private _horizontalBlurPostprocess1;
  47266. private _verticalBlurPostprocess1;
  47267. private _horizontalBlurPostprocess2;
  47268. private _verticalBlurPostprocess2;
  47269. private _blurTexture1;
  47270. private _blurTexture2;
  47271. private _postProcesses1;
  47272. private _postProcesses2;
  47273. private _includedOnlyMeshes;
  47274. private _excludedMeshes;
  47275. /**
  47276. * Callback used to let the user override the color selection on a per mesh basis
  47277. */
  47278. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47279. /**
  47280. * Callback used to let the user override the texture selection on a per mesh basis
  47281. */
  47282. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47283. /**
  47284. * Instantiates a new glow Layer and references it to the scene.
  47285. * @param name The name of the layer
  47286. * @param scene The scene to use the layer in
  47287. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47288. */
  47289. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47290. /**
  47291. * Get the effect name of the layer.
  47292. * @return The effect name
  47293. */
  47294. getEffectName(): string;
  47295. /**
  47296. * Create the merge effect. This is the shader use to blit the information back
  47297. * to the main canvas at the end of the scene rendering.
  47298. */
  47299. protected _createMergeEffect(): Effect;
  47300. /**
  47301. * Creates the render target textures and post processes used in the glow layer.
  47302. */
  47303. protected _createTextureAndPostProcesses(): void;
  47304. /**
  47305. * Checks for the readiness of the element composing the layer.
  47306. * @param subMesh the mesh to check for
  47307. * @param useInstances specify wether or not to use instances to render the mesh
  47308. * @param emissiveTexture the associated emissive texture used to generate the glow
  47309. * @return true if ready otherwise, false
  47310. */
  47311. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47312. /**
  47313. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47314. */
  47315. needStencil(): boolean;
  47316. /**
  47317. * Returns true if the mesh can be rendered, otherwise false.
  47318. * @param mesh The mesh to render
  47319. * @param material The material used on the mesh
  47320. * @returns true if it can be rendered otherwise false
  47321. */
  47322. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47323. /**
  47324. * Implementation specific of rendering the generating effect on the main canvas.
  47325. * @param effect The effect used to render through
  47326. */
  47327. protected _internalRender(effect: Effect): void;
  47328. /**
  47329. * Sets the required values for both the emissive texture and and the main color.
  47330. */
  47331. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47332. /**
  47333. * Returns true if the mesh should render, otherwise false.
  47334. * @param mesh The mesh to render
  47335. * @returns true if it should render otherwise false
  47336. */
  47337. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47338. /**
  47339. * Adds specific effects defines.
  47340. * @param defines The defines to add specifics to.
  47341. */
  47342. protected _addCustomEffectDefines(defines: string[]): void;
  47343. /**
  47344. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47345. * @param mesh The mesh to exclude from the glow layer
  47346. */
  47347. addExcludedMesh(mesh: Mesh): void;
  47348. /**
  47349. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47350. * @param mesh The mesh to remove
  47351. */
  47352. removeExcludedMesh(mesh: Mesh): void;
  47353. /**
  47354. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47355. * @param mesh The mesh to include in the glow layer
  47356. */
  47357. addIncludedOnlyMesh(mesh: Mesh): void;
  47358. /**
  47359. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47360. * @param mesh The mesh to remove
  47361. */
  47362. removeIncludedOnlyMesh(mesh: Mesh): void;
  47363. /**
  47364. * Determine if a given mesh will be used in the glow layer
  47365. * @param mesh The mesh to test
  47366. * @returns true if the mesh will be highlighted by the current glow layer
  47367. */
  47368. hasMesh(mesh: AbstractMesh): boolean;
  47369. /**
  47370. * Free any resources and references associated to a mesh.
  47371. * Internal use
  47372. * @param mesh The mesh to free.
  47373. * @hidden
  47374. */
  47375. _disposeMesh(mesh: Mesh): void;
  47376. /**
  47377. * Gets the class name of the effect layer
  47378. * @returns the string with the class name of the effect layer
  47379. */
  47380. getClassName(): string;
  47381. /**
  47382. * Serializes this glow layer
  47383. * @returns a serialized glow layer object
  47384. */
  47385. serialize(): any;
  47386. /**
  47387. * Creates a Glow Layer from parsed glow layer data
  47388. * @param parsedGlowLayer defines glow layer data
  47389. * @param scene defines the current scene
  47390. * @param rootUrl defines the root URL containing the glow layer information
  47391. * @returns a parsed Glow Layer
  47392. */
  47393. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47394. }
  47395. }
  47396. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47397. /** @hidden */
  47398. export var glowBlurPostProcessPixelShader: {
  47399. name: string;
  47400. shader: string;
  47401. };
  47402. }
  47403. declare module "babylonjs/Layers/highlightLayer" {
  47404. import { Observable } from "babylonjs/Misc/observable";
  47405. import { Nullable } from "babylonjs/types";
  47406. import { Camera } from "babylonjs/Cameras/camera";
  47407. import { Scene } from "babylonjs/scene";
  47408. import { Color3, Color4 } from "babylonjs/Maths/math";
  47409. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47411. import { Mesh } from "babylonjs/Meshes/mesh";
  47412. import { Effect } from "babylonjs/Materials/effect";
  47413. import { Material } from "babylonjs/Materials/material";
  47414. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47415. import "babylonjs/Shaders/glowMapMerge.fragment";
  47416. import "babylonjs/Shaders/glowMapMerge.vertex";
  47417. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47418. module "babylonjs/abstractScene" {
  47419. interface AbstractScene {
  47420. /**
  47421. * Return a the first highlight layer of the scene with a given name.
  47422. * @param name The name of the highlight layer to look for.
  47423. * @return The highlight layer if found otherwise null.
  47424. */
  47425. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47426. }
  47427. }
  47428. /**
  47429. * Highlight layer options. This helps customizing the behaviour
  47430. * of the highlight layer.
  47431. */
  47432. export interface IHighlightLayerOptions {
  47433. /**
  47434. * Multiplication factor apply to the canvas size to compute the render target size
  47435. * used to generated the glowing objects (the smaller the faster).
  47436. */
  47437. mainTextureRatio: number;
  47438. /**
  47439. * Enforces a fixed size texture to ensure resize independant blur.
  47440. */
  47441. mainTextureFixedSize?: number;
  47442. /**
  47443. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47444. * of the picture to blur (the smaller the faster).
  47445. */
  47446. blurTextureSizeRatio: number;
  47447. /**
  47448. * How big in texel of the blur texture is the vertical blur.
  47449. */
  47450. blurVerticalSize: number;
  47451. /**
  47452. * How big in texel of the blur texture is the horizontal blur.
  47453. */
  47454. blurHorizontalSize: number;
  47455. /**
  47456. * Alpha blending mode used to apply the blur. Default is combine.
  47457. */
  47458. alphaBlendingMode: number;
  47459. /**
  47460. * The camera attached to the layer.
  47461. */
  47462. camera: Nullable<Camera>;
  47463. /**
  47464. * Should we display highlight as a solid stroke?
  47465. */
  47466. isStroke?: boolean;
  47467. /**
  47468. * The rendering group to draw the layer in.
  47469. */
  47470. renderingGroupId: number;
  47471. }
  47472. /**
  47473. * The highlight layer Helps adding a glow effect around a mesh.
  47474. *
  47475. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47476. * glowy meshes to your scene.
  47477. *
  47478. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47479. */
  47480. export class HighlightLayer extends EffectLayer {
  47481. name: string;
  47482. /**
  47483. * Effect Name of the highlight layer.
  47484. */
  47485. static readonly EffectName: string;
  47486. /**
  47487. * The neutral color used during the preparation of the glow effect.
  47488. * This is black by default as the blend operation is a blend operation.
  47489. */
  47490. static NeutralColor: Color4;
  47491. /**
  47492. * Stencil value used for glowing meshes.
  47493. */
  47494. static GlowingMeshStencilReference: number;
  47495. /**
  47496. * Stencil value used for the other meshes in the scene.
  47497. */
  47498. static NormalMeshStencilReference: number;
  47499. /**
  47500. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47501. */
  47502. innerGlow: boolean;
  47503. /**
  47504. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47505. */
  47506. outerGlow: boolean;
  47507. /**
  47508. * Specifies the horizontal size of the blur.
  47509. */
  47510. /**
  47511. * Gets the horizontal size of the blur.
  47512. */
  47513. blurHorizontalSize: number;
  47514. /**
  47515. * Specifies the vertical size of the blur.
  47516. */
  47517. /**
  47518. * Gets the vertical size of the blur.
  47519. */
  47520. blurVerticalSize: number;
  47521. /**
  47522. * An event triggered when the highlight layer is being blurred.
  47523. */
  47524. onBeforeBlurObservable: Observable<HighlightLayer>;
  47525. /**
  47526. * An event triggered when the highlight layer has been blurred.
  47527. */
  47528. onAfterBlurObservable: Observable<HighlightLayer>;
  47529. private _instanceGlowingMeshStencilReference;
  47530. private _options;
  47531. private _downSamplePostprocess;
  47532. private _horizontalBlurPostprocess;
  47533. private _verticalBlurPostprocess;
  47534. private _blurTexture;
  47535. private _meshes;
  47536. private _excludedMeshes;
  47537. /**
  47538. * Instantiates a new highlight Layer and references it to the scene..
  47539. * @param name The name of the layer
  47540. * @param scene The scene to use the layer in
  47541. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47542. */
  47543. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47544. /**
  47545. * Get the effect name of the layer.
  47546. * @return The effect name
  47547. */
  47548. getEffectName(): string;
  47549. /**
  47550. * Create the merge effect. This is the shader use to blit the information back
  47551. * to the main canvas at the end of the scene rendering.
  47552. */
  47553. protected _createMergeEffect(): Effect;
  47554. /**
  47555. * Creates the render target textures and post processes used in the highlight layer.
  47556. */
  47557. protected _createTextureAndPostProcesses(): void;
  47558. /**
  47559. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47560. */
  47561. needStencil(): boolean;
  47562. /**
  47563. * Checks for the readiness of the element composing the layer.
  47564. * @param subMesh the mesh to check for
  47565. * @param useInstances specify wether or not to use instances to render the mesh
  47566. * @param emissiveTexture the associated emissive texture used to generate the glow
  47567. * @return true if ready otherwise, false
  47568. */
  47569. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47570. /**
  47571. * Implementation specific of rendering the generating effect on the main canvas.
  47572. * @param effect The effect used to render through
  47573. */
  47574. protected _internalRender(effect: Effect): void;
  47575. /**
  47576. * Returns true if the layer contains information to display, otherwise false.
  47577. */
  47578. shouldRender(): boolean;
  47579. /**
  47580. * Returns true if the mesh should render, otherwise false.
  47581. * @param mesh The mesh to render
  47582. * @returns true if it should render otherwise false
  47583. */
  47584. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47585. /**
  47586. * Sets the required values for both the emissive texture and and the main color.
  47587. */
  47588. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47589. /**
  47590. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47591. * @param mesh The mesh to exclude from the highlight layer
  47592. */
  47593. addExcludedMesh(mesh: Mesh): void;
  47594. /**
  47595. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47596. * @param mesh The mesh to highlight
  47597. */
  47598. removeExcludedMesh(mesh: Mesh): void;
  47599. /**
  47600. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47601. * @param mesh mesh to test
  47602. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47603. */
  47604. hasMesh(mesh: AbstractMesh): boolean;
  47605. /**
  47606. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47607. * @param mesh The mesh to highlight
  47608. * @param color The color of the highlight
  47609. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47610. */
  47611. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47612. /**
  47613. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47614. * @param mesh The mesh to highlight
  47615. */
  47616. removeMesh(mesh: Mesh): void;
  47617. /**
  47618. * Force the stencil to the normal expected value for none glowing parts
  47619. */
  47620. private _defaultStencilReference;
  47621. /**
  47622. * Free any resources and references associated to a mesh.
  47623. * Internal use
  47624. * @param mesh The mesh to free.
  47625. * @hidden
  47626. */
  47627. _disposeMesh(mesh: Mesh): void;
  47628. /**
  47629. * Dispose the highlight layer and free resources.
  47630. */
  47631. dispose(): void;
  47632. /**
  47633. * Gets the class name of the effect layer
  47634. * @returns the string with the class name of the effect layer
  47635. */
  47636. getClassName(): string;
  47637. /**
  47638. * Serializes this Highlight layer
  47639. * @returns a serialized Highlight layer object
  47640. */
  47641. serialize(): any;
  47642. /**
  47643. * Creates a Highlight layer from parsed Highlight layer data
  47644. * @param parsedHightlightLayer defines the Highlight layer data
  47645. * @param scene defines the current scene
  47646. * @param rootUrl defines the root URL containing the Highlight layer information
  47647. * @returns a parsed Highlight layer
  47648. */
  47649. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47650. }
  47651. }
  47652. declare module "babylonjs/Layers/index" {
  47653. export * from "babylonjs/Layers/effectLayer";
  47654. export * from "babylonjs/Layers/effectLayerSceneComponent";
  47655. export * from "babylonjs/Layers/glowLayer";
  47656. export * from "babylonjs/Layers/highlightLayer";
  47657. export * from "babylonjs/Layers/layer";
  47658. export * from "babylonjs/Layers/layerSceneComponent";
  47659. }
  47660. declare module "babylonjs/Shaders/lensFlare.fragment" {
  47661. /** @hidden */
  47662. export var lensFlarePixelShader: {
  47663. name: string;
  47664. shader: string;
  47665. };
  47666. }
  47667. declare module "babylonjs/Shaders/lensFlare.vertex" {
  47668. /** @hidden */
  47669. export var lensFlareVertexShader: {
  47670. name: string;
  47671. shader: string;
  47672. };
  47673. }
  47674. declare module "babylonjs/LensFlares/lensFlareSystem" {
  47675. import { Scene } from "babylonjs/scene";
  47676. import { Vector3, Viewport } from "babylonjs/Maths/math";
  47677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47678. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  47679. import "babylonjs/Shaders/lensFlare.fragment";
  47680. import "babylonjs/Shaders/lensFlare.vertex";
  47681. /**
  47682. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47683. * It is usually composed of several `lensFlare`.
  47684. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47685. */
  47686. export class LensFlareSystem {
  47687. /**
  47688. * Define the name of the lens flare system
  47689. */
  47690. name: string;
  47691. /**
  47692. * List of lens flares used in this system.
  47693. */
  47694. lensFlares: LensFlare[];
  47695. /**
  47696. * Define a limit from the border the lens flare can be visible.
  47697. */
  47698. borderLimit: number;
  47699. /**
  47700. * Define a viewport border we do not want to see the lens flare in.
  47701. */
  47702. viewportBorder: number;
  47703. /**
  47704. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47705. */
  47706. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47707. /**
  47708. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47709. */
  47710. layerMask: number;
  47711. /**
  47712. * Define the id of the lens flare system in the scene.
  47713. * (equal to name by default)
  47714. */
  47715. id: string;
  47716. private _scene;
  47717. private _emitter;
  47718. private _vertexBuffers;
  47719. private _indexBuffer;
  47720. private _effect;
  47721. private _positionX;
  47722. private _positionY;
  47723. private _isEnabled;
  47724. /** @hidden */
  47725. static _SceneComponentInitialization: (scene: Scene) => void;
  47726. /**
  47727. * Instantiates a lens flare system.
  47728. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47729. * It is usually composed of several `lensFlare`.
  47730. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47731. * @param name Define the name of the lens flare system in the scene
  47732. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47733. * @param scene Define the scene the lens flare system belongs to
  47734. */
  47735. constructor(
  47736. /**
  47737. * Define the name of the lens flare system
  47738. */
  47739. name: string, emitter: any, scene: Scene);
  47740. /**
  47741. * Define if the lens flare system is enabled.
  47742. */
  47743. isEnabled: boolean;
  47744. /**
  47745. * Get the scene the effects belongs to.
  47746. * @returns the scene holding the lens flare system
  47747. */
  47748. getScene(): Scene;
  47749. /**
  47750. * Get the emitter of the lens flare system.
  47751. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47752. * @returns the emitter of the lens flare system
  47753. */
  47754. getEmitter(): any;
  47755. /**
  47756. * Set the emitter of the lens flare system.
  47757. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47758. * @param newEmitter Define the new emitter of the system
  47759. */
  47760. setEmitter(newEmitter: any): void;
  47761. /**
  47762. * Get the lens flare system emitter position.
  47763. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47764. * @returns the position
  47765. */
  47766. getEmitterPosition(): Vector3;
  47767. /**
  47768. * @hidden
  47769. */
  47770. computeEffectivePosition(globalViewport: Viewport): boolean;
  47771. /** @hidden */
  47772. _isVisible(): boolean;
  47773. /**
  47774. * @hidden
  47775. */
  47776. render(): boolean;
  47777. /**
  47778. * Dispose and release the lens flare with its associated resources.
  47779. */
  47780. dispose(): void;
  47781. /**
  47782. * Parse a lens flare system from a JSON repressentation
  47783. * @param parsedLensFlareSystem Define the JSON to parse
  47784. * @param scene Define the scene the parsed system should be instantiated in
  47785. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47786. * @returns the parsed system
  47787. */
  47788. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47789. /**
  47790. * Serialize the current Lens Flare System into a JSON representation.
  47791. * @returns the serialized JSON
  47792. */
  47793. serialize(): any;
  47794. }
  47795. }
  47796. declare module "babylonjs/LensFlares/lensFlare" {
  47797. import { Nullable } from "babylonjs/types";
  47798. import { Color3 } from "babylonjs/Maths/math";
  47799. import { Texture } from "babylonjs/Materials/Textures/texture";
  47800. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47801. /**
  47802. * This represents one of the lens effect in a `lensFlareSystem`.
  47803. * It controls one of the indiviual texture used in the effect.
  47804. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47805. */
  47806. export class LensFlare {
  47807. /**
  47808. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47809. */
  47810. size: number;
  47811. /**
  47812. * 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.
  47813. */
  47814. position: number;
  47815. /**
  47816. * Define the lens color.
  47817. */
  47818. color: Color3;
  47819. /**
  47820. * Define the lens texture.
  47821. */
  47822. texture: Nullable<Texture>;
  47823. /**
  47824. * Define the alpha mode to render this particular lens.
  47825. */
  47826. alphaMode: number;
  47827. private _system;
  47828. /**
  47829. * Creates a new Lens Flare.
  47830. * This represents one of the lens effect in a `lensFlareSystem`.
  47831. * It controls one of the indiviual texture used in the effect.
  47832. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47833. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47834. * @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.
  47835. * @param color Define the lens color
  47836. * @param imgUrl Define the lens texture url
  47837. * @param system Define the `lensFlareSystem` this flare is part of
  47838. * @returns The newly created Lens Flare
  47839. */
  47840. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47841. /**
  47842. * Instantiates a new Lens Flare.
  47843. * This represents one of the lens effect in a `lensFlareSystem`.
  47844. * It controls one of the indiviual texture used in the effect.
  47845. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47846. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47847. * @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.
  47848. * @param color Define the lens color
  47849. * @param imgUrl Define the lens texture url
  47850. * @param system Define the `lensFlareSystem` this flare is part of
  47851. */
  47852. constructor(
  47853. /**
  47854. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47855. */
  47856. size: number,
  47857. /**
  47858. * 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.
  47859. */
  47860. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47861. /**
  47862. * Dispose and release the lens flare with its associated resources.
  47863. */
  47864. dispose(): void;
  47865. }
  47866. }
  47867. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47868. import { Nullable } from "babylonjs/types";
  47869. import { Scene } from "babylonjs/scene";
  47870. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47871. import { AbstractScene } from "babylonjs/abstractScene";
  47872. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47873. module "babylonjs/abstractScene" {
  47874. interface AbstractScene {
  47875. /**
  47876. * The list of lens flare system added to the scene
  47877. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47878. */
  47879. lensFlareSystems: Array<LensFlareSystem>;
  47880. /**
  47881. * Removes the given lens flare system from this scene.
  47882. * @param toRemove The lens flare system to remove
  47883. * @returns The index of the removed lens flare system
  47884. */
  47885. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47886. /**
  47887. * Adds the given lens flare system to this scene
  47888. * @param newLensFlareSystem The lens flare system to add
  47889. */
  47890. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47891. /**
  47892. * Gets a lens flare system using its name
  47893. * @param name defines the name to look for
  47894. * @returns the lens flare system or null if not found
  47895. */
  47896. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47897. /**
  47898. * Gets a lens flare system using its id
  47899. * @param id defines the id to look for
  47900. * @returns the lens flare system or null if not found
  47901. */
  47902. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47903. }
  47904. }
  47905. /**
  47906. * Defines the lens flare scene component responsible to manage any lens flares
  47907. * in a given scene.
  47908. */
  47909. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47910. /**
  47911. * The component name helpfull to identify the component in the list of scene components.
  47912. */
  47913. readonly name: string;
  47914. /**
  47915. * The scene the component belongs to.
  47916. */
  47917. scene: Scene;
  47918. /**
  47919. * Creates a new instance of the component for the given scene
  47920. * @param scene Defines the scene to register the component in
  47921. */
  47922. constructor(scene: Scene);
  47923. /**
  47924. * Registers the component in a given scene
  47925. */
  47926. register(): void;
  47927. /**
  47928. * Rebuilds the elements related to this component in case of
  47929. * context lost for instance.
  47930. */
  47931. rebuild(): void;
  47932. /**
  47933. * Adds all the element from the container to the scene
  47934. * @param container the container holding the elements
  47935. */
  47936. addFromContainer(container: AbstractScene): void;
  47937. /**
  47938. * Removes all the elements in the container from the scene
  47939. * @param container contains the elements to remove
  47940. */
  47941. removeFromContainer(container: AbstractScene): void;
  47942. /**
  47943. * Serializes the component data to the specified json object
  47944. * @param serializationObject The object to serialize to
  47945. */
  47946. serialize(serializationObject: any): void;
  47947. /**
  47948. * Disposes the component and the associated ressources.
  47949. */
  47950. dispose(): void;
  47951. private _draw;
  47952. }
  47953. }
  47954. declare module "babylonjs/LensFlares/index" {
  47955. export * from "babylonjs/LensFlares/lensFlare";
  47956. export * from "babylonjs/LensFlares/lensFlareSystem";
  47957. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47958. }
  47959. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47960. import { Scene } from "babylonjs/scene";
  47961. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47962. import { AbstractScene } from "babylonjs/abstractScene";
  47963. /**
  47964. * Defines the shadow generator component responsible to manage any shadow generators
  47965. * in a given scene.
  47966. */
  47967. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47968. /**
  47969. * The component name helpfull to identify the component in the list of scene components.
  47970. */
  47971. readonly name: string;
  47972. /**
  47973. * The scene the component belongs to.
  47974. */
  47975. scene: Scene;
  47976. /**
  47977. * Creates a new instance of the component for the given scene
  47978. * @param scene Defines the scene to register the component in
  47979. */
  47980. constructor(scene: Scene);
  47981. /**
  47982. * Registers the component in a given scene
  47983. */
  47984. register(): void;
  47985. /**
  47986. * Rebuilds the elements related to this component in case of
  47987. * context lost for instance.
  47988. */
  47989. rebuild(): void;
  47990. /**
  47991. * Serializes the component data to the specified json object
  47992. * @param serializationObject The object to serialize to
  47993. */
  47994. serialize(serializationObject: any): void;
  47995. /**
  47996. * Adds all the element from the container to the scene
  47997. * @param container the container holding the elements
  47998. */
  47999. addFromContainer(container: AbstractScene): void;
  48000. /**
  48001. * Removes all the elements in the container from the scene
  48002. * @param container contains the elements to remove
  48003. */
  48004. removeFromContainer(container: AbstractScene): void;
  48005. /**
  48006. * Rebuilds the elements related to this component in case of
  48007. * context lost for instance.
  48008. */
  48009. dispose(): void;
  48010. private _gatherRenderTargets;
  48011. }
  48012. }
  48013. declare module "babylonjs/Lights/Shadows/index" {
  48014. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48015. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48016. }
  48017. declare module "babylonjs/Lights/directionalLight" {
  48018. import { Camera } from "babylonjs/Cameras/camera";
  48019. import { Scene } from "babylonjs/scene";
  48020. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48022. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48023. import { Effect } from "babylonjs/Materials/effect";
  48024. /**
  48025. * A directional light is defined by a direction (what a surprise!).
  48026. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48027. * 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.
  48028. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48029. */
  48030. export class DirectionalLight extends ShadowLight {
  48031. private _shadowFrustumSize;
  48032. /**
  48033. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48034. */
  48035. /**
  48036. * Specifies a fix frustum size for the shadow generation.
  48037. */
  48038. shadowFrustumSize: number;
  48039. private _shadowOrthoScale;
  48040. /**
  48041. * Gets 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. /**
  48046. * Sets the shadow projection scale against the optimal computed one.
  48047. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48048. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48049. */
  48050. shadowOrthoScale: number;
  48051. /**
  48052. * Automatically compute the projection matrix to best fit (including all the casters)
  48053. * on each frame.
  48054. */
  48055. autoUpdateExtends: boolean;
  48056. private _orthoLeft;
  48057. private _orthoRight;
  48058. private _orthoTop;
  48059. private _orthoBottom;
  48060. /**
  48061. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48062. * The directional light is emitted from everywhere in the given direction.
  48063. * It can cast shadows.
  48064. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48065. * @param name The friendly name of the light
  48066. * @param direction The direction of the light
  48067. * @param scene The scene the light belongs to
  48068. */
  48069. constructor(name: string, direction: Vector3, scene: Scene);
  48070. /**
  48071. * Returns the string "DirectionalLight".
  48072. * @return The class name
  48073. */
  48074. getClassName(): string;
  48075. /**
  48076. * Returns the integer 1.
  48077. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48078. */
  48079. getTypeID(): number;
  48080. /**
  48081. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48085. /**
  48086. * Sets the passed matrix "matrix" as fixed frustum 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 _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48090. /**
  48091. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48092. * Returns the DirectionalLight Shadow projection matrix.
  48093. */
  48094. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48095. protected _buildUniformLayout(): void;
  48096. /**
  48097. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48098. * @param effect The effect to update
  48099. * @param lightIndex The index of the light in the effect to update
  48100. * @returns The directional light
  48101. */
  48102. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48103. /**
  48104. * Gets the minZ used for shadow according to both the scene and the light.
  48105. *
  48106. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48107. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48108. * @param activeCamera The camera we are returning the min for
  48109. * @returns the depth min z
  48110. */
  48111. getDepthMinZ(activeCamera: Camera): number;
  48112. /**
  48113. * Gets the maxZ used for shadow according to both the scene and the light.
  48114. *
  48115. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48116. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48117. * @param activeCamera The camera we are returning the max for
  48118. * @returns the depth max z
  48119. */
  48120. getDepthMaxZ(activeCamera: Camera): number;
  48121. /**
  48122. * Prepares the list of defines specific to the light type.
  48123. * @param defines the list of defines
  48124. * @param lightIndex defines the index of the light for the effect
  48125. */
  48126. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48127. }
  48128. }
  48129. declare module "babylonjs/Lights/pointLight" {
  48130. import { Scene } from "babylonjs/scene";
  48131. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48133. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48134. import { Effect } from "babylonjs/Materials/effect";
  48135. /**
  48136. * A point light is a light defined by an unique point in world space.
  48137. * The light is emitted in every direction from this point.
  48138. * A good example of a point light is a standard light bulb.
  48139. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48140. */
  48141. export class PointLight extends ShadowLight {
  48142. private _shadowAngle;
  48143. /**
  48144. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48145. * This specifies what angle the shadow will use to be created.
  48146. *
  48147. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48148. */
  48149. /**
  48150. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48151. * This specifies what angle the shadow will use to be created.
  48152. *
  48153. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48154. */
  48155. shadowAngle: number;
  48156. /**
  48157. * Gets the direction if it has been set.
  48158. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48159. */
  48160. /**
  48161. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48162. */
  48163. direction: Vector3;
  48164. /**
  48165. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48166. * A PointLight emits the light in every direction.
  48167. * It can cast shadows.
  48168. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48169. * ```javascript
  48170. * var pointLight = new PointLight("pl", camera.position, scene);
  48171. * ```
  48172. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48173. * @param name The light friendly name
  48174. * @param position The position of the point light in the scene
  48175. * @param scene The scene the lights belongs to
  48176. */
  48177. constructor(name: string, position: Vector3, scene: Scene);
  48178. /**
  48179. * Returns the string "PointLight"
  48180. * @returns the class name
  48181. */
  48182. getClassName(): string;
  48183. /**
  48184. * Returns the integer 0.
  48185. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48186. */
  48187. getTypeID(): number;
  48188. /**
  48189. * Specifies wether or not the shadowmap should be a cube texture.
  48190. * @returns true if the shadowmap needs to be a cube texture.
  48191. */
  48192. needCube(): boolean;
  48193. /**
  48194. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48195. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48196. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48197. */
  48198. getShadowDirection(faceIndex?: number): Vector3;
  48199. /**
  48200. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48201. * - fov = PI / 2
  48202. * - aspect ratio : 1.0
  48203. * - z-near and far equal to the active camera minZ and maxZ.
  48204. * Returns the PointLight.
  48205. */
  48206. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48207. protected _buildUniformLayout(): void;
  48208. /**
  48209. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48210. * @param effect The effect to update
  48211. * @param lightIndex The index of the light in the effect to update
  48212. * @returns The point light
  48213. */
  48214. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48215. /**
  48216. * Prepares the list of defines specific to the light type.
  48217. * @param defines the list of defines
  48218. * @param lightIndex defines the index of the light for the effect
  48219. */
  48220. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48221. }
  48222. }
  48223. declare module "babylonjs/Lights/spotLight" {
  48224. import { Nullable } from "babylonjs/types";
  48225. import { Scene } from "babylonjs/scene";
  48226. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48228. import { Effect } from "babylonjs/Materials/effect";
  48229. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48230. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48231. /**
  48232. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48233. * These values define a cone of light starting from the position, emitting toward the direction.
  48234. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48235. * and the exponent defines the speed of the decay of the light with distance (reach).
  48236. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48237. */
  48238. export class SpotLight extends ShadowLight {
  48239. private _angle;
  48240. private _innerAngle;
  48241. private _cosHalfAngle;
  48242. private _lightAngleScale;
  48243. private _lightAngleOffset;
  48244. /**
  48245. * Gets the cone angle of the spot light in Radians.
  48246. */
  48247. /**
  48248. * Sets the cone angle of the spot light in Radians.
  48249. */
  48250. angle: number;
  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. /**
  48257. * Only used in gltf falloff mode, this defines the angle where
  48258. * the directional falloff will start before cutting at angle which could be seen
  48259. * as outer angle.
  48260. */
  48261. innerAngle: number;
  48262. private _shadowAngleScale;
  48263. /**
  48264. * Allows scaling the angle of the light for shadow generation only.
  48265. */
  48266. /**
  48267. * Allows scaling the angle of the light for shadow generation only.
  48268. */
  48269. shadowAngleScale: number;
  48270. /**
  48271. * The light decay speed with the distance from the emission spot.
  48272. */
  48273. exponent: number;
  48274. private _projectionTextureMatrix;
  48275. /**
  48276. * Allows reading the projecton texture
  48277. */
  48278. readonly projectionTextureMatrix: Matrix;
  48279. protected _projectionTextureLightNear: number;
  48280. /**
  48281. * Gets the near clip of the Spotlight for texture projection.
  48282. */
  48283. /**
  48284. * Sets the near clip of the Spotlight for texture projection.
  48285. */
  48286. projectionTextureLightNear: number;
  48287. protected _projectionTextureLightFar: number;
  48288. /**
  48289. * Gets the far clip of the Spotlight for texture projection.
  48290. */
  48291. /**
  48292. * Sets the far clip of the Spotlight for texture projection.
  48293. */
  48294. projectionTextureLightFar: number;
  48295. protected _projectionTextureUpDirection: Vector3;
  48296. /**
  48297. * Gets the Up vector of the Spotlight for texture projection.
  48298. */
  48299. /**
  48300. * Sets the Up vector of the Spotlight for texture projection.
  48301. */
  48302. projectionTextureUpDirection: Vector3;
  48303. private _projectionTexture;
  48304. /**
  48305. * Gets the projection texture of the light.
  48306. */
  48307. /**
  48308. * Sets the projection texture of the light.
  48309. */
  48310. projectionTexture: Nullable<BaseTexture>;
  48311. private _projectionTextureViewLightDirty;
  48312. private _projectionTextureProjectionLightDirty;
  48313. private _projectionTextureDirty;
  48314. private _projectionTextureViewTargetVector;
  48315. private _projectionTextureViewLightMatrix;
  48316. private _projectionTextureProjectionLightMatrix;
  48317. private _projectionTextureScalingMatrix;
  48318. /**
  48319. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48320. * It can cast shadows.
  48321. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48322. * @param name The light friendly name
  48323. * @param position The position of the spot light in the scene
  48324. * @param direction The direction of the light in the scene
  48325. * @param angle The cone angle of the light in Radians
  48326. * @param exponent The light decay speed with the distance from the emission spot
  48327. * @param scene The scene the lights belongs to
  48328. */
  48329. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48330. /**
  48331. * Returns the string "SpotLight".
  48332. * @returns the class name
  48333. */
  48334. getClassName(): string;
  48335. /**
  48336. * Returns the integer 2.
  48337. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48338. */
  48339. getTypeID(): number;
  48340. /**
  48341. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48342. */
  48343. protected _setDirection(value: Vector3): void;
  48344. /**
  48345. * Overrides the position setter to recompute the projection texture view light Matrix.
  48346. */
  48347. protected _setPosition(value: Vector3): void;
  48348. /**
  48349. * 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.
  48350. * Returns the SpotLight.
  48351. */
  48352. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48353. protected _computeProjectionTextureViewLightMatrix(): void;
  48354. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48355. /**
  48356. * Main function for light texture projection matrix computing.
  48357. */
  48358. protected _computeProjectionTextureMatrix(): void;
  48359. protected _buildUniformLayout(): void;
  48360. private _computeAngleValues;
  48361. /**
  48362. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48363. * @param effect The effect to update
  48364. * @param lightIndex The index of the light in the effect to update
  48365. * @returns The spot light
  48366. */
  48367. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48368. /**
  48369. * Disposes the light and the associated resources.
  48370. */
  48371. dispose(): void;
  48372. /**
  48373. * Prepares the list of defines specific to the light type.
  48374. * @param defines the list of defines
  48375. * @param lightIndex defines the index of the light for the effect
  48376. */
  48377. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48378. }
  48379. }
  48380. declare module "babylonjs/Lights/index" {
  48381. export * from "babylonjs/Lights/light";
  48382. export * from "babylonjs/Lights/shadowLight";
  48383. export * from "babylonjs/Lights/Shadows/index";
  48384. export * from "babylonjs/Lights/directionalLight";
  48385. export * from "babylonjs/Lights/hemisphericLight";
  48386. export * from "babylonjs/Lights/pointLight";
  48387. export * from "babylonjs/Lights/spotLight";
  48388. }
  48389. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48390. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48391. /**
  48392. * Header information of HDR texture files.
  48393. */
  48394. export interface HDRInfo {
  48395. /**
  48396. * The height of the texture in pixels.
  48397. */
  48398. height: number;
  48399. /**
  48400. * The width of the texture in pixels.
  48401. */
  48402. width: number;
  48403. /**
  48404. * The index of the beginning of the data in the binary file.
  48405. */
  48406. dataPosition: number;
  48407. }
  48408. /**
  48409. * This groups tools to convert HDR texture to native colors array.
  48410. */
  48411. export class HDRTools {
  48412. private static Ldexp;
  48413. private static Rgbe2float;
  48414. private static readStringLine;
  48415. /**
  48416. * Reads header information from an RGBE texture stored in a native array.
  48417. * More information on this format are available here:
  48418. * https://en.wikipedia.org/wiki/RGBE_image_format
  48419. *
  48420. * @param uint8array The binary file stored in native array.
  48421. * @return The header information.
  48422. */
  48423. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48424. /**
  48425. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48426. * This RGBE texture needs to store the information as a panorama.
  48427. *
  48428. * More information on this format are available here:
  48429. * https://en.wikipedia.org/wiki/RGBE_image_format
  48430. *
  48431. * @param buffer The binary file stored in an array buffer.
  48432. * @param size The expected size of the extracted cubemap.
  48433. * @return The Cube Map information.
  48434. */
  48435. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48436. /**
  48437. * Returns the pixels data extracted from an RGBE texture.
  48438. * This pixels will be stored left to right up to down in the R G B order in one array.
  48439. *
  48440. * More information on this format are available here:
  48441. * https://en.wikipedia.org/wiki/RGBE_image_format
  48442. *
  48443. * @param uint8array The binary file stored in an array buffer.
  48444. * @param hdrInfo The header information of the file.
  48445. * @return The pixels data in RGB right to left up to down order.
  48446. */
  48447. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48448. private static RGBE_ReadPixels_RLE;
  48449. }
  48450. }
  48451. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48452. import { Nullable } from "babylonjs/types";
  48453. import { Scene } from "babylonjs/scene";
  48454. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48456. /**
  48457. * This represents a texture coming from an HDR input.
  48458. *
  48459. * The only supported format is currently panorama picture stored in RGBE format.
  48460. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48461. */
  48462. export class HDRCubeTexture extends BaseTexture {
  48463. private static _facesMapping;
  48464. private _generateHarmonics;
  48465. private _noMipmap;
  48466. private _textureMatrix;
  48467. private _size;
  48468. private _onLoad;
  48469. private _onError;
  48470. /**
  48471. * The texture URL.
  48472. */
  48473. url: string;
  48474. /**
  48475. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48476. */
  48477. coordinatesMode: number;
  48478. protected _isBlocking: boolean;
  48479. /**
  48480. * Sets wether or not the texture is blocking during loading.
  48481. */
  48482. /**
  48483. * Gets wether or not the texture is blocking during loading.
  48484. */
  48485. isBlocking: boolean;
  48486. protected _rotationY: number;
  48487. /**
  48488. * Sets texture matrix rotation angle around Y axis in radians.
  48489. */
  48490. /**
  48491. * Gets texture matrix rotation angle around Y axis radians.
  48492. */
  48493. rotationY: number;
  48494. /**
  48495. * Gets or sets the center of the bounding box associated with the cube texture
  48496. * It must define where the camera used to render the texture was set
  48497. */
  48498. boundingBoxPosition: Vector3;
  48499. private _boundingBoxSize;
  48500. /**
  48501. * Gets or sets the size of the bounding box associated with the cube texture
  48502. * When defined, the cubemap will switch to local mode
  48503. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48504. * @example https://www.babylonjs-playground.com/#RNASML
  48505. */
  48506. boundingBoxSize: Vector3;
  48507. /**
  48508. * Instantiates an HDRTexture from the following parameters.
  48509. *
  48510. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48511. * @param scene The scene the texture will be used in
  48512. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48513. * @param noMipmap Forces to not generate the mipmap if true
  48514. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48515. * @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)
  48516. * @param reserved Reserved flag for internal use.
  48517. */
  48518. 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>);
  48519. /**
  48520. * Get the current class name of the texture useful for serialization or dynamic coding.
  48521. * @returns "HDRCubeTexture"
  48522. */
  48523. getClassName(): string;
  48524. /**
  48525. * Occurs when the file is raw .hdr file.
  48526. */
  48527. private loadTexture;
  48528. clone(): HDRCubeTexture;
  48529. delayLoad(): void;
  48530. /**
  48531. * Get the texture reflection matrix used to rotate/transform the reflection.
  48532. * @returns the reflection matrix
  48533. */
  48534. getReflectionTextureMatrix(): Matrix;
  48535. /**
  48536. * Set the texture reflection matrix used to rotate/transform the reflection.
  48537. * @param value Define the reflection matrix to set
  48538. */
  48539. setReflectionTextureMatrix(value: Matrix): void;
  48540. /**
  48541. * Parses a JSON representation of an HDR Texture in order to create the texture
  48542. * @param parsedTexture Define the JSON representation
  48543. * @param scene Define the scene the texture should be created in
  48544. * @param rootUrl Define the root url in case we need to load relative dependencies
  48545. * @returns the newly created texture after parsing
  48546. */
  48547. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48548. serialize(): any;
  48549. }
  48550. }
  48551. declare module "babylonjs/Physics/physicsEngine" {
  48552. import { Nullable } from "babylonjs/types";
  48553. import { Vector3 } from "babylonjs/Maths/math";
  48554. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48555. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48556. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48557. /**
  48558. * Class used to control physics engine
  48559. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48560. */
  48561. export class PhysicsEngine implements IPhysicsEngine {
  48562. private _physicsPlugin;
  48563. /**
  48564. * Global value used to control the smallest number supported by the simulation
  48565. */
  48566. static Epsilon: number;
  48567. private _impostors;
  48568. private _joints;
  48569. /**
  48570. * Gets the gravity vector used by the simulation
  48571. */
  48572. gravity: Vector3;
  48573. /**
  48574. * Factory used to create the default physics plugin.
  48575. * @returns The default physics plugin
  48576. */
  48577. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48578. /**
  48579. * Creates a new Physics Engine
  48580. * @param gravity defines the gravity vector used by the simulation
  48581. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48582. */
  48583. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48584. /**
  48585. * Sets the gravity vector used by the simulation
  48586. * @param gravity defines the gravity vector to use
  48587. */
  48588. setGravity(gravity: Vector3): void;
  48589. /**
  48590. * Set the time step of the physics engine.
  48591. * Default is 1/60.
  48592. * To slow it down, enter 1/600 for example.
  48593. * To speed it up, 1/30
  48594. * @param newTimeStep defines the new timestep to apply to this world.
  48595. */
  48596. setTimeStep(newTimeStep?: number): void;
  48597. /**
  48598. * Get the time step of the physics engine.
  48599. * @returns the current time step
  48600. */
  48601. getTimeStep(): number;
  48602. /**
  48603. * Release all resources
  48604. */
  48605. dispose(): void;
  48606. /**
  48607. * Gets the name of the current physics plugin
  48608. * @returns the name of the plugin
  48609. */
  48610. getPhysicsPluginName(): string;
  48611. /**
  48612. * Adding a new impostor for the impostor tracking.
  48613. * This will be done by the impostor itself.
  48614. * @param impostor the impostor to add
  48615. */
  48616. addImpostor(impostor: PhysicsImpostor): void;
  48617. /**
  48618. * Remove an impostor from the engine.
  48619. * This impostor and its mesh will not longer be updated by the physics engine.
  48620. * @param impostor the impostor to remove
  48621. */
  48622. removeImpostor(impostor: PhysicsImpostor): void;
  48623. /**
  48624. * Add a joint to the physics engine
  48625. * @param mainImpostor defines the main impostor to which the joint is added.
  48626. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48627. * @param joint defines the joint that will connect both impostors.
  48628. */
  48629. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48630. /**
  48631. * Removes a joint from the simulation
  48632. * @param mainImpostor defines the impostor used with the joint
  48633. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48634. * @param joint defines the joint to remove
  48635. */
  48636. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48637. /**
  48638. * Called by the scene. No need to call it.
  48639. * @param delta defines the timespam between frames
  48640. */
  48641. _step(delta: number): void;
  48642. /**
  48643. * Gets the current plugin used to run the simulation
  48644. * @returns current plugin
  48645. */
  48646. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48647. /**
  48648. * Gets the list of physic impostors
  48649. * @returns an array of PhysicsImpostor
  48650. */
  48651. getImpostors(): Array<PhysicsImpostor>;
  48652. /**
  48653. * Gets the impostor for a physics enabled object
  48654. * @param object defines the object impersonated by the impostor
  48655. * @returns the PhysicsImpostor or null if not found
  48656. */
  48657. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48658. /**
  48659. * Gets the impostor for a physics body object
  48660. * @param body defines physics body used by the impostor
  48661. * @returns the PhysicsImpostor or null if not found
  48662. */
  48663. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48664. }
  48665. }
  48666. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  48667. import { Nullable } from "babylonjs/types";
  48668. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48670. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48671. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48672. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48673. /** @hidden */
  48674. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48675. private _useDeltaForWorldStep;
  48676. world: any;
  48677. name: string;
  48678. private _physicsMaterials;
  48679. private _fixedTimeStep;
  48680. BJSCANNON: any;
  48681. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48682. setGravity(gravity: Vector3): void;
  48683. setTimeStep(timeStep: number): void;
  48684. getTimeStep(): number;
  48685. executeStep(delta: number): void;
  48686. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48687. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48688. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48689. private _processChildMeshes;
  48690. removePhysicsBody(impostor: PhysicsImpostor): void;
  48691. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48692. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48693. private _addMaterial;
  48694. private _checkWithEpsilon;
  48695. private _createShape;
  48696. private _createHeightmap;
  48697. private _minus90X;
  48698. private _plus90X;
  48699. private _tmpPosition;
  48700. private _tmpDeltaPosition;
  48701. private _tmpUnityRotation;
  48702. private _updatePhysicsBodyTransformation;
  48703. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48704. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48705. isSupported(): boolean;
  48706. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48707. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48708. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48709. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48710. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48711. getBodyMass(impostor: PhysicsImpostor): number;
  48712. getBodyFriction(impostor: PhysicsImpostor): number;
  48713. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48714. getBodyRestitution(impostor: PhysicsImpostor): number;
  48715. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48716. sleepBody(impostor: PhysicsImpostor): void;
  48717. wakeUpBody(impostor: PhysicsImpostor): void;
  48718. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48719. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48720. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48721. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48722. getRadius(impostor: PhysicsImpostor): number;
  48723. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48724. dispose(): void;
  48725. private _extendNamespace;
  48726. }
  48727. }
  48728. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48729. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48730. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48731. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48733. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48734. import { Nullable } from "babylonjs/types";
  48735. /** @hidden */
  48736. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48737. world: any;
  48738. name: string;
  48739. BJSOIMO: any;
  48740. constructor(iterations?: number, oimoInjection?: any);
  48741. setGravity(gravity: Vector3): void;
  48742. setTimeStep(timeStep: number): void;
  48743. getTimeStep(): number;
  48744. private _tmpImpostorsArray;
  48745. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48746. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48747. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48748. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48749. private _tmpPositionVector;
  48750. removePhysicsBody(impostor: PhysicsImpostor): void;
  48751. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48752. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48753. isSupported(): boolean;
  48754. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48755. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48756. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48757. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48758. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48759. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48760. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48761. getBodyMass(impostor: PhysicsImpostor): number;
  48762. getBodyFriction(impostor: PhysicsImpostor): number;
  48763. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48764. getBodyRestitution(impostor: PhysicsImpostor): number;
  48765. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48766. sleepBody(impostor: PhysicsImpostor): void;
  48767. wakeUpBody(impostor: PhysicsImpostor): void;
  48768. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48769. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48770. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48771. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48772. getRadius(impostor: PhysicsImpostor): number;
  48773. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48774. dispose(): void;
  48775. }
  48776. }
  48777. declare module "babylonjs/Probes/reflectionProbe" {
  48778. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48779. import { Vector3 } from "babylonjs/Maths/math";
  48780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48781. import { Nullable } from "babylonjs/types";
  48782. import { Scene } from "babylonjs/scene";
  48783. module "babylonjs/abstractScene" {
  48784. interface AbstractScene {
  48785. /**
  48786. * The list of reflection probes added to the scene
  48787. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48788. */
  48789. reflectionProbes: Array<ReflectionProbe>;
  48790. /**
  48791. * Removes the given reflection probe from this scene.
  48792. * @param toRemove The reflection probe to remove
  48793. * @returns The index of the removed reflection probe
  48794. */
  48795. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48796. /**
  48797. * Adds the given reflection probe to this scene.
  48798. * @param newReflectionProbe The reflection probe to add
  48799. */
  48800. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48801. }
  48802. }
  48803. /**
  48804. * Class used to generate realtime reflection / refraction cube textures
  48805. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48806. */
  48807. export class ReflectionProbe {
  48808. /** defines the name of the probe */
  48809. name: string;
  48810. private _scene;
  48811. private _renderTargetTexture;
  48812. private _projectionMatrix;
  48813. private _viewMatrix;
  48814. private _target;
  48815. private _add;
  48816. private _attachedMesh;
  48817. private _invertYAxis;
  48818. /** Gets or sets probe position (center of the cube map) */
  48819. position: Vector3;
  48820. /**
  48821. * Creates a new reflection probe
  48822. * @param name defines the name of the probe
  48823. * @param size defines the texture resolution (for each face)
  48824. * @param scene defines the hosting scene
  48825. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48826. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48827. */
  48828. constructor(
  48829. /** defines the name of the probe */
  48830. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48831. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48832. samples: number;
  48833. /** Gets or sets the refresh rate to use (on every frame by default) */
  48834. refreshRate: number;
  48835. /**
  48836. * Gets the hosting scene
  48837. * @returns a Scene
  48838. */
  48839. getScene(): Scene;
  48840. /** Gets the internal CubeTexture used to render to */
  48841. readonly cubeTexture: RenderTargetTexture;
  48842. /** Gets the list of meshes to render */
  48843. readonly renderList: Nullable<AbstractMesh[]>;
  48844. /**
  48845. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48846. * @param mesh defines the mesh to attach to
  48847. */
  48848. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48849. /**
  48850. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48851. * @param renderingGroupId The rendering group id corresponding to its index
  48852. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48853. */
  48854. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48855. /**
  48856. * Clean all associated resources
  48857. */
  48858. dispose(): void;
  48859. /**
  48860. * Converts the reflection probe information to a readable string for debug purpose.
  48861. * @param fullDetails Supports for multiple levels of logging within scene loading
  48862. * @returns the human readable reflection probe info
  48863. */
  48864. toString(fullDetails?: boolean): string;
  48865. /**
  48866. * Get the class name of the relfection probe.
  48867. * @returns "ReflectionProbe"
  48868. */
  48869. getClassName(): string;
  48870. /**
  48871. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48872. * @returns The JSON representation of the texture
  48873. */
  48874. serialize(): any;
  48875. /**
  48876. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48877. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48878. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48879. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48880. * @returns The parsed reflection probe if successful
  48881. */
  48882. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48883. }
  48884. }
  48885. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48886. /** @hidden */
  48887. export var _BabylonLoaderRegistered: boolean;
  48888. }
  48889. declare module "babylonjs/Loading/Plugins/index" {
  48890. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48891. }
  48892. declare module "babylonjs/Loading/index" {
  48893. export * from "babylonjs/Loading/loadingScreen";
  48894. export * from "babylonjs/Loading/Plugins/index";
  48895. export * from "babylonjs/Loading/sceneLoader";
  48896. export * from "babylonjs/Loading/sceneLoaderFlags";
  48897. }
  48898. declare module "babylonjs/Materials/Background/index" {
  48899. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48900. }
  48901. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48902. import { Scene } from "babylonjs/scene";
  48903. import { Color3 } from "babylonjs/Maths/math";
  48904. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48906. /**
  48907. * The Physically based simple base material of BJS.
  48908. *
  48909. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48910. * It is used as the base class for both the specGloss and metalRough conventions.
  48911. */
  48912. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48913. /**
  48914. * Number of Simultaneous lights allowed on the material.
  48915. */
  48916. maxSimultaneousLights: number;
  48917. /**
  48918. * If sets to true, disables all the lights affecting the material.
  48919. */
  48920. disableLighting: boolean;
  48921. /**
  48922. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48923. */
  48924. environmentTexture: BaseTexture;
  48925. /**
  48926. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48927. */
  48928. invertNormalMapX: boolean;
  48929. /**
  48930. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48931. */
  48932. invertNormalMapY: boolean;
  48933. /**
  48934. * Normal map used in the model.
  48935. */
  48936. normalTexture: BaseTexture;
  48937. /**
  48938. * Emissivie color used to self-illuminate the model.
  48939. */
  48940. emissiveColor: Color3;
  48941. /**
  48942. * Emissivie texture used to self-illuminate the model.
  48943. */
  48944. emissiveTexture: BaseTexture;
  48945. /**
  48946. * Occlusion Channel Strenght.
  48947. */
  48948. occlusionStrength: number;
  48949. /**
  48950. * Occlusion Texture of the material (adding extra occlusion effects).
  48951. */
  48952. occlusionTexture: BaseTexture;
  48953. /**
  48954. * Defines the alpha limits in alpha test mode.
  48955. */
  48956. alphaCutOff: number;
  48957. /**
  48958. * Gets the current double sided mode.
  48959. */
  48960. /**
  48961. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48962. */
  48963. doubleSided: boolean;
  48964. /**
  48965. * Stores the pre-calculated light information of a mesh in a texture.
  48966. */
  48967. lightmapTexture: BaseTexture;
  48968. /**
  48969. * If true, the light map contains occlusion information instead of lighting info.
  48970. */
  48971. useLightmapAsShadowmap: boolean;
  48972. /**
  48973. * Instantiates a new PBRMaterial instance.
  48974. *
  48975. * @param name The material name
  48976. * @param scene The scene the material will be use in.
  48977. */
  48978. constructor(name: string, scene: Scene);
  48979. getClassName(): string;
  48980. }
  48981. }
  48982. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48983. import { Scene } from "babylonjs/scene";
  48984. import { Color3 } from "babylonjs/Maths/math";
  48985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48986. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48987. /**
  48988. * The PBR material of BJS following the metal roughness convention.
  48989. *
  48990. * This fits to the PBR convention in the GLTF definition:
  48991. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48992. */
  48993. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48994. /**
  48995. * The base color has two different interpretations depending on the value of metalness.
  48996. * When the material is a metal, the base color is the specific measured reflectance value
  48997. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48998. * of the material.
  48999. */
  49000. baseColor: Color3;
  49001. /**
  49002. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49003. * well as opacity information in the alpha channel.
  49004. */
  49005. baseTexture: BaseTexture;
  49006. /**
  49007. * Specifies the metallic scalar value of the material.
  49008. * Can also be used to scale the metalness values of the metallic texture.
  49009. */
  49010. metallic: number;
  49011. /**
  49012. * Specifies the roughness scalar value of the material.
  49013. * Can also be used to scale the roughness values of the metallic texture.
  49014. */
  49015. roughness: number;
  49016. /**
  49017. * Texture containing both the metallic value in the B channel and the
  49018. * roughness value in the G channel to keep better precision.
  49019. */
  49020. metallicRoughnessTexture: BaseTexture;
  49021. /**
  49022. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49023. *
  49024. * @param name The material name
  49025. * @param scene The scene the material will be use in.
  49026. */
  49027. constructor(name: string, scene: Scene);
  49028. /**
  49029. * Return the currrent class name of the material.
  49030. */
  49031. getClassName(): string;
  49032. /**
  49033. * Makes a duplicate of the current material.
  49034. * @param name - name to use for the new material.
  49035. */
  49036. clone(name: string): PBRMetallicRoughnessMaterial;
  49037. /**
  49038. * Serialize the material to a parsable JSON object.
  49039. */
  49040. serialize(): any;
  49041. /**
  49042. * Parses a JSON object correponding to the serialize function.
  49043. */
  49044. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49045. }
  49046. }
  49047. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49048. import { Scene } from "babylonjs/scene";
  49049. import { Color3 } from "babylonjs/Maths/math";
  49050. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49051. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49052. /**
  49053. * The PBR material of BJS following the specular glossiness convention.
  49054. *
  49055. * This fits to the PBR convention in the GLTF definition:
  49056. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49057. */
  49058. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49059. /**
  49060. * Specifies the diffuse color of the material.
  49061. */
  49062. diffuseColor: Color3;
  49063. /**
  49064. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49065. * channel.
  49066. */
  49067. diffuseTexture: BaseTexture;
  49068. /**
  49069. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49070. */
  49071. specularColor: Color3;
  49072. /**
  49073. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49074. */
  49075. glossiness: number;
  49076. /**
  49077. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49078. */
  49079. specularGlossinessTexture: BaseTexture;
  49080. /**
  49081. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49082. *
  49083. * @param name The material name
  49084. * @param scene The scene the material will be use in.
  49085. */
  49086. constructor(name: string, scene: Scene);
  49087. /**
  49088. * Return the currrent class name of the material.
  49089. */
  49090. getClassName(): string;
  49091. /**
  49092. * Makes a duplicate of the current material.
  49093. * @param name - name to use for the new material.
  49094. */
  49095. clone(name: string): PBRSpecularGlossinessMaterial;
  49096. /**
  49097. * Serialize the material to a parsable JSON object.
  49098. */
  49099. serialize(): any;
  49100. /**
  49101. * Parses a JSON object correponding to the serialize function.
  49102. */
  49103. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49104. }
  49105. }
  49106. declare module "babylonjs/Materials/PBR/index" {
  49107. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49108. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49109. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49110. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49111. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49112. }
  49113. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49114. import { Nullable } from "babylonjs/types";
  49115. import { Scene } from "babylonjs/scene";
  49116. import { Matrix } from "babylonjs/Maths/math";
  49117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49118. /**
  49119. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49120. * It can help converting any input color in a desired output one. This can then be used to create effects
  49121. * from sepia, black and white to sixties or futuristic rendering...
  49122. *
  49123. * The only supported format is currently 3dl.
  49124. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49125. */
  49126. export class ColorGradingTexture extends BaseTexture {
  49127. /**
  49128. * The current texture matrix. (will always be identity in color grading texture)
  49129. */
  49130. private _textureMatrix;
  49131. /**
  49132. * The texture URL.
  49133. */
  49134. url: string;
  49135. /**
  49136. * Empty line regex stored for GC.
  49137. */
  49138. private static _noneEmptyLineRegex;
  49139. private _engine;
  49140. /**
  49141. * Instantiates a ColorGradingTexture from the following parameters.
  49142. *
  49143. * @param url The location of the color gradind data (currently only supporting 3dl)
  49144. * @param scene The scene the texture will be used in
  49145. */
  49146. constructor(url: string, scene: Scene);
  49147. /**
  49148. * Returns the texture matrix used in most of the material.
  49149. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49150. */
  49151. getTextureMatrix(): Matrix;
  49152. /**
  49153. * Occurs when the file being loaded is a .3dl LUT file.
  49154. */
  49155. private load3dlTexture;
  49156. /**
  49157. * Starts the loading process of the texture.
  49158. */
  49159. private loadTexture;
  49160. /**
  49161. * Clones the color gradind texture.
  49162. */
  49163. clone(): ColorGradingTexture;
  49164. /**
  49165. * Called during delayed load for textures.
  49166. */
  49167. delayLoad(): void;
  49168. /**
  49169. * Parses a color grading texture serialized by Babylon.
  49170. * @param parsedTexture The texture information being parsedTexture
  49171. * @param scene The scene to load the texture in
  49172. * @param rootUrl The root url of the data assets to load
  49173. * @return A color gradind texture
  49174. */
  49175. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49176. /**
  49177. * Serializes the LUT texture to json format.
  49178. */
  49179. serialize(): any;
  49180. }
  49181. }
  49182. declare module "babylonjs/Misc/tga" {
  49183. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49184. /**
  49185. * Based on jsTGALoader - Javascript loader for TGA file
  49186. * By Vincent Thibault
  49187. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49188. */
  49189. export class TGATools {
  49190. private static _TYPE_INDEXED;
  49191. private static _TYPE_RGB;
  49192. private static _TYPE_GREY;
  49193. private static _TYPE_RLE_INDEXED;
  49194. private static _TYPE_RLE_RGB;
  49195. private static _TYPE_RLE_GREY;
  49196. private static _ORIGIN_MASK;
  49197. private static _ORIGIN_SHIFT;
  49198. private static _ORIGIN_BL;
  49199. private static _ORIGIN_BR;
  49200. private static _ORIGIN_UL;
  49201. private static _ORIGIN_UR;
  49202. /**
  49203. * Gets the header of a TGA file
  49204. * @param data defines the TGA data
  49205. * @returns the header
  49206. */
  49207. static GetTGAHeader(data: Uint8Array): any;
  49208. /**
  49209. * Uploads TGA content to a Babylon Texture
  49210. * @hidden
  49211. */
  49212. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49213. /** @hidden */
  49214. 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;
  49215. /** @hidden */
  49216. 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;
  49217. /** @hidden */
  49218. 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;
  49219. /** @hidden */
  49220. 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;
  49221. /** @hidden */
  49222. 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;
  49223. /** @hidden */
  49224. 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;
  49225. }
  49226. }
  49227. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49228. import { Nullable } from "babylonjs/types";
  49229. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49230. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49231. /**
  49232. * Implementation of the TGA Texture Loader.
  49233. * @hidden
  49234. */
  49235. export class _TGATextureLoader implements IInternalTextureLoader {
  49236. /**
  49237. * Defines wether the loader supports cascade loading the different faces.
  49238. */
  49239. readonly supportCascades: boolean;
  49240. /**
  49241. * This returns if the loader support the current file information.
  49242. * @param extension defines the file extension of the file being loaded
  49243. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49244. * @param fallback defines the fallback internal texture if any
  49245. * @param isBase64 defines whether the texture is encoded as a base64
  49246. * @param isBuffer defines whether the texture data are stored as a buffer
  49247. * @returns true if the loader can load the specified file
  49248. */
  49249. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49250. /**
  49251. * Transform the url before loading if required.
  49252. * @param rootUrl the url of the texture
  49253. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49254. * @returns the transformed texture
  49255. */
  49256. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49257. /**
  49258. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49259. * @param rootUrl the url of the texture
  49260. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49261. * @returns the fallback texture
  49262. */
  49263. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49264. /**
  49265. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49266. * @param data contains the texture data
  49267. * @param texture defines the BabylonJS internal texture
  49268. * @param createPolynomials will be true if polynomials have been requested
  49269. * @param onLoad defines the callback to trigger once the texture is ready
  49270. * @param onError defines the callback to trigger in case of error
  49271. */
  49272. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49273. /**
  49274. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49275. * @param data contains the texture data
  49276. * @param texture defines the BabylonJS internal texture
  49277. * @param callback defines the method to call once ready to upload
  49278. */
  49279. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49280. }
  49281. }
  49282. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49283. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49284. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49285. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49286. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49287. }
  49288. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49289. import { Scene } from "babylonjs/scene";
  49290. import { Texture } from "babylonjs/Materials/Textures/texture";
  49291. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49292. /**
  49293. * 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.
  49294. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49295. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49296. */
  49297. export class CustomProceduralTexture extends ProceduralTexture {
  49298. private _animate;
  49299. private _time;
  49300. private _config;
  49301. private _texturePath;
  49302. /**
  49303. * Instantiates a new Custom Procedural Texture.
  49304. * 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.
  49305. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49306. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49307. * @param name Define the name of the texture
  49308. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49309. * @param size Define the size of the texture to create
  49310. * @param scene Define the scene the texture belongs to
  49311. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49312. * @param generateMipMaps Define if the texture should creates mip maps or not
  49313. */
  49314. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49315. private _loadJson;
  49316. /**
  49317. * Is the texture ready to be used ? (rendered at least once)
  49318. * @returns true if ready, otherwise, false.
  49319. */
  49320. isReady(): boolean;
  49321. /**
  49322. * Render the texture to its associated render target.
  49323. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49324. */
  49325. render(useCameraPostProcess?: boolean): void;
  49326. /**
  49327. * Update the list of dependant textures samplers in the shader.
  49328. */
  49329. updateTextures(): void;
  49330. /**
  49331. * Update the uniform values of the procedural texture in the shader.
  49332. */
  49333. updateShaderUniforms(): void;
  49334. /**
  49335. * Define if the texture animates or not.
  49336. */
  49337. animate: boolean;
  49338. }
  49339. }
  49340. declare module "babylonjs/Shaders/noise.fragment" {
  49341. /** @hidden */
  49342. export var noisePixelShader: {
  49343. name: string;
  49344. shader: string;
  49345. };
  49346. }
  49347. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49348. import { Nullable } from "babylonjs/types";
  49349. import { Scene } from "babylonjs/scene";
  49350. import { Texture } from "babylonjs/Materials/Textures/texture";
  49351. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49352. import "babylonjs/Shaders/noise.fragment";
  49353. /**
  49354. * Class used to generate noise procedural textures
  49355. */
  49356. export class NoiseProceduralTexture extends ProceduralTexture {
  49357. private _time;
  49358. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49359. brightness: number;
  49360. /** Defines the number of octaves to process */
  49361. octaves: number;
  49362. /** Defines the level of persistence (0.8 by default) */
  49363. persistence: number;
  49364. /** Gets or sets animation speed factor (default is 1) */
  49365. animationSpeedFactor: number;
  49366. /**
  49367. * Creates a new NoiseProceduralTexture
  49368. * @param name defines the name fo the texture
  49369. * @param size defines the size of the texture (default is 256)
  49370. * @param scene defines the hosting scene
  49371. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49372. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49373. */
  49374. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49375. private _updateShaderUniforms;
  49376. protected _getDefines(): string;
  49377. /** Generate the current state of the procedural texture */
  49378. render(useCameraPostProcess?: boolean): void;
  49379. /**
  49380. * Serializes this noise procedural texture
  49381. * @returns a serialized noise procedural texture object
  49382. */
  49383. serialize(): any;
  49384. /**
  49385. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49386. * @param parsedTexture defines parsed texture data
  49387. * @param scene defines the current scene
  49388. * @param rootUrl defines the root URL containing noise procedural texture information
  49389. * @returns a parsed NoiseProceduralTexture
  49390. */
  49391. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49392. }
  49393. }
  49394. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49395. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49396. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49397. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49398. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49399. }
  49400. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49401. import { Nullable } from "babylonjs/types";
  49402. import { Scene } from "babylonjs/scene";
  49403. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49404. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49405. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49406. /**
  49407. * Raw cube texture where the raw buffers are passed in
  49408. */
  49409. export class RawCubeTexture extends CubeTexture {
  49410. /**
  49411. * Creates a cube texture where the raw buffers are passed in.
  49412. * @param scene defines the scene the texture is attached to
  49413. * @param data defines the array of data to use to create each face
  49414. * @param size defines the size of the textures
  49415. * @param format defines the format of the data
  49416. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49417. * @param generateMipMaps defines if the engine should generate the mip levels
  49418. * @param invertY defines if data must be stored with Y axis inverted
  49419. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49420. * @param compression defines the compression used (null by default)
  49421. */
  49422. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49423. /**
  49424. * Updates the raw cube texture.
  49425. * @param data defines the data to store
  49426. * @param format defines the data format
  49427. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49428. * @param invertY defines if data must be stored with Y axis inverted
  49429. * @param compression defines the compression used (null by default)
  49430. * @param level defines which level of the texture to update
  49431. */
  49432. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49433. /**
  49434. * Updates a raw cube texture with RGBD encoded data.
  49435. * @param data defines the array of data [mipmap][face] to use to create each face
  49436. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49437. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49438. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49439. * @returns a promsie that resolves when the operation is complete
  49440. */
  49441. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49442. /**
  49443. * Clones the raw cube texture.
  49444. * @return a new cube texture
  49445. */
  49446. clone(): CubeTexture;
  49447. /** @hidden */
  49448. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49449. }
  49450. }
  49451. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49452. import { Scene } from "babylonjs/scene";
  49453. import { Texture } from "babylonjs/Materials/Textures/texture";
  49454. /**
  49455. * Class used to store 3D textures containing user data
  49456. */
  49457. export class RawTexture3D extends Texture {
  49458. /** Gets or sets the texture format to use */
  49459. format: number;
  49460. private _engine;
  49461. /**
  49462. * Create a new RawTexture3D
  49463. * @param data defines the data of the texture
  49464. * @param width defines the width of the texture
  49465. * @param height defines the height of the texture
  49466. * @param depth defines the depth of the texture
  49467. * @param format defines the texture format to use
  49468. * @param scene defines the hosting scene
  49469. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49470. * @param invertY defines if texture must be stored with Y axis inverted
  49471. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49472. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49473. */
  49474. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49475. /** Gets or sets the texture format to use */
  49476. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49477. /**
  49478. * Update the texture with new data
  49479. * @param data defines the data to store in the texture
  49480. */
  49481. update(data: ArrayBufferView): void;
  49482. }
  49483. }
  49484. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49485. import { Scene } from "babylonjs/scene";
  49486. import { Plane } from "babylonjs/Maths/math";
  49487. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49488. /**
  49489. * Creates a refraction texture used by refraction channel of the standard material.
  49490. * It is like a mirror but to see through a material.
  49491. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49492. */
  49493. export class RefractionTexture extends RenderTargetTexture {
  49494. /**
  49495. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49496. * 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.
  49497. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49498. */
  49499. refractionPlane: Plane;
  49500. /**
  49501. * Define how deep under the surface we should see.
  49502. */
  49503. depth: number;
  49504. /**
  49505. * Creates a refraction texture used by refraction channel of the standard material.
  49506. * It is like a mirror but to see through a material.
  49507. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49508. * @param name Define the texture name
  49509. * @param size Define the size of the underlying texture
  49510. * @param scene Define the scene the refraction belongs to
  49511. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49512. */
  49513. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49514. /**
  49515. * Clone the refraction texture.
  49516. * @returns the cloned texture
  49517. */
  49518. clone(): RefractionTexture;
  49519. /**
  49520. * Serialize the texture to a JSON representation you could use in Parse later on
  49521. * @returns the serialized JSON representation
  49522. */
  49523. serialize(): any;
  49524. }
  49525. }
  49526. declare module "babylonjs/Materials/Textures/index" {
  49527. export * from "babylonjs/Materials/Textures/baseTexture";
  49528. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49529. export * from "babylonjs/Materials/Textures/cubeTexture";
  49530. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49531. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49532. export * from "babylonjs/Materials/Textures/internalTexture";
  49533. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49534. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49535. export * from "babylonjs/Materials/Textures/Loaders/index";
  49536. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49537. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49538. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49539. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49540. export * from "babylonjs/Materials/Textures/rawTexture";
  49541. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49542. export * from "babylonjs/Materials/Textures/refractionTexture";
  49543. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49544. export * from "babylonjs/Materials/Textures/texture";
  49545. export * from "babylonjs/Materials/Textures/videoTexture";
  49546. }
  49547. declare module "babylonjs/Materials/index" {
  49548. export * from "babylonjs/Materials/Background/index";
  49549. export * from "babylonjs/Materials/colorCurves";
  49550. export * from "babylonjs/Materials/effect";
  49551. export * from "babylonjs/Materials/fresnelParameters";
  49552. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49553. export * from "babylonjs/Materials/material";
  49554. export * from "babylonjs/Materials/materialDefines";
  49555. export * from "babylonjs/Materials/materialHelper";
  49556. export * from "babylonjs/Materials/multiMaterial";
  49557. export * from "babylonjs/Materials/PBR/index";
  49558. export * from "babylonjs/Materials/pushMaterial";
  49559. export * from "babylonjs/Materials/shaderMaterial";
  49560. export * from "babylonjs/Materials/standardMaterial";
  49561. export * from "babylonjs/Materials/Textures/index";
  49562. export * from "babylonjs/Materials/uniformBuffer";
  49563. export * from "babylonjs/Materials/materialFlags";
  49564. }
  49565. declare module "babylonjs/Maths/index" {
  49566. export * from "babylonjs/Maths/math.scalar";
  49567. export * from "babylonjs/Maths/math";
  49568. export * from "babylonjs/Maths/sphericalPolynomial";
  49569. }
  49570. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49571. import { IDisposable } from "babylonjs/scene";
  49572. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49573. /**
  49574. * Configuration for Draco compression
  49575. */
  49576. export interface IDracoCompressionConfiguration {
  49577. /**
  49578. * Configuration for the decoder.
  49579. */
  49580. decoder?: {
  49581. /**
  49582. * The url to the WebAssembly module.
  49583. */
  49584. wasmUrl?: string;
  49585. /**
  49586. * The url to the WebAssembly binary.
  49587. */
  49588. wasmBinaryUrl?: string;
  49589. /**
  49590. * The url to the fallback JavaScript module.
  49591. */
  49592. fallbackUrl?: string;
  49593. };
  49594. }
  49595. /**
  49596. * Draco compression (https://google.github.io/draco/)
  49597. *
  49598. * This class wraps the Draco module.
  49599. *
  49600. * **Encoder**
  49601. *
  49602. * The encoder is not currently implemented.
  49603. *
  49604. * **Decoder**
  49605. *
  49606. * 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.
  49607. *
  49608. * To update the configuration, use the following code:
  49609. * ```javascript
  49610. * DracoCompression.Configuration = {
  49611. * decoder: {
  49612. * wasmUrl: "<url to the WebAssembly library>",
  49613. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49614. * fallbackUrl: "<url to the fallback JavaScript library>",
  49615. * }
  49616. * };
  49617. * ```
  49618. *
  49619. * 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.
  49620. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49621. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49622. *
  49623. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49624. * ```javascript
  49625. * var dracoCompression = new DracoCompression();
  49626. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49627. * [VertexBuffer.PositionKind]: 0
  49628. * });
  49629. * ```
  49630. *
  49631. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49632. */
  49633. export class DracoCompression implements IDisposable {
  49634. private static _DecoderModulePromise;
  49635. /**
  49636. * The configuration. Defaults to the following urls:
  49637. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49638. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49639. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49640. */
  49641. static Configuration: IDracoCompressionConfiguration;
  49642. /**
  49643. * Returns true if the decoder is available.
  49644. */
  49645. static readonly DecoderAvailable: boolean;
  49646. /**
  49647. * Constructor
  49648. */
  49649. constructor();
  49650. /**
  49651. * Stop all async operations and release resources.
  49652. */
  49653. dispose(): void;
  49654. /**
  49655. * Decode Draco compressed mesh data to vertex data.
  49656. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49657. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49658. * @returns A promise that resolves with the decoded vertex data
  49659. */
  49660. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49661. [kind: string]: number;
  49662. }): Promise<VertexData>;
  49663. private static _GetDecoderModule;
  49664. private static _LoadScriptAsync;
  49665. private static _LoadFileAsync;
  49666. }
  49667. }
  49668. declare module "babylonjs/Meshes/Compression/index" {
  49669. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49670. }
  49671. declare module "babylonjs/Meshes/csg" {
  49672. import { Nullable } from "babylonjs/types";
  49673. import { Scene } from "babylonjs/scene";
  49674. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49675. import { Mesh } from "babylonjs/Meshes/mesh";
  49676. import { Material } from "babylonjs/Materials/material";
  49677. /**
  49678. * Class for building Constructive Solid Geometry
  49679. */
  49680. export class CSG {
  49681. private polygons;
  49682. /**
  49683. * The world matrix
  49684. */
  49685. matrix: Matrix;
  49686. /**
  49687. * Stores the position
  49688. */
  49689. position: Vector3;
  49690. /**
  49691. * Stores the rotation
  49692. */
  49693. rotation: Vector3;
  49694. /**
  49695. * Stores the rotation quaternion
  49696. */
  49697. rotationQuaternion: Nullable<Quaternion>;
  49698. /**
  49699. * Stores the scaling vector
  49700. */
  49701. scaling: Vector3;
  49702. /**
  49703. * Convert the Mesh to CSG
  49704. * @param mesh The Mesh to convert to CSG
  49705. * @returns A new CSG from the Mesh
  49706. */
  49707. static FromMesh(mesh: Mesh): CSG;
  49708. /**
  49709. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49710. * @param polygons Polygons used to construct a CSG solid
  49711. */
  49712. private static FromPolygons;
  49713. /**
  49714. * Clones, or makes a deep copy, of the CSG
  49715. * @returns A new CSG
  49716. */
  49717. clone(): CSG;
  49718. /**
  49719. * Unions this CSG with another CSG
  49720. * @param csg The CSG to union against this CSG
  49721. * @returns The unioned CSG
  49722. */
  49723. union(csg: CSG): CSG;
  49724. /**
  49725. * Unions this CSG with another CSG in place
  49726. * @param csg The CSG to union against this CSG
  49727. */
  49728. unionInPlace(csg: CSG): void;
  49729. /**
  49730. * Subtracts this CSG with another CSG
  49731. * @param csg The CSG to subtract against this CSG
  49732. * @returns A new CSG
  49733. */
  49734. subtract(csg: CSG): CSG;
  49735. /**
  49736. * Subtracts this CSG with another CSG in place
  49737. * @param csg The CSG to subtact against this CSG
  49738. */
  49739. subtractInPlace(csg: CSG): void;
  49740. /**
  49741. * Intersect this CSG with another CSG
  49742. * @param csg The CSG to intersect against this CSG
  49743. * @returns A new CSG
  49744. */
  49745. intersect(csg: CSG): CSG;
  49746. /**
  49747. * Intersects this CSG with another CSG in place
  49748. * @param csg The CSG to intersect against this CSG
  49749. */
  49750. intersectInPlace(csg: CSG): void;
  49751. /**
  49752. * Return a new CSG solid with solid and empty space switched. This solid is
  49753. * not modified.
  49754. * @returns A new CSG solid with solid and empty space switched
  49755. */
  49756. inverse(): CSG;
  49757. /**
  49758. * Inverses the CSG in place
  49759. */
  49760. inverseInPlace(): void;
  49761. /**
  49762. * This is used to keep meshes transformations so they can be restored
  49763. * when we build back a Babylon Mesh
  49764. * NB : All CSG operations are performed in world coordinates
  49765. * @param csg The CSG to copy the transform attributes from
  49766. * @returns This CSG
  49767. */
  49768. copyTransformAttributes(csg: CSG): CSG;
  49769. /**
  49770. * Build Raw mesh from CSG
  49771. * Coordinates here are in world space
  49772. * @param name The name of the mesh geometry
  49773. * @param scene The Scene
  49774. * @param keepSubMeshes Specifies if the submeshes should be kept
  49775. * @returns A new Mesh
  49776. */
  49777. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49778. /**
  49779. * Build Mesh from CSG taking material and transforms into account
  49780. * @param name The name of the Mesh
  49781. * @param material The material of the Mesh
  49782. * @param scene The Scene
  49783. * @param keepSubMeshes Specifies if submeshes should be kept
  49784. * @returns The new Mesh
  49785. */
  49786. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49787. }
  49788. }
  49789. declare module "babylonjs/Meshes/trailMesh" {
  49790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49791. import { Mesh } from "babylonjs/Meshes/mesh";
  49792. import { Scene } from "babylonjs/scene";
  49793. /**
  49794. * Class used to create a trail following a mesh
  49795. */
  49796. export class TrailMesh extends Mesh {
  49797. private _generator;
  49798. private _autoStart;
  49799. private _running;
  49800. private _diameter;
  49801. private _length;
  49802. private _sectionPolygonPointsCount;
  49803. private _sectionVectors;
  49804. private _sectionNormalVectors;
  49805. private _beforeRenderObserver;
  49806. /**
  49807. * @constructor
  49808. * @param name The value used by scene.getMeshByName() to do a lookup.
  49809. * @param generator The mesh to generate a trail.
  49810. * @param scene The scene to add this mesh to.
  49811. * @param diameter Diameter of trailing mesh. Default is 1.
  49812. * @param length Length of trailing mesh. Default is 60.
  49813. * @param autoStart Automatically start trailing mesh. Default true.
  49814. */
  49815. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49816. /**
  49817. * "TrailMesh"
  49818. * @returns "TrailMesh"
  49819. */
  49820. getClassName(): string;
  49821. private _createMesh;
  49822. /**
  49823. * Start trailing mesh.
  49824. */
  49825. start(): void;
  49826. /**
  49827. * Stop trailing mesh.
  49828. */
  49829. stop(): void;
  49830. /**
  49831. * Update trailing mesh geometry.
  49832. */
  49833. update(): void;
  49834. /**
  49835. * Returns a new TrailMesh object.
  49836. * @param name is a string, the name given to the new mesh
  49837. * @param newGenerator use new generator object for cloned trail mesh
  49838. * @returns a new mesh
  49839. */
  49840. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49841. /**
  49842. * Serializes this trail mesh
  49843. * @param serializationObject object to write serialization to
  49844. */
  49845. serialize(serializationObject: any): void;
  49846. /**
  49847. * Parses a serialized trail mesh
  49848. * @param parsedMesh the serialized mesh
  49849. * @param scene the scene to create the trail mesh in
  49850. * @returns the created trail mesh
  49851. */
  49852. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49853. }
  49854. }
  49855. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49856. import { Nullable } from "babylonjs/types";
  49857. import { Scene } from "babylonjs/scene";
  49858. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49859. import { Mesh } from "babylonjs/Meshes/mesh";
  49860. /**
  49861. * Class containing static functions to help procedurally build meshes
  49862. */
  49863. export class RibbonBuilder {
  49864. /**
  49865. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49866. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49867. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49868. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49869. * * 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
  49870. * * 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
  49871. * * 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
  49872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49874. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49875. * * 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
  49876. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49877. * * 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
  49878. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49880. * @param name defines the name of the mesh
  49881. * @param options defines the options used to create the mesh
  49882. * @param scene defines the hosting scene
  49883. * @returns the ribbon mesh
  49884. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49885. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49886. */
  49887. static CreateRibbon(name: string, options: {
  49888. pathArray: Vector3[][];
  49889. closeArray?: boolean;
  49890. closePath?: boolean;
  49891. offset?: number;
  49892. updatable?: boolean;
  49893. sideOrientation?: number;
  49894. frontUVs?: Vector4;
  49895. backUVs?: Vector4;
  49896. instance?: Mesh;
  49897. invertUV?: boolean;
  49898. uvs?: Vector2[];
  49899. colors?: Color4[];
  49900. }, scene?: Nullable<Scene>): Mesh;
  49901. }
  49902. }
  49903. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49904. import { Vector4 } from "babylonjs/Maths/math";
  49905. import { Mesh } from "babylonjs/Meshes/mesh";
  49906. /**
  49907. * Class containing static functions to help procedurally build meshes
  49908. */
  49909. export class TorusKnotBuilder {
  49910. /**
  49911. * Creates a torus knot mesh
  49912. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49913. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49914. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49915. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49919. * @param name defines the name of the mesh
  49920. * @param options defines the options used to create the mesh
  49921. * @param scene defines the hosting scene
  49922. * @returns the torus knot mesh
  49923. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49924. */
  49925. static CreateTorusKnot(name: string, options: {
  49926. radius?: number;
  49927. tube?: number;
  49928. radialSegments?: number;
  49929. tubularSegments?: number;
  49930. p?: number;
  49931. q?: number;
  49932. updatable?: boolean;
  49933. sideOrientation?: number;
  49934. frontUVs?: Vector4;
  49935. backUVs?: Vector4;
  49936. }, scene: any): Mesh;
  49937. }
  49938. }
  49939. declare module "babylonjs/Meshes/polygonMesh" {
  49940. import { Scene } from "babylonjs/scene";
  49941. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49942. import { Mesh } from "babylonjs/Meshes/mesh";
  49943. /**
  49944. * Polygon
  49945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49946. */
  49947. export class Polygon {
  49948. /**
  49949. * Creates a rectangle
  49950. * @param xmin bottom X coord
  49951. * @param ymin bottom Y coord
  49952. * @param xmax top X coord
  49953. * @param ymax top Y coord
  49954. * @returns points that make the resulting rectation
  49955. */
  49956. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49957. /**
  49958. * Creates a circle
  49959. * @param radius radius of circle
  49960. * @param cx scale in x
  49961. * @param cy scale in y
  49962. * @param numberOfSides number of sides that make up the circle
  49963. * @returns points that make the resulting circle
  49964. */
  49965. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49966. /**
  49967. * Creates a polygon from input string
  49968. * @param input Input polygon data
  49969. * @returns the parsed points
  49970. */
  49971. static Parse(input: string): Vector2[];
  49972. /**
  49973. * Starts building a polygon from x and y coordinates
  49974. * @param x x coordinate
  49975. * @param y y coordinate
  49976. * @returns the started path2
  49977. */
  49978. static StartingAt(x: number, y: number): Path2;
  49979. }
  49980. /**
  49981. * Builds a polygon
  49982. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49983. */
  49984. export class PolygonMeshBuilder {
  49985. private _points;
  49986. private _outlinepoints;
  49987. private _holes;
  49988. private _name;
  49989. private _scene;
  49990. private _epoints;
  49991. private _eholes;
  49992. private _addToepoint;
  49993. /**
  49994. * Babylon reference to the earcut plugin.
  49995. */
  49996. bjsEarcut: any;
  49997. /**
  49998. * Creates a PolygonMeshBuilder
  49999. * @param name name of the builder
  50000. * @param contours Path of the polygon
  50001. * @param scene scene to add to
  50002. * @param earcutInjection can be used to inject your own earcut reference
  50003. */
  50004. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  50005. /**
  50006. * Adds a whole within the polygon
  50007. * @param hole Array of points defining the hole
  50008. * @returns this
  50009. */
  50010. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50011. /**
  50012. * Creates the polygon
  50013. * @param updatable If the mesh should be updatable
  50014. * @param depth The depth of the mesh created
  50015. * @returns the created mesh
  50016. */
  50017. build(updatable?: boolean, depth?: number): Mesh;
  50018. /**
  50019. * Adds a side to the polygon
  50020. * @param positions points that make the polygon
  50021. * @param normals normals of the polygon
  50022. * @param uvs uvs of the polygon
  50023. * @param indices indices of the polygon
  50024. * @param bounds bounds of the polygon
  50025. * @param points points of the polygon
  50026. * @param depth depth of the polygon
  50027. * @param flip flip of the polygon
  50028. */
  50029. private addSide;
  50030. }
  50031. }
  50032. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50033. import { Scene } from "babylonjs/scene";
  50034. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50035. import { Mesh } from "babylonjs/Meshes/mesh";
  50036. /**
  50037. * Class containing static functions to help procedurally build meshes
  50038. */
  50039. export class PolygonBuilder {
  50040. /**
  50041. * Creates a polygon mesh
  50042. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50043. * * 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
  50044. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50047. * * Remember you can only change the shape positions, not their number when updating a polygon
  50048. * @param name defines the name of the mesh
  50049. * @param options defines the options used to create the mesh
  50050. * @param scene defines the hosting scene
  50051. * @param earcutInjection can be used to inject your own earcut reference
  50052. * @returns the polygon mesh
  50053. */
  50054. static CreatePolygon(name: string, options: {
  50055. shape: Vector3[];
  50056. holes?: Vector3[][];
  50057. depth?: number;
  50058. faceUV?: Vector4[];
  50059. faceColors?: Color4[];
  50060. updatable?: boolean;
  50061. sideOrientation?: number;
  50062. frontUVs?: Vector4;
  50063. backUVs?: Vector4;
  50064. }, scene: Scene, earcutInjection?: any): Mesh;
  50065. /**
  50066. * Creates an extruded polygon mesh, with depth in the Y direction.
  50067. * * 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)
  50068. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50069. * @param name defines the name of the mesh
  50070. * @param options defines the options used to create the mesh
  50071. * @param scene defines the hosting scene
  50072. * @param earcutInjection can be used to inject your own earcut reference
  50073. * @returns the polygon mesh
  50074. */
  50075. static ExtrudePolygon(name: string, options: {
  50076. shape: Vector3[];
  50077. holes?: Vector3[][];
  50078. depth?: number;
  50079. faceUV?: Vector4[];
  50080. faceColors?: Color4[];
  50081. updatable?: boolean;
  50082. sideOrientation?: number;
  50083. frontUVs?: Vector4;
  50084. backUVs?: Vector4;
  50085. }, scene: Scene, earcutInjection?: any): Mesh;
  50086. }
  50087. }
  50088. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50089. import { Nullable } from "babylonjs/types";
  50090. import { Scene } from "babylonjs/scene";
  50091. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50092. import { Mesh } from "babylonjs/Meshes/mesh";
  50093. /**
  50094. * Class containing static functions to help procedurally build meshes
  50095. */
  50096. export class ShapeBuilder {
  50097. /**
  50098. * 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.
  50099. * * 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.
  50100. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50101. * * 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.
  50102. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50103. * * 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
  50104. * * 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
  50105. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50108. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50110. * @param name defines the name of the mesh
  50111. * @param options defines the options used to create the mesh
  50112. * @param scene defines the hosting scene
  50113. * @returns the extruded shape mesh
  50114. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50116. */
  50117. static ExtrudeShape(name: string, options: {
  50118. shape: Vector3[];
  50119. path: Vector3[];
  50120. scale?: number;
  50121. rotation?: number;
  50122. cap?: number;
  50123. updatable?: boolean;
  50124. sideOrientation?: number;
  50125. frontUVs?: Vector4;
  50126. backUVs?: Vector4;
  50127. instance?: Mesh;
  50128. invertUV?: boolean;
  50129. }, scene?: Nullable<Scene>): Mesh;
  50130. /**
  50131. * Creates an custom extruded shape mesh.
  50132. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50133. * * 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.
  50134. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50135. * * 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
  50136. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50137. * * 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
  50138. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50139. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50140. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50141. * * 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
  50142. * * 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
  50143. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50146. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50148. * @param name defines the name of the mesh
  50149. * @param options defines the options used to create the mesh
  50150. * @param scene defines the hosting scene
  50151. * @returns the custom extruded shape mesh
  50152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50153. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50154. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50155. */
  50156. static ExtrudeShapeCustom(name: string, options: {
  50157. shape: Vector3[];
  50158. path: Vector3[];
  50159. scaleFunction?: any;
  50160. rotationFunction?: any;
  50161. ribbonCloseArray?: boolean;
  50162. ribbonClosePath?: boolean;
  50163. cap?: number;
  50164. updatable?: boolean;
  50165. sideOrientation?: number;
  50166. frontUVs?: Vector4;
  50167. backUVs?: Vector4;
  50168. instance?: Mesh;
  50169. invertUV?: boolean;
  50170. }, scene: Scene): Mesh;
  50171. private static _ExtrudeShapeGeneric;
  50172. }
  50173. }
  50174. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50175. import { Scene } from "babylonjs/scene";
  50176. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50177. import { Mesh } from "babylonjs/Meshes/mesh";
  50178. /**
  50179. * Class containing static functions to help procedurally build meshes
  50180. */
  50181. export class LatheBuilder {
  50182. /**
  50183. * Creates lathe mesh.
  50184. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50185. * * 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
  50186. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50187. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50188. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50189. * * 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
  50190. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50191. * * 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
  50192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50194. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50196. * @param name defines the name of the mesh
  50197. * @param options defines the options used to create the mesh
  50198. * @param scene defines the hosting scene
  50199. * @returns the lathe mesh
  50200. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50201. */
  50202. static CreateLathe(name: string, options: {
  50203. shape: Vector3[];
  50204. radius?: number;
  50205. tessellation?: number;
  50206. clip?: number;
  50207. arc?: number;
  50208. closed?: boolean;
  50209. updatable?: boolean;
  50210. sideOrientation?: number;
  50211. frontUVs?: Vector4;
  50212. backUVs?: Vector4;
  50213. cap?: number;
  50214. invertUV?: boolean;
  50215. }, scene: Scene): Mesh;
  50216. }
  50217. }
  50218. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50219. import { Scene } from "babylonjs/scene";
  50220. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50221. import { Mesh } from "babylonjs/Meshes/mesh";
  50222. /**
  50223. * Class containing static functions to help procedurally build meshes
  50224. */
  50225. export class TubeBuilder {
  50226. /**
  50227. * Creates a tube mesh.
  50228. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50229. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50230. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50231. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50232. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50233. * * 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)
  50234. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50235. * * 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
  50236. * * 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
  50237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50239. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50241. * @param name defines the name of the mesh
  50242. * @param options defines the options used to create the mesh
  50243. * @param scene defines the hosting scene
  50244. * @returns the tube mesh
  50245. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50246. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50247. */
  50248. static CreateTube(name: string, options: {
  50249. path: Vector3[];
  50250. radius?: number;
  50251. tessellation?: number;
  50252. radiusFunction?: {
  50253. (i: number, distance: number): number;
  50254. };
  50255. cap?: number;
  50256. arc?: number;
  50257. updatable?: boolean;
  50258. sideOrientation?: number;
  50259. frontUVs?: Vector4;
  50260. backUVs?: Vector4;
  50261. instance?: Mesh;
  50262. invertUV?: boolean;
  50263. }, scene: Scene): Mesh;
  50264. }
  50265. }
  50266. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50267. import { Scene } from "babylonjs/scene";
  50268. import { Vector4 } from "babylonjs/Maths/math";
  50269. import { Mesh } from "babylonjs/Meshes/mesh";
  50270. /**
  50271. * Class containing static functions to help procedurally build meshes
  50272. */
  50273. export class IcoSphereBuilder {
  50274. /**
  50275. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50276. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50277. * * 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`)
  50278. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50279. * * 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
  50280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50283. * @param name defines the name of the mesh
  50284. * @param options defines the options used to create the mesh
  50285. * @param scene defines the hosting scene
  50286. * @returns the icosahedron mesh
  50287. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50288. */
  50289. static CreateIcoSphere(name: string, options: {
  50290. radius?: number;
  50291. radiusX?: number;
  50292. radiusY?: number;
  50293. radiusZ?: number;
  50294. flat?: boolean;
  50295. subdivisions?: number;
  50296. sideOrientation?: number;
  50297. frontUVs?: Vector4;
  50298. backUVs?: Vector4;
  50299. updatable?: boolean;
  50300. }, scene: Scene): Mesh;
  50301. }
  50302. }
  50303. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50304. import { Vector3 } from "babylonjs/Maths/math";
  50305. import { Mesh } from "babylonjs/Meshes/mesh";
  50306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50307. /**
  50308. * Class containing static functions to help procedurally build meshes
  50309. */
  50310. export class DecalBuilder {
  50311. /**
  50312. * Creates a decal mesh.
  50313. * 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
  50314. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50315. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50316. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50317. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50318. * @param name defines the name of the mesh
  50319. * @param sourceMesh defines the mesh where the decal must be applied
  50320. * @param options defines the options used to create the mesh
  50321. * @param scene defines the hosting scene
  50322. * @returns the decal mesh
  50323. * @see https://doc.babylonjs.com/how_to/decals
  50324. */
  50325. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50326. position?: Vector3;
  50327. normal?: Vector3;
  50328. size?: Vector3;
  50329. angle?: number;
  50330. }): Mesh;
  50331. }
  50332. }
  50333. declare module "babylonjs/Meshes/meshBuilder" {
  50334. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50335. import { Nullable } from "babylonjs/types";
  50336. import { Scene } from "babylonjs/scene";
  50337. import { Mesh } from "babylonjs/Meshes/mesh";
  50338. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50339. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50341. /**
  50342. * Class containing static functions to help procedurally build meshes
  50343. */
  50344. export class MeshBuilder {
  50345. /**
  50346. * Creates a box mesh
  50347. * * The parameter `size` sets the size (float) of each box side (default 1)
  50348. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50349. * * 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)
  50350. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50354. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50355. * @param name defines the name of the mesh
  50356. * @param options defines the options used to create the mesh
  50357. * @param scene defines the hosting scene
  50358. * @returns the box mesh
  50359. */
  50360. static CreateBox(name: string, options: {
  50361. size?: number;
  50362. width?: number;
  50363. height?: number;
  50364. depth?: number;
  50365. faceUV?: Vector4[];
  50366. faceColors?: Color4[];
  50367. sideOrientation?: number;
  50368. frontUVs?: Vector4;
  50369. backUVs?: Vector4;
  50370. updatable?: boolean;
  50371. }, scene?: Nullable<Scene>): Mesh;
  50372. /**
  50373. * Creates a sphere mesh
  50374. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50375. * * 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`)
  50376. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50377. * * 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
  50378. * * 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)
  50379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50380. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50382. * @param name defines the name of the mesh
  50383. * @param options defines the options used to create the mesh
  50384. * @param scene defines the hosting scene
  50385. * @returns the sphere mesh
  50386. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50387. */
  50388. static CreateSphere(name: string, options: {
  50389. segments?: number;
  50390. diameter?: number;
  50391. diameterX?: number;
  50392. diameterY?: number;
  50393. diameterZ?: number;
  50394. arc?: number;
  50395. slice?: number;
  50396. sideOrientation?: number;
  50397. frontUVs?: Vector4;
  50398. backUVs?: Vector4;
  50399. updatable?: boolean;
  50400. }, scene: any): Mesh;
  50401. /**
  50402. * Creates a plane polygonal mesh. By default, this is a disc
  50403. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50404. * * 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
  50405. * * 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
  50406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50409. * @param name defines the name of the mesh
  50410. * @param options defines the options used to create the mesh
  50411. * @param scene defines the hosting scene
  50412. * @returns the plane polygonal mesh
  50413. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50414. */
  50415. static CreateDisc(name: string, options: {
  50416. radius?: number;
  50417. tessellation?: number;
  50418. arc?: number;
  50419. updatable?: boolean;
  50420. sideOrientation?: number;
  50421. frontUVs?: Vector4;
  50422. backUVs?: Vector4;
  50423. }, scene?: Nullable<Scene>): Mesh;
  50424. /**
  50425. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50426. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50427. * * 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`)
  50428. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50429. * * 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
  50430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50433. * @param name defines the name of the mesh
  50434. * @param options defines the options used to create the mesh
  50435. * @param scene defines the hosting scene
  50436. * @returns the icosahedron mesh
  50437. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50438. */
  50439. static CreateIcoSphere(name: string, options: {
  50440. radius?: number;
  50441. radiusX?: number;
  50442. radiusY?: number;
  50443. radiusZ?: number;
  50444. flat?: boolean;
  50445. subdivisions?: number;
  50446. sideOrientation?: number;
  50447. frontUVs?: Vector4;
  50448. backUVs?: Vector4;
  50449. updatable?: boolean;
  50450. }, scene: Scene): Mesh;
  50451. /**
  50452. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50453. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50454. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50455. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50456. * * 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
  50457. * * 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
  50458. * * 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
  50459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50462. * * 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
  50463. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50464. * * 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
  50465. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50467. * @param name defines the name of the mesh
  50468. * @param options defines the options used to create the mesh
  50469. * @param scene defines the hosting scene
  50470. * @returns the ribbon mesh
  50471. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50473. */
  50474. static CreateRibbon(name: string, options: {
  50475. pathArray: Vector3[][];
  50476. closeArray?: boolean;
  50477. closePath?: boolean;
  50478. offset?: number;
  50479. updatable?: boolean;
  50480. sideOrientation?: number;
  50481. frontUVs?: Vector4;
  50482. backUVs?: Vector4;
  50483. instance?: Mesh;
  50484. invertUV?: boolean;
  50485. uvs?: Vector2[];
  50486. colors?: Color4[];
  50487. }, scene?: Nullable<Scene>): Mesh;
  50488. /**
  50489. * Creates a cylinder or a cone mesh
  50490. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50491. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50492. * * 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.
  50493. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50494. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50495. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50496. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50497. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50498. * * 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).
  50499. * * 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
  50500. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50501. * * 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
  50502. * * 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.
  50503. * * If `enclose` is false, a ring surface is one element.
  50504. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50505. * * 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
  50506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50509. * @param name defines the name of the mesh
  50510. * @param options defines the options used to create the mesh
  50511. * @param scene defines the hosting scene
  50512. * @returns the cylinder mesh
  50513. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50514. */
  50515. static CreateCylinder(name: string, options: {
  50516. height?: number;
  50517. diameterTop?: number;
  50518. diameterBottom?: number;
  50519. diameter?: number;
  50520. tessellation?: number;
  50521. subdivisions?: number;
  50522. arc?: number;
  50523. faceColors?: Color4[];
  50524. faceUV?: Vector4[];
  50525. updatable?: boolean;
  50526. hasRings?: boolean;
  50527. enclose?: boolean;
  50528. sideOrientation?: number;
  50529. frontUVs?: Vector4;
  50530. backUVs?: Vector4;
  50531. }, scene: any): Mesh;
  50532. /**
  50533. * Creates a torus mesh
  50534. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50535. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50536. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50540. * @param name defines the name of the mesh
  50541. * @param options defines the options used to create the mesh
  50542. * @param scene defines the hosting scene
  50543. * @returns the torus mesh
  50544. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50545. */
  50546. static CreateTorus(name: string, options: {
  50547. diameter?: number;
  50548. thickness?: number;
  50549. tessellation?: number;
  50550. updatable?: boolean;
  50551. sideOrientation?: number;
  50552. frontUVs?: Vector4;
  50553. backUVs?: Vector4;
  50554. }, scene: any): Mesh;
  50555. /**
  50556. * Creates a torus knot mesh
  50557. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50558. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50559. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50560. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50564. * @param name defines the name of the mesh
  50565. * @param options defines the options used to create the mesh
  50566. * @param scene defines the hosting scene
  50567. * @returns the torus knot mesh
  50568. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50569. */
  50570. static CreateTorusKnot(name: string, options: {
  50571. radius?: number;
  50572. tube?: number;
  50573. radialSegments?: number;
  50574. tubularSegments?: number;
  50575. p?: number;
  50576. q?: number;
  50577. updatable?: boolean;
  50578. sideOrientation?: number;
  50579. frontUVs?: Vector4;
  50580. backUVs?: Vector4;
  50581. }, scene: any): Mesh;
  50582. /**
  50583. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50584. * * 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
  50585. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50586. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50587. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50588. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50589. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50590. * * 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
  50591. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50594. * @param name defines the name of the new line system
  50595. * @param options defines the options used to create the line system
  50596. * @param scene defines the hosting scene
  50597. * @returns a new line system mesh
  50598. */
  50599. static CreateLineSystem(name: string, options: {
  50600. lines: Vector3[][];
  50601. updatable?: boolean;
  50602. instance?: Nullable<LinesMesh>;
  50603. colors?: Nullable<Color4[][]>;
  50604. useVertexAlpha?: boolean;
  50605. }, scene: Nullable<Scene>): LinesMesh;
  50606. /**
  50607. * Creates a line mesh
  50608. * 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
  50609. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50610. * * The parameter `points` is an array successive Vector3
  50611. * * 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
  50612. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50613. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50614. * * When updating an instance, remember that only point positions can change, not the number of points
  50615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50616. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50617. * @param name defines the name of the new line system
  50618. * @param options defines the options used to create the line system
  50619. * @param scene defines the hosting scene
  50620. * @returns a new line mesh
  50621. */
  50622. static CreateLines(name: string, options: {
  50623. points: Vector3[];
  50624. updatable?: boolean;
  50625. instance?: Nullable<LinesMesh>;
  50626. colors?: Color4[];
  50627. useVertexAlpha?: boolean;
  50628. }, scene?: Nullable<Scene>): LinesMesh;
  50629. /**
  50630. * Creates a dashed line mesh
  50631. * * 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
  50632. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50633. * * The parameter `points` is an array successive Vector3
  50634. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50635. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50636. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50637. * * 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
  50638. * * When updating an instance, remember that only point positions can change, not the number of points
  50639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50640. * @param name defines the name of the mesh
  50641. * @param options defines the options used to create the mesh
  50642. * @param scene defines the hosting scene
  50643. * @returns the dashed line mesh
  50644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50645. */
  50646. static CreateDashedLines(name: string, options: {
  50647. points: Vector3[];
  50648. dashSize?: number;
  50649. gapSize?: number;
  50650. dashNb?: number;
  50651. updatable?: boolean;
  50652. instance?: LinesMesh;
  50653. }, scene?: Nullable<Scene>): LinesMesh;
  50654. /**
  50655. * 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.
  50656. * * 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.
  50657. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50658. * * 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.
  50659. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50660. * * 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
  50661. * * 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
  50662. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50665. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50667. * @param name defines the name of the mesh
  50668. * @param options defines the options used to create the mesh
  50669. * @param scene defines the hosting scene
  50670. * @returns the extruded shape mesh
  50671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50673. */
  50674. static ExtrudeShape(name: string, options: {
  50675. shape: Vector3[];
  50676. path: Vector3[];
  50677. scale?: number;
  50678. rotation?: number;
  50679. cap?: number;
  50680. updatable?: boolean;
  50681. sideOrientation?: number;
  50682. frontUVs?: Vector4;
  50683. backUVs?: Vector4;
  50684. instance?: Mesh;
  50685. invertUV?: boolean;
  50686. }, scene?: Nullable<Scene>): Mesh;
  50687. /**
  50688. * Creates an custom extruded shape mesh.
  50689. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50690. * * 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.
  50691. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50692. * * 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
  50693. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50694. * * 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
  50695. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50696. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50697. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50698. * * 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
  50699. * * 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
  50700. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50703. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50705. * @param name defines the name of the mesh
  50706. * @param options defines the options used to create the mesh
  50707. * @param scene defines the hosting scene
  50708. * @returns the custom extruded shape mesh
  50709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50710. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50712. */
  50713. static ExtrudeShapeCustom(name: string, options: {
  50714. shape: Vector3[];
  50715. path: Vector3[];
  50716. scaleFunction?: any;
  50717. rotationFunction?: any;
  50718. ribbonCloseArray?: boolean;
  50719. ribbonClosePath?: boolean;
  50720. cap?: number;
  50721. updatable?: boolean;
  50722. sideOrientation?: number;
  50723. frontUVs?: Vector4;
  50724. backUVs?: Vector4;
  50725. instance?: Mesh;
  50726. invertUV?: boolean;
  50727. }, scene: Scene): Mesh;
  50728. /**
  50729. * Creates lathe mesh.
  50730. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50731. * * 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
  50732. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50733. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50734. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50735. * * 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
  50736. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50737. * * 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
  50738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50740. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50742. * @param name defines the name of the mesh
  50743. * @param options defines the options used to create the mesh
  50744. * @param scene defines the hosting scene
  50745. * @returns the lathe mesh
  50746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50747. */
  50748. static CreateLathe(name: string, options: {
  50749. shape: Vector3[];
  50750. radius?: number;
  50751. tessellation?: number;
  50752. clip?: number;
  50753. arc?: number;
  50754. closed?: boolean;
  50755. updatable?: boolean;
  50756. sideOrientation?: number;
  50757. frontUVs?: Vector4;
  50758. backUVs?: Vector4;
  50759. cap?: number;
  50760. invertUV?: boolean;
  50761. }, scene: Scene): Mesh;
  50762. /**
  50763. * Creates a plane mesh
  50764. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50765. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50766. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50770. * @param name defines the name of the mesh
  50771. * @param options defines the options used to create the mesh
  50772. * @param scene defines the hosting scene
  50773. * @returns the plane mesh
  50774. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50775. */
  50776. static CreatePlane(name: string, options: {
  50777. size?: number;
  50778. width?: number;
  50779. height?: number;
  50780. sideOrientation?: number;
  50781. frontUVs?: Vector4;
  50782. backUVs?: Vector4;
  50783. updatable?: boolean;
  50784. sourcePlane?: Plane;
  50785. }, scene: Scene): Mesh;
  50786. /**
  50787. * Creates a ground mesh
  50788. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50789. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50791. * @param name defines the name of the mesh
  50792. * @param options defines the options used to create the mesh
  50793. * @param scene defines the hosting scene
  50794. * @returns the ground mesh
  50795. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50796. */
  50797. static CreateGround(name: string, options: {
  50798. width?: number;
  50799. height?: number;
  50800. subdivisions?: number;
  50801. subdivisionsX?: number;
  50802. subdivisionsY?: number;
  50803. updatable?: boolean;
  50804. }, scene: any): Mesh;
  50805. /**
  50806. * Creates a tiled ground mesh
  50807. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50808. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50809. * * 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
  50810. * * 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
  50811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50812. * @param name defines the name of the mesh
  50813. * @param options defines the options used to create the mesh
  50814. * @param scene defines the hosting scene
  50815. * @returns the tiled ground mesh
  50816. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50817. */
  50818. static CreateTiledGround(name: string, options: {
  50819. xmin: number;
  50820. zmin: number;
  50821. xmax: number;
  50822. zmax: number;
  50823. subdivisions?: {
  50824. w: number;
  50825. h: number;
  50826. };
  50827. precision?: {
  50828. w: number;
  50829. h: number;
  50830. };
  50831. updatable?: boolean;
  50832. }, scene: Scene): Mesh;
  50833. /**
  50834. * Creates a ground mesh from a height map
  50835. * * The parameter `url` sets the URL of the height map image resource.
  50836. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50837. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50838. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50839. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50840. * * 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.
  50841. * * 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).
  50842. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50844. * @param name defines the name of the mesh
  50845. * @param url defines the url to the height map
  50846. * @param options defines the options used to create the mesh
  50847. * @param scene defines the hosting scene
  50848. * @returns the ground mesh
  50849. * @see https://doc.babylonjs.com/babylon101/height_map
  50850. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50851. */
  50852. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50853. width?: number;
  50854. height?: number;
  50855. subdivisions?: number;
  50856. minHeight?: number;
  50857. maxHeight?: number;
  50858. colorFilter?: Color3;
  50859. alphaFilter?: number;
  50860. updatable?: boolean;
  50861. onReady?: (mesh: GroundMesh) => void;
  50862. }, scene: Scene): GroundMesh;
  50863. /**
  50864. * Creates a polygon mesh
  50865. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50866. * * 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
  50867. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50870. * * Remember you can only change the shape positions, not their number when updating a polygon
  50871. * @param name defines the name of the mesh
  50872. * @param options defines the options used to create the mesh
  50873. * @param scene defines the hosting scene
  50874. * @param earcutInjection can be used to inject your own earcut reference
  50875. * @returns the polygon mesh
  50876. */
  50877. static CreatePolygon(name: string, options: {
  50878. shape: Vector3[];
  50879. holes?: Vector3[][];
  50880. depth?: number;
  50881. faceUV?: Vector4[];
  50882. faceColors?: Color4[];
  50883. updatable?: boolean;
  50884. sideOrientation?: number;
  50885. frontUVs?: Vector4;
  50886. backUVs?: Vector4;
  50887. }, scene: Scene, earcutInjection?: any): Mesh;
  50888. /**
  50889. * Creates an extruded polygon mesh, with depth in the Y direction.
  50890. * * 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)
  50891. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50892. * @param name defines the name of the mesh
  50893. * @param options defines the options used to create the mesh
  50894. * @param scene defines the hosting scene
  50895. * @param earcutInjection can be used to inject your own earcut reference
  50896. * @returns the polygon mesh
  50897. */
  50898. static ExtrudePolygon(name: string, options: {
  50899. shape: Vector3[];
  50900. holes?: Vector3[][];
  50901. depth?: number;
  50902. faceUV?: Vector4[];
  50903. faceColors?: Color4[];
  50904. updatable?: boolean;
  50905. sideOrientation?: number;
  50906. frontUVs?: Vector4;
  50907. backUVs?: Vector4;
  50908. }, scene: Scene, earcutInjection?: any): Mesh;
  50909. /**
  50910. * Creates a tube mesh.
  50911. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50912. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50913. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50914. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50915. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50916. * * 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)
  50917. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50918. * * 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
  50919. * * 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
  50920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50922. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50924. * @param name defines the name of the mesh
  50925. * @param options defines the options used to create the mesh
  50926. * @param scene defines the hosting scene
  50927. * @returns the tube mesh
  50928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50929. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50930. */
  50931. static CreateTube(name: string, options: {
  50932. path: Vector3[];
  50933. radius?: number;
  50934. tessellation?: number;
  50935. radiusFunction?: {
  50936. (i: number, distance: number): number;
  50937. };
  50938. cap?: number;
  50939. arc?: number;
  50940. updatable?: boolean;
  50941. sideOrientation?: number;
  50942. frontUVs?: Vector4;
  50943. backUVs?: Vector4;
  50944. instance?: Mesh;
  50945. invertUV?: boolean;
  50946. }, scene: Scene): Mesh;
  50947. /**
  50948. * Creates a polyhedron mesh
  50949. * * 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
  50950. * * The parameter `size` (positive float, default 1) sets the polygon size
  50951. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50952. * * 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`
  50953. * * 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
  50954. * * 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)`)
  50955. * * 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
  50956. * * 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
  50957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50960. * @param name defines the name of the mesh
  50961. * @param options defines the options used to create the mesh
  50962. * @param scene defines the hosting scene
  50963. * @returns the polyhedron mesh
  50964. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50965. */
  50966. static CreatePolyhedron(name: string, options: {
  50967. type?: number;
  50968. size?: number;
  50969. sizeX?: number;
  50970. sizeY?: number;
  50971. sizeZ?: number;
  50972. custom?: any;
  50973. faceUV?: Vector4[];
  50974. faceColors?: Color4[];
  50975. flat?: boolean;
  50976. updatable?: boolean;
  50977. sideOrientation?: number;
  50978. frontUVs?: Vector4;
  50979. backUVs?: Vector4;
  50980. }, scene: Scene): Mesh;
  50981. /**
  50982. * Creates a decal mesh.
  50983. * 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
  50984. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50985. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50986. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50987. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50988. * @param name defines the name of the mesh
  50989. * @param sourceMesh defines the mesh where the decal must be applied
  50990. * @param options defines the options used to create the mesh
  50991. * @param scene defines the hosting scene
  50992. * @returns the decal mesh
  50993. * @see https://doc.babylonjs.com/how_to/decals
  50994. */
  50995. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50996. position?: Vector3;
  50997. normal?: Vector3;
  50998. size?: Vector3;
  50999. angle?: number;
  51000. }): Mesh;
  51001. }
  51002. }
  51003. declare module "babylonjs/Meshes/meshSimplification" {
  51004. import { Mesh } from "babylonjs/Meshes/mesh";
  51005. /**
  51006. * A simplifier interface for future simplification implementations
  51007. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51008. */
  51009. export interface ISimplifier {
  51010. /**
  51011. * Simplification of a given mesh according to the given settings.
  51012. * Since this requires computation, it is assumed that the function runs async.
  51013. * @param settings The settings of the simplification, including quality and distance
  51014. * @param successCallback A callback that will be called after the mesh was simplified.
  51015. * @param errorCallback in case of an error, this callback will be called. optional.
  51016. */
  51017. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51018. }
  51019. /**
  51020. * Expected simplification settings.
  51021. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51022. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51023. */
  51024. export interface ISimplificationSettings {
  51025. /**
  51026. * Gets or sets the expected quality
  51027. */
  51028. quality: number;
  51029. /**
  51030. * Gets or sets the distance when this optimized version should be used
  51031. */
  51032. distance: number;
  51033. /**
  51034. * Gets an already optimized mesh
  51035. */
  51036. optimizeMesh?: boolean;
  51037. }
  51038. /**
  51039. * Class used to specify simplification options
  51040. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51041. */
  51042. export class SimplificationSettings implements ISimplificationSettings {
  51043. /** expected quality */
  51044. quality: number;
  51045. /** distance when this optimized version should be used */
  51046. distance: number;
  51047. /** already optimized mesh */
  51048. optimizeMesh?: boolean | undefined;
  51049. /**
  51050. * Creates a SimplificationSettings
  51051. * @param quality expected quality
  51052. * @param distance distance when this optimized version should be used
  51053. * @param optimizeMesh already optimized mesh
  51054. */
  51055. constructor(
  51056. /** expected quality */
  51057. quality: number,
  51058. /** distance when this optimized version should be used */
  51059. distance: number,
  51060. /** already optimized mesh */
  51061. optimizeMesh?: boolean | undefined);
  51062. }
  51063. /**
  51064. * Interface used to define a simplification task
  51065. */
  51066. export interface ISimplificationTask {
  51067. /**
  51068. * Array of settings
  51069. */
  51070. settings: Array<ISimplificationSettings>;
  51071. /**
  51072. * Simplification type
  51073. */
  51074. simplificationType: SimplificationType;
  51075. /**
  51076. * Mesh to simplify
  51077. */
  51078. mesh: Mesh;
  51079. /**
  51080. * Callback called on success
  51081. */
  51082. successCallback?: () => void;
  51083. /**
  51084. * Defines if parallel processing can be used
  51085. */
  51086. parallelProcessing: boolean;
  51087. }
  51088. /**
  51089. * Queue used to order the simplification tasks
  51090. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51091. */
  51092. export class SimplificationQueue {
  51093. private _simplificationArray;
  51094. /**
  51095. * Gets a boolean indicating that the process is still running
  51096. */
  51097. running: boolean;
  51098. /**
  51099. * Creates a new queue
  51100. */
  51101. constructor();
  51102. /**
  51103. * Adds a new simplification task
  51104. * @param task defines a task to add
  51105. */
  51106. addTask(task: ISimplificationTask): void;
  51107. /**
  51108. * Execute next task
  51109. */
  51110. executeNext(): void;
  51111. /**
  51112. * Execute a simplification task
  51113. * @param task defines the task to run
  51114. */
  51115. runSimplification(task: ISimplificationTask): void;
  51116. private getSimplifier;
  51117. }
  51118. /**
  51119. * The implemented types of simplification
  51120. * At the moment only Quadratic Error Decimation is implemented
  51121. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51122. */
  51123. export enum SimplificationType {
  51124. /** Quadratic error decimation */
  51125. QUADRATIC = 0
  51126. }
  51127. }
  51128. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51129. import { Scene } from "babylonjs/scene";
  51130. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51131. import { ISceneComponent } from "babylonjs/sceneComponent";
  51132. module "babylonjs/scene" {
  51133. interface Scene {
  51134. /** @hidden (Backing field) */
  51135. _simplificationQueue: SimplificationQueue;
  51136. /**
  51137. * Gets or sets the simplification queue attached to the scene
  51138. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51139. */
  51140. simplificationQueue: SimplificationQueue;
  51141. }
  51142. }
  51143. module "babylonjs/Meshes/mesh" {
  51144. interface Mesh {
  51145. /**
  51146. * Simplify the mesh according to the given array of settings.
  51147. * Function will return immediately and will simplify async
  51148. * @param settings a collection of simplification settings
  51149. * @param parallelProcessing should all levels calculate parallel or one after the other
  51150. * @param simplificationType the type of simplification to run
  51151. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51152. * @returns the current mesh
  51153. */
  51154. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51155. }
  51156. }
  51157. /**
  51158. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51159. * created in a scene
  51160. */
  51161. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51162. /**
  51163. * The component name helpfull to identify the component in the list of scene components.
  51164. */
  51165. readonly name: string;
  51166. /**
  51167. * The scene the component belongs to.
  51168. */
  51169. scene: Scene;
  51170. /**
  51171. * Creates a new instance of the component for the given scene
  51172. * @param scene Defines the scene to register the component in
  51173. */
  51174. constructor(scene: Scene);
  51175. /**
  51176. * Registers the component in a given scene
  51177. */
  51178. register(): void;
  51179. /**
  51180. * Rebuilds the elements related to this component in case of
  51181. * context lost for instance.
  51182. */
  51183. rebuild(): void;
  51184. /**
  51185. * Disposes the component and the associated ressources
  51186. */
  51187. dispose(): void;
  51188. private _beforeCameraUpdate;
  51189. }
  51190. }
  51191. declare module "babylonjs/Meshes/Builders/index" {
  51192. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51193. export * from "babylonjs/Meshes/Builders/discBuilder";
  51194. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51195. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51196. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51197. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51198. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51199. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51200. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51201. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51202. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51203. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51204. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51205. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51206. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51207. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51208. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51209. }
  51210. declare module "babylonjs/Meshes/index" {
  51211. export * from "babylonjs/Meshes/abstractMesh";
  51212. export * from "babylonjs/Meshes/buffer";
  51213. export * from "babylonjs/Meshes/Compression/index";
  51214. export * from "babylonjs/Meshes/csg";
  51215. export * from "babylonjs/Meshes/geometry";
  51216. export * from "babylonjs/Meshes/groundMesh";
  51217. export * from "babylonjs/Meshes/trailMesh";
  51218. export * from "babylonjs/Meshes/instancedMesh";
  51219. export * from "babylonjs/Meshes/linesMesh";
  51220. export * from "babylonjs/Meshes/mesh";
  51221. export * from "babylonjs/Meshes/mesh.vertexData";
  51222. export * from "babylonjs/Meshes/meshBuilder";
  51223. export * from "babylonjs/Meshes/meshSimplification";
  51224. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51225. export * from "babylonjs/Meshes/polygonMesh";
  51226. export * from "babylonjs/Meshes/subMesh";
  51227. export * from "babylonjs/Meshes/transformNode";
  51228. export * from "babylonjs/Meshes/Builders/index";
  51229. }
  51230. declare module "babylonjs/Morph/index" {
  51231. export * from "babylonjs/Morph/morphTarget";
  51232. export * from "babylonjs/Morph/morphTargetManager";
  51233. }
  51234. declare module "babylonjs/Offline/database" {
  51235. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51236. /**
  51237. * Class used to enable access to IndexedDB
  51238. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51239. */
  51240. export class Database implements IOfflineProvider {
  51241. private _callbackManifestChecked;
  51242. private _currentSceneUrl;
  51243. private _db;
  51244. private _enableSceneOffline;
  51245. private _enableTexturesOffline;
  51246. private _manifestVersionFound;
  51247. private _mustUpdateRessources;
  51248. private _hasReachedQuota;
  51249. private _isSupported;
  51250. private _idbFactory;
  51251. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51252. private static IsUASupportingBlobStorage;
  51253. /**
  51254. * Gets a boolean indicating if Database storate is enabled (off by default)
  51255. */
  51256. static IDBStorageEnabled: boolean;
  51257. /**
  51258. * Gets a boolean indicating if scene must be saved in the database
  51259. */
  51260. readonly enableSceneOffline: boolean;
  51261. /**
  51262. * Gets a boolean indicating if textures must be saved in the database
  51263. */
  51264. readonly enableTexturesOffline: boolean;
  51265. /**
  51266. * Creates a new Database
  51267. * @param urlToScene defines the url to load the scene
  51268. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51269. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51270. */
  51271. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51272. private static _ParseURL;
  51273. private static _ReturnFullUrlLocation;
  51274. private _checkManifestFile;
  51275. /**
  51276. * Open the database and make it available
  51277. * @param successCallback defines the callback to call on success
  51278. * @param errorCallback defines the callback to call on error
  51279. */
  51280. open(successCallback: () => void, errorCallback: () => void): void;
  51281. /**
  51282. * Loads an image from the database
  51283. * @param url defines the url to load from
  51284. * @param image defines the target DOM image
  51285. */
  51286. loadImage(url: string, image: HTMLImageElement): void;
  51287. private _loadImageFromDBAsync;
  51288. private _saveImageIntoDBAsync;
  51289. private _checkVersionFromDB;
  51290. private _loadVersionFromDBAsync;
  51291. private _saveVersionIntoDBAsync;
  51292. /**
  51293. * Loads a file from database
  51294. * @param url defines the URL to load from
  51295. * @param sceneLoaded defines a callback to call on success
  51296. * @param progressCallBack defines a callback to call when progress changed
  51297. * @param errorCallback defines a callback to call on error
  51298. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51299. */
  51300. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51301. private _loadFileAsync;
  51302. private _saveFileAsync;
  51303. /**
  51304. * Validates if xhr data is correct
  51305. * @param xhr defines the request to validate
  51306. * @param dataType defines the expected data type
  51307. * @returns true if data is correct
  51308. */
  51309. private static _ValidateXHRData;
  51310. }
  51311. }
  51312. declare module "babylonjs/Offline/index" {
  51313. export * from "babylonjs/Offline/database";
  51314. export * from "babylonjs/Offline/IOfflineProvider";
  51315. }
  51316. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51317. /** @hidden */
  51318. export var gpuUpdateParticlesPixelShader: {
  51319. name: string;
  51320. shader: string;
  51321. };
  51322. }
  51323. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51324. /** @hidden */
  51325. export var gpuUpdateParticlesVertexShader: {
  51326. name: string;
  51327. shader: string;
  51328. };
  51329. }
  51330. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51331. /** @hidden */
  51332. export var clipPlaneFragmentDeclaration2: {
  51333. name: string;
  51334. shader: string;
  51335. };
  51336. }
  51337. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51338. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51339. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51340. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51341. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51342. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51343. /** @hidden */
  51344. export var gpuRenderParticlesPixelShader: {
  51345. name: string;
  51346. shader: string;
  51347. };
  51348. }
  51349. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51350. /** @hidden */
  51351. export var clipPlaneVertexDeclaration2: {
  51352. name: string;
  51353. shader: string;
  51354. };
  51355. }
  51356. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51357. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51358. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51359. /** @hidden */
  51360. export var gpuRenderParticlesVertexShader: {
  51361. name: string;
  51362. shader: string;
  51363. };
  51364. }
  51365. declare module "babylonjs/Particles/gpuParticleSystem" {
  51366. import { Nullable } from "babylonjs/types";
  51367. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51368. import { Observable } from "babylonjs/Misc/observable";
  51369. import { Color4, Color3 } from "babylonjs/Maths/math";
  51370. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51371. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51372. import { Scene, IDisposable } from "babylonjs/scene";
  51373. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51374. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51375. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51376. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51377. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51378. /**
  51379. * This represents a GPU particle system in Babylon
  51380. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51381. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51382. */
  51383. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51384. /**
  51385. * The layer mask we are rendering the particles through.
  51386. */
  51387. layerMask: number;
  51388. private _capacity;
  51389. private _activeCount;
  51390. private _currentActiveCount;
  51391. private _accumulatedCount;
  51392. private _renderEffect;
  51393. private _updateEffect;
  51394. private _buffer0;
  51395. private _buffer1;
  51396. private _spriteBuffer;
  51397. private _updateVAO;
  51398. private _renderVAO;
  51399. private _targetIndex;
  51400. private _sourceBuffer;
  51401. private _targetBuffer;
  51402. private _engine;
  51403. private _currentRenderId;
  51404. private _started;
  51405. private _stopped;
  51406. private _timeDelta;
  51407. private _randomTexture;
  51408. private _randomTexture2;
  51409. private _attributesStrideSize;
  51410. private _updateEffectOptions;
  51411. private _randomTextureSize;
  51412. private _actualFrame;
  51413. private readonly _rawTextureWidth;
  51414. /**
  51415. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51416. */
  51417. static readonly IsSupported: boolean;
  51418. /**
  51419. * An event triggered when the system is disposed.
  51420. */
  51421. onDisposeObservable: Observable<GPUParticleSystem>;
  51422. /**
  51423. * Gets the maximum number of particles active at the same time.
  51424. * @returns The max number of active particles.
  51425. */
  51426. getCapacity(): number;
  51427. /**
  51428. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51429. * to override the particles.
  51430. */
  51431. forceDepthWrite: boolean;
  51432. /**
  51433. * Gets or set the number of active particles
  51434. */
  51435. activeParticleCount: number;
  51436. private _preWarmDone;
  51437. /**
  51438. * Is this system ready to be used/rendered
  51439. * @return true if the system is ready
  51440. */
  51441. isReady(): boolean;
  51442. /**
  51443. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51444. * @returns True if it has been started, otherwise false.
  51445. */
  51446. isStarted(): boolean;
  51447. /**
  51448. * Starts the particle system and begins to emit
  51449. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51450. */
  51451. start(delay?: number): void;
  51452. /**
  51453. * Stops the particle system.
  51454. */
  51455. stop(): void;
  51456. /**
  51457. * Remove all active particles
  51458. */
  51459. reset(): void;
  51460. /**
  51461. * Returns the string "GPUParticleSystem"
  51462. * @returns a string containing the class name
  51463. */
  51464. getClassName(): string;
  51465. private _colorGradientsTexture;
  51466. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51467. /**
  51468. * Adds a new color gradient
  51469. * @param gradient defines the gradient to use (between 0 and 1)
  51470. * @param color1 defines the color to affect to the specified gradient
  51471. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51472. * @returns the current particle system
  51473. */
  51474. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51475. /**
  51476. * Remove a specific color gradient
  51477. * @param gradient defines the gradient to remove
  51478. * @returns the current particle system
  51479. */
  51480. removeColorGradient(gradient: number): GPUParticleSystem;
  51481. private _angularSpeedGradientsTexture;
  51482. private _sizeGradientsTexture;
  51483. private _velocityGradientsTexture;
  51484. private _limitVelocityGradientsTexture;
  51485. private _dragGradientsTexture;
  51486. private _addFactorGradient;
  51487. /**
  51488. * Adds a new size gradient
  51489. * @param gradient defines the gradient to use (between 0 and 1)
  51490. * @param factor defines the size factor to affect to the specified gradient
  51491. * @returns the current particle system
  51492. */
  51493. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51494. /**
  51495. * Remove a specific size gradient
  51496. * @param gradient defines the gradient to remove
  51497. * @returns the current particle system
  51498. */
  51499. removeSizeGradient(gradient: number): GPUParticleSystem;
  51500. /**
  51501. * Adds a new angular speed gradient
  51502. * @param gradient defines the gradient to use (between 0 and 1)
  51503. * @param factor defines the angular speed to affect to the specified gradient
  51504. * @returns the current particle system
  51505. */
  51506. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51507. /**
  51508. * Remove a specific angular speed gradient
  51509. * @param gradient defines the gradient to remove
  51510. * @returns the current particle system
  51511. */
  51512. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51513. /**
  51514. * Adds a new velocity gradient
  51515. * @param gradient defines the gradient to use (between 0 and 1)
  51516. * @param factor defines the velocity to affect to the specified gradient
  51517. * @returns the current particle system
  51518. */
  51519. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51520. /**
  51521. * Remove a specific velocity gradient
  51522. * @param gradient defines the gradient to remove
  51523. * @returns the current particle system
  51524. */
  51525. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51526. /**
  51527. * Adds a new limit velocity gradient
  51528. * @param gradient defines the gradient to use (between 0 and 1)
  51529. * @param factor defines the limit velocity value to affect to the specified gradient
  51530. * @returns the current particle system
  51531. */
  51532. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51533. /**
  51534. * Remove a specific limit velocity gradient
  51535. * @param gradient defines the gradient to remove
  51536. * @returns the current particle system
  51537. */
  51538. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51539. /**
  51540. * Adds a new drag gradient
  51541. * @param gradient defines the gradient to use (between 0 and 1)
  51542. * @param factor defines the drag value to affect to the specified gradient
  51543. * @returns the current particle system
  51544. */
  51545. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51546. /**
  51547. * Remove a specific drag gradient
  51548. * @param gradient defines the gradient to remove
  51549. * @returns the current particle system
  51550. */
  51551. removeDragGradient(gradient: number): GPUParticleSystem;
  51552. /**
  51553. * Not supported by GPUParticleSystem
  51554. * @param gradient defines the gradient to use (between 0 and 1)
  51555. * @param factor defines the emit rate value to affect to the specified gradient
  51556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51557. * @returns the current particle system
  51558. */
  51559. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51560. /**
  51561. * Not supported by GPUParticleSystem
  51562. * @param gradient defines the gradient to remove
  51563. * @returns the current particle system
  51564. */
  51565. removeEmitRateGradient(gradient: number): IParticleSystem;
  51566. /**
  51567. * Not supported by GPUParticleSystem
  51568. * @param gradient defines the gradient to use (between 0 and 1)
  51569. * @param factor defines the start size value to affect to the specified gradient
  51570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51571. * @returns the current particle system
  51572. */
  51573. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51574. /**
  51575. * Not supported by GPUParticleSystem
  51576. * @param gradient defines the gradient to remove
  51577. * @returns the current particle system
  51578. */
  51579. removeStartSizeGradient(gradient: number): IParticleSystem;
  51580. /**
  51581. * Not supported by GPUParticleSystem
  51582. * @param gradient defines the gradient to use (between 0 and 1)
  51583. * @param min defines the color remap minimal range
  51584. * @param max defines the color remap maximal range
  51585. * @returns the current particle system
  51586. */
  51587. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51588. /**
  51589. * Not supported by GPUParticleSystem
  51590. * @param gradient defines the gradient to remove
  51591. * @returns the current particle system
  51592. */
  51593. removeColorRemapGradient(): IParticleSystem;
  51594. /**
  51595. * Not supported by GPUParticleSystem
  51596. * @param gradient defines the gradient to use (between 0 and 1)
  51597. * @param min defines the alpha remap minimal range
  51598. * @param max defines the alpha remap maximal range
  51599. * @returns the current particle system
  51600. */
  51601. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51602. /**
  51603. * Not supported by GPUParticleSystem
  51604. * @param gradient defines the gradient to remove
  51605. * @returns the current particle system
  51606. */
  51607. removeAlphaRemapGradient(): IParticleSystem;
  51608. /**
  51609. * Not supported by GPUParticleSystem
  51610. * @param gradient defines the gradient to use (between 0 and 1)
  51611. * @param color defines the color to affect to the specified gradient
  51612. * @returns the current particle system
  51613. */
  51614. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51615. /**
  51616. * Not supported by GPUParticleSystem
  51617. * @param gradient defines the gradient to remove
  51618. * @returns the current particle system
  51619. */
  51620. removeRampGradient(): IParticleSystem;
  51621. /**
  51622. * Not supported by GPUParticleSystem
  51623. * @returns the list of ramp gradients
  51624. */
  51625. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51626. /**
  51627. * Not supported by GPUParticleSystem
  51628. * Gets or sets a boolean indicating that ramp gradients must be used
  51629. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51630. */
  51631. useRampGradients: boolean;
  51632. /**
  51633. * Not supported by GPUParticleSystem
  51634. * @param gradient defines the gradient to use (between 0 and 1)
  51635. * @param factor defines the life time factor to affect to the specified gradient
  51636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51637. * @returns the current particle system
  51638. */
  51639. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51640. /**
  51641. * Not supported by GPUParticleSystem
  51642. * @param gradient defines the gradient to remove
  51643. * @returns the current particle system
  51644. */
  51645. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51646. /**
  51647. * Instantiates a GPU particle system.
  51648. * 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.
  51649. * @param name The name of the particle system
  51650. * @param options The options used to create the system
  51651. * @param scene The scene the particle system belongs to
  51652. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51653. */
  51654. constructor(name: string, options: Partial<{
  51655. capacity: number;
  51656. randomTextureSize: number;
  51657. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51658. protected _reset(): void;
  51659. private _createUpdateVAO;
  51660. private _createRenderVAO;
  51661. private _initialize;
  51662. /** @hidden */
  51663. _recreateUpdateEffect(): void;
  51664. /** @hidden */
  51665. _recreateRenderEffect(): void;
  51666. /**
  51667. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51668. * @param preWarm defines if we are in the pre-warmimg phase
  51669. */
  51670. animate(preWarm?: boolean): void;
  51671. private _createFactorGradientTexture;
  51672. private _createSizeGradientTexture;
  51673. private _createAngularSpeedGradientTexture;
  51674. private _createVelocityGradientTexture;
  51675. private _createLimitVelocityGradientTexture;
  51676. private _createDragGradientTexture;
  51677. private _createColorGradientTexture;
  51678. /**
  51679. * Renders the particle system in its current state
  51680. * @param preWarm defines if the system should only update the particles but not render them
  51681. * @returns the current number of particles
  51682. */
  51683. render(preWarm?: boolean): number;
  51684. /**
  51685. * Rebuilds the particle system
  51686. */
  51687. rebuild(): void;
  51688. private _releaseBuffers;
  51689. private _releaseVAOs;
  51690. /**
  51691. * Disposes the particle system and free the associated resources
  51692. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51693. */
  51694. dispose(disposeTexture?: boolean): void;
  51695. /**
  51696. * Clones the particle system.
  51697. * @param name The name of the cloned object
  51698. * @param newEmitter The new emitter to use
  51699. * @returns the cloned particle system
  51700. */
  51701. clone(name: string, newEmitter: any): GPUParticleSystem;
  51702. /**
  51703. * Serializes the particle system to a JSON object.
  51704. * @returns the JSON object
  51705. */
  51706. serialize(): any;
  51707. /**
  51708. * Parses a JSON object to create a GPU particle system.
  51709. * @param parsedParticleSystem The JSON object to parse
  51710. * @param scene The scene to create the particle system in
  51711. * @param rootUrl The root url to use to load external dependencies like texture
  51712. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51713. * @returns the parsed GPU particle system
  51714. */
  51715. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51716. }
  51717. }
  51718. declare module "babylonjs/Particles/particleSystemSet" {
  51719. import { Nullable } from "babylonjs/types";
  51720. import { Color3 } from "babylonjs/Maths/math";
  51721. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51723. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51724. import { Scene, IDisposable } from "babylonjs/scene";
  51725. /**
  51726. * Represents a set of particle systems working together to create a specific effect
  51727. */
  51728. export class ParticleSystemSet implements IDisposable {
  51729. private _emitterCreationOptions;
  51730. private _emitterNode;
  51731. /**
  51732. * Gets the particle system list
  51733. */
  51734. systems: IParticleSystem[];
  51735. /**
  51736. * Gets the emitter node used with this set
  51737. */
  51738. readonly emitterNode: Nullable<TransformNode>;
  51739. /**
  51740. * Creates a new emitter mesh as a sphere
  51741. * @param options defines the options used to create the sphere
  51742. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51743. * @param scene defines the hosting scene
  51744. */
  51745. setEmitterAsSphere(options: {
  51746. diameter: number;
  51747. segments: number;
  51748. color: Color3;
  51749. }, renderingGroupId: number, scene: Scene): void;
  51750. /**
  51751. * Starts all particle systems of the set
  51752. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51753. */
  51754. start(emitter?: AbstractMesh): void;
  51755. /**
  51756. * Release all associated resources
  51757. */
  51758. dispose(): void;
  51759. /**
  51760. * Serialize the set into a JSON compatible object
  51761. * @returns a JSON compatible representation of the set
  51762. */
  51763. serialize(): any;
  51764. /**
  51765. * Parse a new ParticleSystemSet from a serialized source
  51766. * @param data defines a JSON compatible representation of the set
  51767. * @param scene defines the hosting scene
  51768. * @param gpu defines if we want GPU particles or CPU particles
  51769. * @returns a new ParticleSystemSet
  51770. */
  51771. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51772. }
  51773. }
  51774. declare module "babylonjs/Particles/particleHelper" {
  51775. import { Nullable } from "babylonjs/types";
  51776. import { Scene } from "babylonjs/scene";
  51777. import { Vector3 } from "babylonjs/Maths/math";
  51778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51779. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51780. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51781. /**
  51782. * This class is made for on one-liner static method to help creating particle system set.
  51783. */
  51784. export class ParticleHelper {
  51785. /**
  51786. * Gets or sets base Assets URL
  51787. */
  51788. static BaseAssetsUrl: string;
  51789. /**
  51790. * Create a default particle system that you can tweak
  51791. * @param emitter defines the emitter to use
  51792. * @param capacity defines the system capacity (default is 500 particles)
  51793. * @param scene defines the hosting scene
  51794. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51795. * @returns the new Particle system
  51796. */
  51797. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51798. /**
  51799. * This is the main static method (one-liner) of this helper to create different particle systems
  51800. * @param type This string represents the type to the particle system to create
  51801. * @param scene The scene where the particle system should live
  51802. * @param gpu If the system will use gpu
  51803. * @returns the ParticleSystemSet created
  51804. */
  51805. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51806. /**
  51807. * Static function used to export a particle system to a ParticleSystemSet variable.
  51808. * Please note that the emitter shape is not exported
  51809. * @param systems defines the particle systems to export
  51810. * @returns the created particle system set
  51811. */
  51812. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51813. }
  51814. }
  51815. declare module "babylonjs/Particles/particleSystemComponent" {
  51816. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51817. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51818. import "babylonjs/Shaders/particles.vertex";
  51819. module "babylonjs/Engines/engine" {
  51820. interface Engine {
  51821. /**
  51822. * Create an effect to use with particle systems.
  51823. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51824. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51825. * @param uniformsNames defines a list of attribute names
  51826. * @param samplers defines an array of string used to represent textures
  51827. * @param defines defines the string containing the defines to use to compile the shaders
  51828. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51829. * @param onCompiled defines a function to call when the effect creation is successful
  51830. * @param onError defines a function to call when the effect creation has failed
  51831. * @returns the new Effect
  51832. */
  51833. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51834. }
  51835. }
  51836. module "babylonjs/Meshes/mesh" {
  51837. interface Mesh {
  51838. /**
  51839. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51840. * @returns an array of IParticleSystem
  51841. */
  51842. getEmittedParticleSystems(): IParticleSystem[];
  51843. /**
  51844. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51845. * @returns an array of IParticleSystem
  51846. */
  51847. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51848. }
  51849. }
  51850. /**
  51851. * @hidden
  51852. */
  51853. export var _IDoNeedToBeInTheBuild: number;
  51854. }
  51855. declare module "babylonjs/Particles/index" {
  51856. export * from "babylonjs/Particles/baseParticleSystem";
  51857. export * from "babylonjs/Particles/EmitterTypes/index";
  51858. export * from "babylonjs/Particles/gpuParticleSystem";
  51859. export * from "babylonjs/Particles/IParticleSystem";
  51860. export * from "babylonjs/Particles/particle";
  51861. export * from "babylonjs/Particles/particleHelper";
  51862. export * from "babylonjs/Particles/particleSystem";
  51863. export * from "babylonjs/Particles/particleSystemComponent";
  51864. export * from "babylonjs/Particles/particleSystemSet";
  51865. export * from "babylonjs/Particles/solidParticle";
  51866. export * from "babylonjs/Particles/solidParticleSystem";
  51867. export * from "babylonjs/Particles/subEmitter";
  51868. }
  51869. declare module "babylonjs/Physics/physicsEngineComponent" {
  51870. import { Nullable } from "babylonjs/types";
  51871. import { Observable, Observer } from "babylonjs/Misc/observable";
  51872. import { Vector3 } from "babylonjs/Maths/math";
  51873. import { Mesh } from "babylonjs/Meshes/mesh";
  51874. import { ISceneComponent } from "babylonjs/sceneComponent";
  51875. import { Scene } from "babylonjs/scene";
  51876. import { Node } from "babylonjs/node";
  51877. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51878. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51879. module "babylonjs/scene" {
  51880. interface Scene {
  51881. /** @hidden (Backing field) */
  51882. _physicsEngine: Nullable<IPhysicsEngine>;
  51883. /**
  51884. * Gets the current physics engine
  51885. * @returns a IPhysicsEngine or null if none attached
  51886. */
  51887. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51888. /**
  51889. * Enables physics to the current scene
  51890. * @param gravity defines the scene's gravity for the physics engine
  51891. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51892. * @return a boolean indicating if the physics engine was initialized
  51893. */
  51894. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51895. /**
  51896. * Disables and disposes the physics engine associated with the scene
  51897. */
  51898. disablePhysicsEngine(): void;
  51899. /**
  51900. * Gets a boolean indicating if there is an active physics engine
  51901. * @returns a boolean indicating if there is an active physics engine
  51902. */
  51903. isPhysicsEnabled(): boolean;
  51904. /**
  51905. * Deletes a physics compound impostor
  51906. * @param compound defines the compound to delete
  51907. */
  51908. deleteCompoundImpostor(compound: any): void;
  51909. /**
  51910. * An event triggered when physic simulation is about to be run
  51911. */
  51912. onBeforePhysicsObservable: Observable<Scene>;
  51913. /**
  51914. * An event triggered when physic simulation has been done
  51915. */
  51916. onAfterPhysicsObservable: Observable<Scene>;
  51917. }
  51918. }
  51919. module "babylonjs/Meshes/abstractMesh" {
  51920. interface AbstractMesh {
  51921. /** @hidden */
  51922. _physicsImpostor: Nullable<PhysicsImpostor>;
  51923. /**
  51924. * Gets or sets impostor used for physic simulation
  51925. * @see http://doc.babylonjs.com/features/physics_engine
  51926. */
  51927. physicsImpostor: Nullable<PhysicsImpostor>;
  51928. /**
  51929. * Gets the current physics impostor
  51930. * @see http://doc.babylonjs.com/features/physics_engine
  51931. * @returns a physics impostor or null
  51932. */
  51933. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51934. /** Apply a physic impulse to the mesh
  51935. * @param force defines the force to apply
  51936. * @param contactPoint defines where to apply the force
  51937. * @returns the current mesh
  51938. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51939. */
  51940. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51941. /**
  51942. * Creates a physic joint between two meshes
  51943. * @param otherMesh defines the other mesh to use
  51944. * @param pivot1 defines the pivot to use on this mesh
  51945. * @param pivot2 defines the pivot to use on the other mesh
  51946. * @param options defines additional options (can be plugin dependent)
  51947. * @returns the current mesh
  51948. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51949. */
  51950. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51951. /** @hidden */
  51952. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51953. }
  51954. }
  51955. /**
  51956. * Defines the physics engine scene component responsible to manage a physics engine
  51957. */
  51958. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51959. /**
  51960. * The component name helpful to identify the component in the list of scene components.
  51961. */
  51962. readonly name: string;
  51963. /**
  51964. * The scene the component belongs to.
  51965. */
  51966. scene: Scene;
  51967. /**
  51968. * Creates a new instance of the component for the given scene
  51969. * @param scene Defines the scene to register the component in
  51970. */
  51971. constructor(scene: Scene);
  51972. /**
  51973. * Registers the component in a given scene
  51974. */
  51975. register(): void;
  51976. /**
  51977. * Rebuilds the elements related to this component in case of
  51978. * context lost for instance.
  51979. */
  51980. rebuild(): void;
  51981. /**
  51982. * Disposes the component and the associated ressources
  51983. */
  51984. dispose(): void;
  51985. }
  51986. }
  51987. declare module "babylonjs/Physics/physicsHelper" {
  51988. import { Nullable } from "babylonjs/types";
  51989. import { Vector3 } from "babylonjs/Maths/math";
  51990. import { Mesh } from "babylonjs/Meshes/mesh";
  51991. import { Ray } from "babylonjs/Culling/ray";
  51992. import { Scene } from "babylonjs/scene";
  51993. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51994. /**
  51995. * A helper for physics simulations
  51996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51997. */
  51998. export class PhysicsHelper {
  51999. private _scene;
  52000. private _physicsEngine;
  52001. /**
  52002. * Initializes the Physics helper
  52003. * @param scene Babylon.js scene
  52004. */
  52005. constructor(scene: Scene);
  52006. /**
  52007. * Applies a radial explosion impulse
  52008. * @param origin the origin of the explosion
  52009. * @param radius the explosion radius
  52010. * @param strength the explosion strength
  52011. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52012. * @returns A physics radial explosion event, or null
  52013. */
  52014. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52015. /**
  52016. * Applies a radial explosion force
  52017. * @param origin the origin of the explosion
  52018. * @param radius the explosion radius
  52019. * @param strength the explosion strength
  52020. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52021. * @returns A physics radial explosion event, or null
  52022. */
  52023. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52024. /**
  52025. * Creates a gravitational field
  52026. * @param origin the origin of the explosion
  52027. * @param radius the explosion radius
  52028. * @param strength the explosion strength
  52029. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52030. * @returns A physics gravitational field event, or null
  52031. */
  52032. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52033. /**
  52034. * Creates a physics updraft event
  52035. * @param origin the origin of the updraft
  52036. * @param radius the radius of the updraft
  52037. * @param strength the strength of the updraft
  52038. * @param height the height of the updraft
  52039. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52040. * @returns A physics updraft event, or null
  52041. */
  52042. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52043. /**
  52044. * Creates a physics vortex event
  52045. * @param origin the of the vortex
  52046. * @param radius the radius of the vortex
  52047. * @param strength the strength of the vortex
  52048. * @param height the height of the vortex
  52049. * @returns a Physics vortex event, or null
  52050. * A physics vortex event or null
  52051. */
  52052. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  52053. }
  52054. /**
  52055. * Represents a physics radial explosion event
  52056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52057. */
  52058. export class PhysicsRadialExplosionEvent {
  52059. private _scene;
  52060. private _sphere;
  52061. private _sphereOptions;
  52062. private _rays;
  52063. private _dataFetched;
  52064. /**
  52065. * Initializes a radial explosioin event
  52066. * @param scene BabylonJS scene
  52067. */
  52068. constructor(scene: Scene);
  52069. /**
  52070. * Returns the data related to the radial explosion event (sphere & rays).
  52071. * @returns The radial explosion event data
  52072. */
  52073. getData(): PhysicsRadialExplosionEventData;
  52074. /**
  52075. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52076. * @param impostor A physics imposter
  52077. * @param origin the origin of the explosion
  52078. * @param radius the explosion radius
  52079. * @param strength the explosion strength
  52080. * @param falloff possible options: Constant & Linear
  52081. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52082. */
  52083. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  52084. /**
  52085. * Disposes the sphere.
  52086. * @param force Specifies if the sphere should be disposed by force
  52087. */
  52088. dispose(force?: boolean): void;
  52089. /*** Helpers ***/
  52090. private _prepareSphere;
  52091. private _intersectsWithSphere;
  52092. }
  52093. /**
  52094. * Represents a gravitational field event
  52095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52096. */
  52097. export class PhysicsGravitationalFieldEvent {
  52098. private _physicsHelper;
  52099. private _scene;
  52100. private _origin;
  52101. private _radius;
  52102. private _strength;
  52103. private _falloff;
  52104. private _tickCallback;
  52105. private _sphere;
  52106. private _dataFetched;
  52107. /**
  52108. * Initializes the physics gravitational field event
  52109. * @param physicsHelper A physics helper
  52110. * @param scene BabylonJS scene
  52111. * @param origin The origin position of the gravitational field event
  52112. * @param radius The radius of the gravitational field event
  52113. * @param strength The strength of the gravitational field event
  52114. * @param falloff The falloff for the gravitational field event
  52115. */
  52116. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  52117. /**
  52118. * Returns the data related to the gravitational field event (sphere).
  52119. * @returns A gravitational field event
  52120. */
  52121. getData(): PhysicsGravitationalFieldEventData;
  52122. /**
  52123. * Enables the gravitational field.
  52124. */
  52125. enable(): void;
  52126. /**
  52127. * Disables the gravitational field.
  52128. */
  52129. disable(): void;
  52130. /**
  52131. * Disposes the sphere.
  52132. * @param force The force to dispose from the gravitational field event
  52133. */
  52134. dispose(force?: boolean): void;
  52135. private _tick;
  52136. }
  52137. /**
  52138. * Represents a physics updraft event
  52139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52140. */
  52141. export class PhysicsUpdraftEvent {
  52142. private _scene;
  52143. private _origin;
  52144. private _radius;
  52145. private _strength;
  52146. private _height;
  52147. private _updraftMode;
  52148. private _physicsEngine;
  52149. private _originTop;
  52150. private _originDirection;
  52151. private _tickCallback;
  52152. private _cylinder;
  52153. private _cylinderPosition;
  52154. private _dataFetched;
  52155. /**
  52156. * Initializes the physics updraft event
  52157. * @param _scene BabylonJS scene
  52158. * @param _origin The origin position of the updraft
  52159. * @param _radius The radius of the updraft
  52160. * @param _strength The strength of the updraft
  52161. * @param _height The height of the updraft
  52162. * @param _updraftMode The mode of the updraft
  52163. */
  52164. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  52165. /**
  52166. * Returns the data related to the updraft event (cylinder).
  52167. * @returns A physics updraft event
  52168. */
  52169. getData(): PhysicsUpdraftEventData;
  52170. /**
  52171. * Enables the updraft.
  52172. */
  52173. enable(): void;
  52174. /**
  52175. * Disables the cortex.
  52176. */
  52177. disable(): void;
  52178. /**
  52179. * Disposes the sphere.
  52180. * @param force Specifies if the updraft should be disposed by force
  52181. */
  52182. dispose(force?: boolean): void;
  52183. private getImpostorForceAndContactPoint;
  52184. private _tick;
  52185. /*** Helpers ***/
  52186. private _prepareCylinder;
  52187. private _intersectsWithCylinder;
  52188. }
  52189. /**
  52190. * Represents a physics vortex event
  52191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52192. */
  52193. export class PhysicsVortexEvent {
  52194. private _scene;
  52195. private _origin;
  52196. private _radius;
  52197. private _strength;
  52198. private _height;
  52199. private _physicsEngine;
  52200. private _originTop;
  52201. private _centripetalForceThreshold;
  52202. private _updraftMultiplier;
  52203. private _tickCallback;
  52204. private _cylinder;
  52205. private _cylinderPosition;
  52206. private _dataFetched;
  52207. /**
  52208. * Initializes the physics vortex event
  52209. * @param _scene The BabylonJS scene
  52210. * @param _origin The origin position of the vortex
  52211. * @param _radius The radius of the vortex
  52212. * @param _strength The strength of the vortex
  52213. * @param _height The height of the vortex
  52214. */
  52215. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  52216. /**
  52217. * Returns the data related to the vortex event (cylinder).
  52218. * @returns The physics vortex event data
  52219. */
  52220. getData(): PhysicsVortexEventData;
  52221. /**
  52222. * Enables the vortex.
  52223. */
  52224. enable(): void;
  52225. /**
  52226. * Disables the cortex.
  52227. */
  52228. disable(): void;
  52229. /**
  52230. * Disposes the sphere.
  52231. * @param force
  52232. */
  52233. dispose(force?: boolean): void;
  52234. private getImpostorForceAndContactPoint;
  52235. private _tick;
  52236. /*** Helpers ***/
  52237. private _prepareCylinder;
  52238. private _intersectsWithCylinder;
  52239. }
  52240. /**
  52241. * The strenght of the force in correspondence to the distance of the affected object
  52242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52243. */
  52244. export enum PhysicsRadialImpulseFalloff {
  52245. /** Defines that impulse is constant in strength across it's whole radius */
  52246. Constant = 0,
  52247. /** DEfines that impulse gets weaker if it's further from the origin */
  52248. Linear = 1
  52249. }
  52250. /**
  52251. * The strength of the force in correspondence to the distance of the affected object
  52252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52253. */
  52254. export enum PhysicsUpdraftMode {
  52255. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52256. Center = 0,
  52257. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52258. Perpendicular = 1
  52259. }
  52260. /**
  52261. * Interface for a physics force and contact point
  52262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52263. */
  52264. export interface PhysicsForceAndContactPoint {
  52265. /**
  52266. * The force applied at the contact point
  52267. */
  52268. force: Vector3;
  52269. /**
  52270. * The contact point
  52271. */
  52272. contactPoint: Vector3;
  52273. }
  52274. /**
  52275. * Interface for radial explosion event data
  52276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52277. */
  52278. export interface PhysicsRadialExplosionEventData {
  52279. /**
  52280. * A sphere used for the radial explosion event
  52281. */
  52282. sphere: Mesh;
  52283. /**
  52284. * An array of rays for the radial explosion event
  52285. */
  52286. rays: Array<Ray>;
  52287. }
  52288. /**
  52289. * Interface for gravitational field event data
  52290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52291. */
  52292. export interface PhysicsGravitationalFieldEventData {
  52293. /**
  52294. * A sphere mesh used for the gravitational field event
  52295. */
  52296. sphere: Mesh;
  52297. }
  52298. /**
  52299. * Interface for updraft event data
  52300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52301. */
  52302. export interface PhysicsUpdraftEventData {
  52303. /**
  52304. * A cylinder used for the updraft event
  52305. */
  52306. cylinder: Mesh;
  52307. }
  52308. /**
  52309. * Interface for vortex event data
  52310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52311. */
  52312. export interface PhysicsVortexEventData {
  52313. /**
  52314. * A cylinder used for the vortex event
  52315. */
  52316. cylinder: Mesh;
  52317. }
  52318. }
  52319. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52320. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52321. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52322. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52323. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52324. import { Nullable } from "babylonjs/types";
  52325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52326. /**
  52327. * AmmoJS Physics plugin
  52328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52329. * @see https://github.com/kripken/ammo.js/
  52330. */
  52331. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52332. private _useDeltaForWorldStep;
  52333. /**
  52334. * Reference to the Ammo library
  52335. */
  52336. bjsAMMO: any;
  52337. /**
  52338. * Created ammoJS world which physics bodies are added to
  52339. */
  52340. world: any;
  52341. /**
  52342. * Name of the plugin
  52343. */
  52344. name: string;
  52345. private _timeStep;
  52346. private _fixedTimeStep;
  52347. private _maxSteps;
  52348. private _tmpQuaternion;
  52349. private _tmpAmmoTransform;
  52350. private _tmpAmmoQuaternion;
  52351. private _tmpAmmoConcreteContactResultCallback;
  52352. private _collisionConfiguration;
  52353. private _dispatcher;
  52354. private _overlappingPairCache;
  52355. private _solver;
  52356. private _tmpAmmoVectorA;
  52357. private _tmpAmmoVectorB;
  52358. private _tmpAmmoVectorC;
  52359. private _tmpContactCallbackResult;
  52360. private static readonly DISABLE_COLLISION_FLAG;
  52361. private static readonly KINEMATIC_FLAG;
  52362. private static readonly DISABLE_DEACTIVATION_FLAG;
  52363. /**
  52364. * Initializes the ammoJS plugin
  52365. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52366. * @param ammoInjection can be used to inject your own ammo reference
  52367. */
  52368. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52369. /**
  52370. * Sets the gravity of the physics world (m/(s^2))
  52371. * @param gravity Gravity to set
  52372. */
  52373. setGravity(gravity: Vector3): void;
  52374. /**
  52375. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52376. * @param timeStep timestep to use in seconds
  52377. */
  52378. setTimeStep(timeStep: number): void;
  52379. /**
  52380. * 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)
  52381. * @param fixedTimeStep fixedTimeStep to use in seconds
  52382. */
  52383. setFixedTimeStep(fixedTimeStep: number): void;
  52384. /**
  52385. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52386. * @param maxSteps the maximum number of steps by the physics engine per frame
  52387. */
  52388. setMaxSteps(maxSteps: number): void;
  52389. /**
  52390. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52391. * @returns the current timestep in seconds
  52392. */
  52393. getTimeStep(): number;
  52394. private _isImpostorInContact;
  52395. private _isImpostorPairInContact;
  52396. private _stepSimulation;
  52397. /**
  52398. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52399. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52400. * After the step the babylon meshes are set to the position of the physics imposters
  52401. * @param delta amount of time to step forward
  52402. * @param impostors array of imposters to update before/after the step
  52403. */
  52404. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52405. private _tmpVector;
  52406. private _tmpMatrix;
  52407. /**
  52408. * Applies an implulse on the imposter
  52409. * @param impostor imposter to apply impulse
  52410. * @param force amount of force to be applied to the imposter
  52411. * @param contactPoint the location to apply the impulse on the imposter
  52412. */
  52413. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52414. /**
  52415. * Applies a force on the imposter
  52416. * @param impostor imposter to apply force
  52417. * @param force amount of force to be applied to the imposter
  52418. * @param contactPoint the location to apply the force on the imposter
  52419. */
  52420. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52421. /**
  52422. * Creates a physics body using the plugin
  52423. * @param impostor the imposter to create the physics body on
  52424. */
  52425. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52426. /**
  52427. * Removes the physics body from the imposter and disposes of the body's memory
  52428. * @param impostor imposter to remove the physics body from
  52429. */
  52430. removePhysicsBody(impostor: PhysicsImpostor): void;
  52431. /**
  52432. * Generates a joint
  52433. * @param impostorJoint the imposter joint to create the joint with
  52434. */
  52435. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52436. /**
  52437. * Removes a joint
  52438. * @param impostorJoint the imposter joint to remove the joint from
  52439. */
  52440. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52441. private _addMeshVerts;
  52442. private _createShape;
  52443. /**
  52444. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52445. * @param impostor imposter containing the physics body and babylon object
  52446. */
  52447. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52448. /**
  52449. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52450. * @param impostor imposter containing the physics body and babylon object
  52451. * @param newPosition new position
  52452. * @param newRotation new rotation
  52453. */
  52454. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52455. /**
  52456. * If this plugin is supported
  52457. * @returns true if its supported
  52458. */
  52459. isSupported(): boolean;
  52460. /**
  52461. * Sets the linear velocity of the physics body
  52462. * @param impostor imposter to set the velocity on
  52463. * @param velocity velocity to set
  52464. */
  52465. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52466. /**
  52467. * Sets the angular velocity of the physics body
  52468. * @param impostor imposter to set the velocity on
  52469. * @param velocity velocity to set
  52470. */
  52471. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52472. /**
  52473. * gets the linear velocity
  52474. * @param impostor imposter to get linear velocity from
  52475. * @returns linear velocity
  52476. */
  52477. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52478. /**
  52479. * gets the angular velocity
  52480. * @param impostor imposter to get angular velocity from
  52481. * @returns angular velocity
  52482. */
  52483. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52484. /**
  52485. * Sets the mass of physics body
  52486. * @param impostor imposter to set the mass on
  52487. * @param mass mass to set
  52488. */
  52489. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52490. /**
  52491. * Gets the mass of the physics body
  52492. * @param impostor imposter to get the mass from
  52493. * @returns mass
  52494. */
  52495. getBodyMass(impostor: PhysicsImpostor): number;
  52496. /**
  52497. * Gets friction of the impostor
  52498. * @param impostor impostor to get friction from
  52499. * @returns friction value
  52500. */
  52501. getBodyFriction(impostor: PhysicsImpostor): number;
  52502. /**
  52503. * Sets friction of the impostor
  52504. * @param impostor impostor to set friction on
  52505. * @param friction friction value
  52506. */
  52507. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52508. /**
  52509. * Gets restitution of the impostor
  52510. * @param impostor impostor to get restitution from
  52511. * @returns restitution value
  52512. */
  52513. getBodyRestitution(impostor: PhysicsImpostor): number;
  52514. /**
  52515. * Sets resitution of the impostor
  52516. * @param impostor impostor to set resitution on
  52517. * @param restitution resitution value
  52518. */
  52519. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52520. /**
  52521. * Sleeps the physics body and stops it from being active
  52522. * @param impostor impostor to sleep
  52523. */
  52524. sleepBody(impostor: PhysicsImpostor): void;
  52525. /**
  52526. * Activates the physics body
  52527. * @param impostor impostor to activate
  52528. */
  52529. wakeUpBody(impostor: PhysicsImpostor): void;
  52530. /**
  52531. * Updates the distance parameters of the joint
  52532. * @param joint joint to update
  52533. * @param maxDistance maximum distance of the joint
  52534. * @param minDistance minimum distance of the joint
  52535. */
  52536. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52537. /**
  52538. * Sets a motor on the joint
  52539. * @param joint joint to set motor on
  52540. * @param speed speed of the motor
  52541. * @param maxForce maximum force of the motor
  52542. * @param motorIndex index of the motor
  52543. */
  52544. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52545. /**
  52546. * Sets the motors limit
  52547. * @param joint joint to set limit on
  52548. * @param upperLimit upper limit
  52549. * @param lowerLimit lower limit
  52550. */
  52551. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52552. /**
  52553. * Syncs the position and rotation of a mesh with the impostor
  52554. * @param mesh mesh to sync
  52555. * @param impostor impostor to update the mesh with
  52556. */
  52557. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52558. /**
  52559. * Gets the radius of the impostor
  52560. * @param impostor impostor to get radius from
  52561. * @returns the radius
  52562. */
  52563. getRadius(impostor: PhysicsImpostor): number;
  52564. /**
  52565. * Gets the box size of the impostor
  52566. * @param impostor impostor to get box size from
  52567. * @param result the resulting box size
  52568. */
  52569. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52570. /**
  52571. * Disposes of the impostor
  52572. */
  52573. dispose(): void;
  52574. }
  52575. }
  52576. declare module "babylonjs/Physics/Plugins/index" {
  52577. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52578. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52579. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52580. }
  52581. declare module "babylonjs/Physics/index" {
  52582. export * from "babylonjs/Physics/IPhysicsEngine";
  52583. export * from "babylonjs/Physics/physicsEngine";
  52584. export * from "babylonjs/Physics/physicsEngineComponent";
  52585. export * from "babylonjs/Physics/physicsHelper";
  52586. export * from "babylonjs/Physics/physicsImpostor";
  52587. export * from "babylonjs/Physics/physicsJoint";
  52588. export * from "babylonjs/Physics/Plugins/index";
  52589. }
  52590. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52591. /** @hidden */
  52592. export var blackAndWhitePixelShader: {
  52593. name: string;
  52594. shader: string;
  52595. };
  52596. }
  52597. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52598. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52599. import { Camera } from "babylonjs/Cameras/camera";
  52600. import { Engine } from "babylonjs/Engines/engine";
  52601. import "babylonjs/Shaders/blackAndWhite.fragment";
  52602. /**
  52603. * Post process used to render in black and white
  52604. */
  52605. export class BlackAndWhitePostProcess extends PostProcess {
  52606. /**
  52607. * Linear about to convert he result to black and white (default: 1)
  52608. */
  52609. degree: number;
  52610. /**
  52611. * Creates a black and white post process
  52612. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52613. * @param name The name of the effect.
  52614. * @param options The required width/height ratio to downsize to before computing the render pass.
  52615. * @param camera The camera to apply the render pass to.
  52616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52617. * @param engine The engine which the post process will be applied. (default: current engine)
  52618. * @param reusable If the post process can be reused on the same frame. (default: false)
  52619. */
  52620. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52621. }
  52622. }
  52623. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52624. import { Nullable } from "babylonjs/types";
  52625. import { Camera } from "babylonjs/Cameras/camera";
  52626. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52627. import { Engine } from "babylonjs/Engines/engine";
  52628. /**
  52629. * This represents a set of one or more post processes in Babylon.
  52630. * A post process can be used to apply a shader to a texture after it is rendered.
  52631. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52632. */
  52633. export class PostProcessRenderEffect {
  52634. private _postProcesses;
  52635. private _getPostProcesses;
  52636. private _singleInstance;
  52637. private _cameras;
  52638. private _indicesForCamera;
  52639. /**
  52640. * Name of the effect
  52641. * @hidden
  52642. */
  52643. _name: string;
  52644. /**
  52645. * Instantiates a post process render effect.
  52646. * A post process can be used to apply a shader to a texture after it is rendered.
  52647. * @param engine The engine the effect is tied to
  52648. * @param name The name of the effect
  52649. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52650. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52651. */
  52652. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52653. /**
  52654. * Checks if all the post processes in the effect are supported.
  52655. */
  52656. readonly isSupported: boolean;
  52657. /**
  52658. * Updates the current state of the effect
  52659. * @hidden
  52660. */
  52661. _update(): void;
  52662. /**
  52663. * Attaches the effect on cameras
  52664. * @param cameras The camera to attach to.
  52665. * @hidden
  52666. */
  52667. _attachCameras(cameras: Camera): void;
  52668. /**
  52669. * Attaches the effect on cameras
  52670. * @param cameras The camera to attach to.
  52671. * @hidden
  52672. */
  52673. _attachCameras(cameras: Camera[]): void;
  52674. /**
  52675. * Detatches the effect on cameras
  52676. * @param cameras The camera to detatch from.
  52677. * @hidden
  52678. */
  52679. _detachCameras(cameras: Camera): void;
  52680. /**
  52681. * Detatches the effect on cameras
  52682. * @param cameras The camera to detatch from.
  52683. * @hidden
  52684. */
  52685. _detachCameras(cameras: Camera[]): void;
  52686. /**
  52687. * Enables the effect on given cameras
  52688. * @param cameras The camera to enable.
  52689. * @hidden
  52690. */
  52691. _enable(cameras: Camera): void;
  52692. /**
  52693. * Enables the effect on given cameras
  52694. * @param cameras The camera to enable.
  52695. * @hidden
  52696. */
  52697. _enable(cameras: Nullable<Camera[]>): void;
  52698. /**
  52699. * Disables the effect on the given cameras
  52700. * @param cameras The camera to disable.
  52701. * @hidden
  52702. */
  52703. _disable(cameras: Camera): void;
  52704. /**
  52705. * Disables the effect on the given cameras
  52706. * @param cameras The camera to disable.
  52707. * @hidden
  52708. */
  52709. _disable(cameras: Nullable<Camera[]>): void;
  52710. /**
  52711. * Gets a list of the post processes contained in the effect.
  52712. * @param camera The camera to get the post processes on.
  52713. * @returns The list of the post processes in the effect.
  52714. */
  52715. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52716. }
  52717. }
  52718. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52719. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52720. /** @hidden */
  52721. export var extractHighlightsPixelShader: {
  52722. name: string;
  52723. shader: string;
  52724. };
  52725. }
  52726. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52727. import { Nullable } from "babylonjs/types";
  52728. import { Camera } from "babylonjs/Cameras/camera";
  52729. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52730. import { Engine } from "babylonjs/Engines/engine";
  52731. import "babylonjs/Shaders/extractHighlights.fragment";
  52732. /**
  52733. * 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.
  52734. */
  52735. export class ExtractHighlightsPostProcess extends PostProcess {
  52736. /**
  52737. * The luminance threshold, pixels below this value will be set to black.
  52738. */
  52739. threshold: number;
  52740. /** @hidden */
  52741. _exposure: number;
  52742. /**
  52743. * Post process which has the input texture to be used when performing highlight extraction
  52744. * @hidden
  52745. */
  52746. _inputPostProcess: Nullable<PostProcess>;
  52747. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52748. }
  52749. }
  52750. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52751. /** @hidden */
  52752. export var bloomMergePixelShader: {
  52753. name: string;
  52754. shader: string;
  52755. };
  52756. }
  52757. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52758. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52759. import { Nullable } from "babylonjs/types";
  52760. import { Engine } from "babylonjs/Engines/engine";
  52761. import { Camera } from "babylonjs/Cameras/camera";
  52762. import "babylonjs/Shaders/bloomMerge.fragment";
  52763. /**
  52764. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52765. */
  52766. export class BloomMergePostProcess extends PostProcess {
  52767. /** Weight of the bloom to be added to the original input. */
  52768. weight: number;
  52769. /**
  52770. * Creates a new instance of @see BloomMergePostProcess
  52771. * @param name The name of the effect.
  52772. * @param originalFromInput Post process which's input will be used for the merge.
  52773. * @param blurred Blurred highlights post process which's output will be used.
  52774. * @param weight Weight of the bloom to be added to the original input.
  52775. * @param options The required width/height ratio to downsize to before computing the render pass.
  52776. * @param camera The camera to apply the render pass to.
  52777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52778. * @param engine The engine which the post process will be applied. (default: current engine)
  52779. * @param reusable If the post process can be reused on the same frame. (default: false)
  52780. * @param textureType Type of textures used when performing the post process. (default: 0)
  52781. * @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)
  52782. */
  52783. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52784. /** Weight of the bloom to be added to the original input. */
  52785. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52786. }
  52787. }
  52788. declare module "babylonjs/PostProcesses/bloomEffect" {
  52789. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52790. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52791. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52792. import { Camera } from "babylonjs/Cameras/camera";
  52793. import { Scene } from "babylonjs/scene";
  52794. /**
  52795. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52796. */
  52797. export class BloomEffect extends PostProcessRenderEffect {
  52798. private bloomScale;
  52799. /**
  52800. * @hidden Internal
  52801. */
  52802. _effects: Array<PostProcess>;
  52803. /**
  52804. * @hidden Internal
  52805. */
  52806. _downscale: ExtractHighlightsPostProcess;
  52807. private _blurX;
  52808. private _blurY;
  52809. private _merge;
  52810. /**
  52811. * The luminance threshold to find bright areas of the image to bloom.
  52812. */
  52813. threshold: number;
  52814. /**
  52815. * The strength of the bloom.
  52816. */
  52817. weight: number;
  52818. /**
  52819. * Specifies the size of the bloom blur kernel, relative to the final output size
  52820. */
  52821. kernel: number;
  52822. /**
  52823. * Creates a new instance of @see BloomEffect
  52824. * @param scene The scene the effect belongs to.
  52825. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52826. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52827. * @param bloomWeight The the strength of bloom.
  52828. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52829. * @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)
  52830. */
  52831. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52832. /**
  52833. * Disposes each of the internal effects for a given camera.
  52834. * @param camera The camera to dispose the effect on.
  52835. */
  52836. disposeEffects(camera: Camera): void;
  52837. /**
  52838. * @hidden Internal
  52839. */
  52840. _updateEffects(): void;
  52841. /**
  52842. * Internal
  52843. * @returns if all the contained post processes are ready.
  52844. * @hidden
  52845. */
  52846. _isReady(): boolean;
  52847. }
  52848. }
  52849. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52850. /** @hidden */
  52851. export var chromaticAberrationPixelShader: {
  52852. name: string;
  52853. shader: string;
  52854. };
  52855. }
  52856. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52857. import { Vector2 } from "babylonjs/Maths/math";
  52858. import { Nullable } from "babylonjs/types";
  52859. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52860. import { Camera } from "babylonjs/Cameras/camera";
  52861. import { Engine } from "babylonjs/Engines/engine";
  52862. import "babylonjs/Shaders/chromaticAberration.fragment";
  52863. /**
  52864. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52865. */
  52866. export class ChromaticAberrationPostProcess extends PostProcess {
  52867. /**
  52868. * The amount of seperation of rgb channels (default: 30)
  52869. */
  52870. aberrationAmount: number;
  52871. /**
  52872. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52873. */
  52874. radialIntensity: number;
  52875. /**
  52876. * 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))
  52877. */
  52878. direction: Vector2;
  52879. /**
  52880. * 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))
  52881. */
  52882. centerPosition: Vector2;
  52883. /**
  52884. * Creates a new instance ChromaticAberrationPostProcess
  52885. * @param name The name of the effect.
  52886. * @param screenWidth The width of the screen to apply the effect on.
  52887. * @param screenHeight The height of the screen to apply the effect on.
  52888. * @param options The required width/height ratio to downsize to before computing the render pass.
  52889. * @param camera The camera to apply the render pass to.
  52890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52891. * @param engine The engine which the post process will be applied. (default: current engine)
  52892. * @param reusable If the post process can be reused on the same frame. (default: false)
  52893. * @param textureType Type of textures used when performing the post process. (default: 0)
  52894. * @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)
  52895. */
  52896. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52897. }
  52898. }
  52899. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52900. /** @hidden */
  52901. export var circleOfConfusionPixelShader: {
  52902. name: string;
  52903. shader: string;
  52904. };
  52905. }
  52906. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52907. import { Nullable } from "babylonjs/types";
  52908. import { Engine } from "babylonjs/Engines/engine";
  52909. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52910. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52911. import { Camera } from "babylonjs/Cameras/camera";
  52912. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52913. /**
  52914. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52915. */
  52916. export class CircleOfConfusionPostProcess extends PostProcess {
  52917. /**
  52918. * 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.
  52919. */
  52920. lensSize: number;
  52921. /**
  52922. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52923. */
  52924. fStop: number;
  52925. /**
  52926. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52927. */
  52928. focusDistance: number;
  52929. /**
  52930. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52931. */
  52932. focalLength: number;
  52933. private _depthTexture;
  52934. /**
  52935. * Creates a new instance CircleOfConfusionPostProcess
  52936. * @param name The name of the effect.
  52937. * @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.
  52938. * @param options The required width/height ratio to downsize to before computing the render pass.
  52939. * @param camera The camera to apply the render pass to.
  52940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52941. * @param engine The engine which the post process will be applied. (default: current engine)
  52942. * @param reusable If the post process can be reused on the same frame. (default: false)
  52943. * @param textureType Type of textures used when performing the post process. (default: 0)
  52944. * @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)
  52945. */
  52946. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52947. /**
  52948. * 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.
  52949. */
  52950. depthTexture: RenderTargetTexture;
  52951. }
  52952. }
  52953. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52954. /** @hidden */
  52955. export var colorCorrectionPixelShader: {
  52956. name: string;
  52957. shader: string;
  52958. };
  52959. }
  52960. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52961. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52962. import { Engine } from "babylonjs/Engines/engine";
  52963. import { Camera } from "babylonjs/Cameras/camera";
  52964. import "babylonjs/Shaders/colorCorrection.fragment";
  52965. /**
  52966. *
  52967. * This post-process allows the modification of rendered colors by using
  52968. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52969. *
  52970. * The object needs to be provided an url to a texture containing the color
  52971. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52972. * Use an image editing software to tweak the LUT to match your needs.
  52973. *
  52974. * For an example of a color LUT, see here:
  52975. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52976. * For explanations on color grading, see here:
  52977. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52978. *
  52979. */
  52980. export class ColorCorrectionPostProcess extends PostProcess {
  52981. private _colorTableTexture;
  52982. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52983. }
  52984. }
  52985. declare module "babylonjs/Shaders/convolution.fragment" {
  52986. /** @hidden */
  52987. export var convolutionPixelShader: {
  52988. name: string;
  52989. shader: string;
  52990. };
  52991. }
  52992. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52993. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52994. import { Nullable } from "babylonjs/types";
  52995. import { Camera } from "babylonjs/Cameras/camera";
  52996. import { Engine } from "babylonjs/Engines/engine";
  52997. import "babylonjs/Shaders/convolution.fragment";
  52998. /**
  52999. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53000. * input texture to perform effects such as edge detection or sharpening
  53001. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53002. */
  53003. export class ConvolutionPostProcess extends PostProcess {
  53004. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53005. kernel: number[];
  53006. /**
  53007. * Creates a new instance ConvolutionPostProcess
  53008. * @param name The name of the effect.
  53009. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53010. * @param options The required width/height ratio to downsize to before computing the render pass.
  53011. * @param camera The camera to apply the render pass to.
  53012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53013. * @param engine The engine which the post process will be applied. (default: current engine)
  53014. * @param reusable If the post process can be reused on the same frame. (default: false)
  53015. * @param textureType Type of textures used when performing the post process. (default: 0)
  53016. */
  53017. constructor(name: string,
  53018. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53019. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53020. /**
  53021. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53022. */
  53023. static EdgeDetect0Kernel: number[];
  53024. /**
  53025. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53026. */
  53027. static EdgeDetect1Kernel: number[];
  53028. /**
  53029. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53030. */
  53031. static EdgeDetect2Kernel: number[];
  53032. /**
  53033. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53034. */
  53035. static SharpenKernel: number[];
  53036. /**
  53037. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53038. */
  53039. static EmbossKernel: number[];
  53040. /**
  53041. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53042. */
  53043. static GaussianKernel: number[];
  53044. }
  53045. }
  53046. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53047. import { Nullable } from "babylonjs/types";
  53048. import { Vector2 } from "babylonjs/Maths/math";
  53049. import { Camera } from "babylonjs/Cameras/camera";
  53050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53051. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53052. import { Engine } from "babylonjs/Engines/engine";
  53053. import { Scene } from "babylonjs/scene";
  53054. /**
  53055. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53056. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53057. * based on samples that have a large difference in distance than the center pixel.
  53058. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53059. */
  53060. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53061. direction: Vector2;
  53062. /**
  53063. * Creates a new instance CircleOfConfusionPostProcess
  53064. * @param name The name of the effect.
  53065. * @param scene The scene the effect belongs to.
  53066. * @param direction The direction the blur should be applied.
  53067. * @param kernel The size of the kernel used to blur.
  53068. * @param options The required width/height ratio to downsize to before computing the render pass.
  53069. * @param camera The camera to apply the render pass to.
  53070. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53071. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53073. * @param engine The engine which the post process will be applied. (default: current engine)
  53074. * @param reusable If the post process can be reused on the same frame. (default: false)
  53075. * @param textureType Type of textures used when performing the post process. (default: 0)
  53076. * @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)
  53077. */
  53078. 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);
  53079. }
  53080. }
  53081. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53082. /** @hidden */
  53083. export var depthOfFieldMergePixelShader: {
  53084. name: string;
  53085. shader: string;
  53086. };
  53087. }
  53088. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53089. import { Nullable } from "babylonjs/types";
  53090. import { Camera } from "babylonjs/Cameras/camera";
  53091. import { Effect } from "babylonjs/Materials/effect";
  53092. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53093. import { Engine } from "babylonjs/Engines/engine";
  53094. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53095. /**
  53096. * Options to be set when merging outputs from the default pipeline.
  53097. */
  53098. export class DepthOfFieldMergePostProcessOptions {
  53099. /**
  53100. * The original image to merge on top of
  53101. */
  53102. originalFromInput: PostProcess;
  53103. /**
  53104. * Parameters to perform the merge of the depth of field effect
  53105. */
  53106. depthOfField?: {
  53107. circleOfConfusion: PostProcess;
  53108. blurSteps: Array<PostProcess>;
  53109. };
  53110. /**
  53111. * Parameters to perform the merge of bloom effect
  53112. */
  53113. bloom?: {
  53114. blurred: PostProcess;
  53115. weight: number;
  53116. };
  53117. }
  53118. /**
  53119. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53120. */
  53121. export class DepthOfFieldMergePostProcess extends PostProcess {
  53122. private blurSteps;
  53123. /**
  53124. * Creates a new instance of DepthOfFieldMergePostProcess
  53125. * @param name The name of the effect.
  53126. * @param originalFromInput Post process which's input will be used for the merge.
  53127. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53128. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53129. * @param options The required width/height ratio to downsize to before computing the render pass.
  53130. * @param camera The camera to apply the render pass to.
  53131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53132. * @param engine The engine which the post process will be applied. (default: current engine)
  53133. * @param reusable If the post process can be reused on the same frame. (default: false)
  53134. * @param textureType Type of textures used when performing the post process. (default: 0)
  53135. * @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)
  53136. */
  53137. 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);
  53138. /**
  53139. * Updates the effect with the current post process compile time values and recompiles the shader.
  53140. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53141. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53142. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53143. * @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
  53144. * @param onCompiled Called when the shader has been compiled.
  53145. * @param onError Called if there is an error when compiling a shader.
  53146. */
  53147. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53148. }
  53149. }
  53150. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53151. import { Nullable } from "babylonjs/types";
  53152. import { Camera } from "babylonjs/Cameras/camera";
  53153. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53154. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53155. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53156. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53157. import { Scene } from "babylonjs/scene";
  53158. /**
  53159. * Specifies the level of max blur that should be applied when using the depth of field effect
  53160. */
  53161. export enum DepthOfFieldEffectBlurLevel {
  53162. /**
  53163. * Subtle blur
  53164. */
  53165. Low = 0,
  53166. /**
  53167. * Medium blur
  53168. */
  53169. Medium = 1,
  53170. /**
  53171. * Large blur
  53172. */
  53173. High = 2
  53174. }
  53175. /**
  53176. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53177. */
  53178. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53179. private _circleOfConfusion;
  53180. /**
  53181. * @hidden Internal, blurs from high to low
  53182. */
  53183. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53184. private _depthOfFieldBlurY;
  53185. private _dofMerge;
  53186. /**
  53187. * @hidden Internal post processes in depth of field effect
  53188. */
  53189. _effects: Array<PostProcess>;
  53190. /**
  53191. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53192. */
  53193. focalLength: number;
  53194. /**
  53195. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53196. */
  53197. fStop: number;
  53198. /**
  53199. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53200. */
  53201. focusDistance: number;
  53202. /**
  53203. * 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.
  53204. */
  53205. lensSize: number;
  53206. /**
  53207. * Creates a new instance DepthOfFieldEffect
  53208. * @param scene The scene the effect belongs to.
  53209. * @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.
  53210. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53211. * @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)
  53212. */
  53213. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53214. /**
  53215. * 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.
  53216. */
  53217. depthTexture: RenderTargetTexture;
  53218. /**
  53219. * Disposes each of the internal effects for a given camera.
  53220. * @param camera The camera to dispose the effect on.
  53221. */
  53222. disposeEffects(camera: Camera): void;
  53223. /**
  53224. * @hidden Internal
  53225. */
  53226. _updateEffects(): void;
  53227. /**
  53228. * Internal
  53229. * @returns if all the contained post processes are ready.
  53230. * @hidden
  53231. */
  53232. _isReady(): boolean;
  53233. }
  53234. }
  53235. declare module "babylonjs/Shaders/displayPass.fragment" {
  53236. /** @hidden */
  53237. export var displayPassPixelShader: {
  53238. name: string;
  53239. shader: string;
  53240. };
  53241. }
  53242. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53243. import { Nullable } from "babylonjs/types";
  53244. import { Camera } from "babylonjs/Cameras/camera";
  53245. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53246. import { Engine } from "babylonjs/Engines/engine";
  53247. import "babylonjs/Shaders/displayPass.fragment";
  53248. /**
  53249. * DisplayPassPostProcess which produces an output the same as it's input
  53250. */
  53251. export class DisplayPassPostProcess extends PostProcess {
  53252. /**
  53253. * Creates the DisplayPassPostProcess
  53254. * @param name The name of the effect.
  53255. * @param options The required width/height ratio to downsize to before computing the render pass.
  53256. * @param camera The camera to apply the render pass to.
  53257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53258. * @param engine The engine which the post process will be applied. (default: current engine)
  53259. * @param reusable If the post process can be reused on the same frame. (default: false)
  53260. */
  53261. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53262. }
  53263. }
  53264. declare module "babylonjs/Shaders/filter.fragment" {
  53265. /** @hidden */
  53266. export var filterPixelShader: {
  53267. name: string;
  53268. shader: string;
  53269. };
  53270. }
  53271. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53272. import { Nullable } from "babylonjs/types";
  53273. import { Matrix } from "babylonjs/Maths/math";
  53274. import { Camera } from "babylonjs/Cameras/camera";
  53275. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53276. import { Engine } from "babylonjs/Engines/engine";
  53277. import "babylonjs/Shaders/filter.fragment";
  53278. /**
  53279. * Applies a kernel filter to the image
  53280. */
  53281. export class FilterPostProcess extends PostProcess {
  53282. /** The matrix to be applied to the image */
  53283. kernelMatrix: Matrix;
  53284. /**
  53285. *
  53286. * @param name The name of the effect.
  53287. * @param kernelMatrix The matrix to be applied to the image
  53288. * @param options The required width/height ratio to downsize to before computing the render pass.
  53289. * @param camera The camera to apply the render pass to.
  53290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53291. * @param engine The engine which the post process will be applied. (default: current engine)
  53292. * @param reusable If the post process can be reused on the same frame. (default: false)
  53293. */
  53294. constructor(name: string,
  53295. /** The matrix to be applied to the image */
  53296. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53297. }
  53298. }
  53299. declare module "babylonjs/Shaders/fxaa.fragment" {
  53300. /** @hidden */
  53301. export var fxaaPixelShader: {
  53302. name: string;
  53303. shader: string;
  53304. };
  53305. }
  53306. declare module "babylonjs/Shaders/fxaa.vertex" {
  53307. /** @hidden */
  53308. export var fxaaVertexShader: {
  53309. name: string;
  53310. shader: string;
  53311. };
  53312. }
  53313. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53314. import { Nullable } from "babylonjs/types";
  53315. import { Camera } from "babylonjs/Cameras/camera";
  53316. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53317. import { Engine } from "babylonjs/Engines/engine";
  53318. import "babylonjs/Shaders/fxaa.fragment";
  53319. import "babylonjs/Shaders/fxaa.vertex";
  53320. /**
  53321. * Fxaa post process
  53322. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53323. */
  53324. export class FxaaPostProcess extends PostProcess {
  53325. /** @hidden */
  53326. texelWidth: number;
  53327. /** @hidden */
  53328. texelHeight: number;
  53329. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53330. private _getDefines;
  53331. }
  53332. }
  53333. declare module "babylonjs/Shaders/grain.fragment" {
  53334. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53335. /** @hidden */
  53336. export var grainPixelShader: {
  53337. name: string;
  53338. shader: string;
  53339. };
  53340. }
  53341. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53342. import { Nullable } from "babylonjs/types";
  53343. import { Camera } from "babylonjs/Cameras/camera";
  53344. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53345. import { Engine } from "babylonjs/Engines/engine";
  53346. import "babylonjs/Shaders/grain.fragment";
  53347. /**
  53348. * The GrainPostProcess adds noise to the image at mid luminance levels
  53349. */
  53350. export class GrainPostProcess extends PostProcess {
  53351. /**
  53352. * The intensity of the grain added (default: 30)
  53353. */
  53354. intensity: number;
  53355. /**
  53356. * If the grain should be randomized on every frame
  53357. */
  53358. animated: boolean;
  53359. /**
  53360. * Creates a new instance of @see GrainPostProcess
  53361. * @param name The name of the effect.
  53362. * @param options The required width/height ratio to downsize to before computing the render pass.
  53363. * @param camera The camera to apply the render pass to.
  53364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53365. * @param engine The engine which the post process will be applied. (default: current engine)
  53366. * @param reusable If the post process can be reused on the same frame. (default: false)
  53367. * @param textureType Type of textures used when performing the post process. (default: 0)
  53368. * @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)
  53369. */
  53370. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53371. }
  53372. }
  53373. declare module "babylonjs/Shaders/highlights.fragment" {
  53374. /** @hidden */
  53375. export var highlightsPixelShader: {
  53376. name: string;
  53377. shader: string;
  53378. };
  53379. }
  53380. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53381. import { Nullable } from "babylonjs/types";
  53382. import { Camera } from "babylonjs/Cameras/camera";
  53383. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53384. import { Engine } from "babylonjs/Engines/engine";
  53385. import "babylonjs/Shaders/highlights.fragment";
  53386. /**
  53387. * Extracts highlights from the image
  53388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53389. */
  53390. export class HighlightsPostProcess extends PostProcess {
  53391. /**
  53392. * Extracts highlights from the image
  53393. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53394. * @param name The name of the effect.
  53395. * @param options The required width/height ratio to downsize to before computing the render pass.
  53396. * @param camera The camera to apply the render pass to.
  53397. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53398. * @param engine The engine which the post process will be applied. (default: current engine)
  53399. * @param reusable If the post process can be reused on the same frame. (default: false)
  53400. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53401. */
  53402. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53403. }
  53404. }
  53405. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53406. /** @hidden */
  53407. export var mrtFragmentDeclaration: {
  53408. name: string;
  53409. shader: string;
  53410. };
  53411. }
  53412. declare module "babylonjs/Shaders/geometry.fragment" {
  53413. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53414. /** @hidden */
  53415. export var geometryPixelShader: {
  53416. name: string;
  53417. shader: string;
  53418. };
  53419. }
  53420. declare module "babylonjs/Shaders/geometry.vertex" {
  53421. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53422. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53423. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53424. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53425. /** @hidden */
  53426. export var geometryVertexShader: {
  53427. name: string;
  53428. shader: string;
  53429. };
  53430. }
  53431. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53432. import { Matrix } from "babylonjs/Maths/math";
  53433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53434. import { Mesh } from "babylonjs/Meshes/mesh";
  53435. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53436. import { Effect } from "babylonjs/Materials/effect";
  53437. import { Scene } from "babylonjs/scene";
  53438. import "babylonjs/Shaders/geometry.fragment";
  53439. import "babylonjs/Shaders/geometry.vertex";
  53440. /**
  53441. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53442. */
  53443. export class GeometryBufferRenderer {
  53444. /**
  53445. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53446. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53447. */
  53448. static readonly POSITION_TEXTURE_TYPE: number;
  53449. /**
  53450. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53451. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53452. */
  53453. static readonly VELOCITY_TEXTURE_TYPE: number;
  53454. /**
  53455. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53456. * in order to compute objects velocities when enableVelocity is set to "true"
  53457. * @hidden
  53458. */
  53459. _previousTransformationMatrices: {
  53460. [index: number]: Matrix;
  53461. };
  53462. private _scene;
  53463. private _multiRenderTarget;
  53464. private _ratio;
  53465. private _enablePosition;
  53466. private _enableVelocity;
  53467. private _positionIndex;
  53468. private _velocityIndex;
  53469. protected _effect: Effect;
  53470. protected _cachedDefines: string;
  53471. /**
  53472. * Set the render list (meshes to be rendered) used in the G buffer.
  53473. */
  53474. renderList: Mesh[];
  53475. /**
  53476. * Gets wether or not G buffer are supported by the running hardware.
  53477. * This requires draw buffer supports
  53478. */
  53479. readonly isSupported: boolean;
  53480. /**
  53481. * Returns the index of the given texture type in the G-Buffer textures array
  53482. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53483. * @returns the index of the given texture type in the G-Buffer textures array
  53484. */
  53485. getTextureIndex(textureType: number): number;
  53486. /**
  53487. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53488. */
  53489. /**
  53490. * Sets whether or not objects positions are enabled for the G buffer.
  53491. */
  53492. enablePosition: boolean;
  53493. /**
  53494. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53495. */
  53496. /**
  53497. * Sets wether or not objects velocities are enabled for the G buffer.
  53498. */
  53499. enableVelocity: boolean;
  53500. /**
  53501. * Gets the scene associated with the buffer.
  53502. */
  53503. readonly scene: Scene;
  53504. /**
  53505. * Gets the ratio used by the buffer during its creation.
  53506. * How big is the buffer related to the main canvas.
  53507. */
  53508. readonly ratio: number;
  53509. /** @hidden */
  53510. static _SceneComponentInitialization: (scene: Scene) => void;
  53511. /**
  53512. * Creates a new G Buffer for the scene
  53513. * @param scene The scene the buffer belongs to
  53514. * @param ratio How big is the buffer related to the main canvas.
  53515. */
  53516. constructor(scene: Scene, ratio?: number);
  53517. /**
  53518. * Checks wether everything is ready to render a submesh to the G buffer.
  53519. * @param subMesh the submesh to check readiness for
  53520. * @param useInstances is the mesh drawn using instance or not
  53521. * @returns true if ready otherwise false
  53522. */
  53523. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53524. /**
  53525. * Gets the current underlying G Buffer.
  53526. * @returns the buffer
  53527. */
  53528. getGBuffer(): MultiRenderTarget;
  53529. /**
  53530. * Gets the number of samples used to render the buffer (anti aliasing).
  53531. */
  53532. /**
  53533. * Sets the number of samples used to render the buffer (anti aliasing).
  53534. */
  53535. samples: number;
  53536. /**
  53537. * Disposes the renderer and frees up associated resources.
  53538. */
  53539. dispose(): void;
  53540. protected _createRenderTargets(): void;
  53541. }
  53542. }
  53543. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53544. import { Nullable } from "babylonjs/types";
  53545. import { Scene } from "babylonjs/scene";
  53546. import { ISceneComponent } from "babylonjs/sceneComponent";
  53547. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53548. module "babylonjs/scene" {
  53549. interface Scene {
  53550. /** @hidden (Backing field) */
  53551. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53552. /**
  53553. * Gets or Sets the current geometry buffer associated to the scene.
  53554. */
  53555. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53556. /**
  53557. * Enables a GeometryBufferRender and associates it with the scene
  53558. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53559. * @returns the GeometryBufferRenderer
  53560. */
  53561. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53562. /**
  53563. * Disables the GeometryBufferRender associated with the scene
  53564. */
  53565. disableGeometryBufferRenderer(): void;
  53566. }
  53567. }
  53568. /**
  53569. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53570. * in several rendering techniques.
  53571. */
  53572. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53573. /**
  53574. * The component name helpful to identify the component in the list of scene components.
  53575. */
  53576. readonly name: string;
  53577. /**
  53578. * The scene the component belongs to.
  53579. */
  53580. scene: Scene;
  53581. /**
  53582. * Creates a new instance of the component for the given scene
  53583. * @param scene Defines the scene to register the component in
  53584. */
  53585. constructor(scene: Scene);
  53586. /**
  53587. * Registers the component in a given scene
  53588. */
  53589. register(): void;
  53590. /**
  53591. * Rebuilds the elements related to this component in case of
  53592. * context lost for instance.
  53593. */
  53594. rebuild(): void;
  53595. /**
  53596. * Disposes the component and the associated ressources
  53597. */
  53598. dispose(): void;
  53599. private _gatherRenderTargets;
  53600. }
  53601. }
  53602. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53603. /** @hidden */
  53604. export var motionBlurPixelShader: {
  53605. name: string;
  53606. shader: string;
  53607. };
  53608. }
  53609. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53610. import { Nullable } from "babylonjs/types";
  53611. import { Camera } from "babylonjs/Cameras/camera";
  53612. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53613. import { Scene } from "babylonjs/scene";
  53614. import "babylonjs/Animations/animatable";
  53615. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53616. import "babylonjs/Shaders/motionBlur.fragment";
  53617. import { Engine } from "babylonjs/Engines/engine";
  53618. /**
  53619. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53620. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53621. * As an example, all you have to do is to create the post-process:
  53622. * var mb = new BABYLON.MotionBlurPostProcess(
  53623. * 'mb', // The name of the effect.
  53624. * scene, // The scene containing the objects to blur according to their velocity.
  53625. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53626. * camera // The camera to apply the render pass to.
  53627. * );
  53628. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53629. */
  53630. export class MotionBlurPostProcess extends PostProcess {
  53631. /**
  53632. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53633. */
  53634. motionStrength: number;
  53635. /**
  53636. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53637. */
  53638. /**
  53639. * Sets the number of iterations to be used for motion blur quality
  53640. */
  53641. motionBlurSamples: number;
  53642. private _motionBlurSamples;
  53643. private _geometryBufferRenderer;
  53644. /**
  53645. * Creates a new instance MotionBlurPostProcess
  53646. * @param name The name of the effect.
  53647. * @param scene The scene containing the objects to blur according to their velocity.
  53648. * @param options The required width/height ratio to downsize to before computing the render pass.
  53649. * @param camera The camera to apply the render pass to.
  53650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53651. * @param engine The engine which the post process will be applied. (default: current engine)
  53652. * @param reusable If the post process can be reused on the same frame. (default: false)
  53653. * @param textureType Type of textures used when performing the post process. (default: 0)
  53654. * @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)
  53655. */
  53656. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53657. /**
  53658. * Disposes the post process.
  53659. * @param camera The camera to dispose the post process on.
  53660. */
  53661. dispose(camera?: Camera): void;
  53662. }
  53663. }
  53664. declare module "babylonjs/Shaders/refraction.fragment" {
  53665. /** @hidden */
  53666. export var refractionPixelShader: {
  53667. name: string;
  53668. shader: string;
  53669. };
  53670. }
  53671. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53672. import { Color3 } from "babylonjs/Maths/math";
  53673. import { Camera } from "babylonjs/Cameras/camera";
  53674. import { Texture } from "babylonjs/Materials/Textures/texture";
  53675. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53676. import { Engine } from "babylonjs/Engines/engine";
  53677. import "babylonjs/Shaders/refraction.fragment";
  53678. /**
  53679. * Post process which applies a refractin texture
  53680. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53681. */
  53682. export class RefractionPostProcess extends PostProcess {
  53683. /** the base color of the refraction (used to taint the rendering) */
  53684. color: Color3;
  53685. /** simulated refraction depth */
  53686. depth: number;
  53687. /** the coefficient of the base color (0 to remove base color tainting) */
  53688. colorLevel: number;
  53689. private _refTexture;
  53690. private _ownRefractionTexture;
  53691. /**
  53692. * Gets or sets the refraction texture
  53693. * Please note that you are responsible for disposing the texture if you set it manually
  53694. */
  53695. refractionTexture: Texture;
  53696. /**
  53697. * Initializes the RefractionPostProcess
  53698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53699. * @param name The name of the effect.
  53700. * @param refractionTextureUrl Url of the refraction texture to use
  53701. * @param color the base color of the refraction (used to taint the rendering)
  53702. * @param depth simulated refraction depth
  53703. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53704. * @param camera The camera to apply the render pass to.
  53705. * @param options The required width/height ratio to downsize to before computing the render pass.
  53706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53707. * @param engine The engine which the post process will be applied. (default: current engine)
  53708. * @param reusable If the post process can be reused on the same frame. (default: false)
  53709. */
  53710. constructor(name: string, refractionTextureUrl: string,
  53711. /** the base color of the refraction (used to taint the rendering) */
  53712. color: Color3,
  53713. /** simulated refraction depth */
  53714. depth: number,
  53715. /** the coefficient of the base color (0 to remove base color tainting) */
  53716. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53717. /**
  53718. * Disposes of the post process
  53719. * @param camera Camera to dispose post process on
  53720. */
  53721. dispose(camera: Camera): void;
  53722. }
  53723. }
  53724. declare module "babylonjs/Shaders/sharpen.fragment" {
  53725. /** @hidden */
  53726. export var sharpenPixelShader: {
  53727. name: string;
  53728. shader: string;
  53729. };
  53730. }
  53731. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53732. import { Nullable } from "babylonjs/types";
  53733. import { Camera } from "babylonjs/Cameras/camera";
  53734. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53735. import "babylonjs/Shaders/sharpen.fragment";
  53736. import { Engine } from "babylonjs/Engines/engine";
  53737. /**
  53738. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53739. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53740. */
  53741. export class SharpenPostProcess extends PostProcess {
  53742. /**
  53743. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53744. */
  53745. colorAmount: number;
  53746. /**
  53747. * How much sharpness should be applied (default: 0.3)
  53748. */
  53749. edgeAmount: number;
  53750. /**
  53751. * Creates a new instance ConvolutionPostProcess
  53752. * @param name The name of the effect.
  53753. * @param options The required width/height ratio to downsize to before computing the render pass.
  53754. * @param camera The camera to apply the render pass to.
  53755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53756. * @param engine The engine which the post process will be applied. (default: current engine)
  53757. * @param reusable If the post process can be reused on the same frame. (default: false)
  53758. * @param textureType Type of textures used when performing the post process. (default: 0)
  53759. * @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)
  53760. */
  53761. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53762. }
  53763. }
  53764. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53765. import { Nullable } from "babylonjs/types";
  53766. import { Camera } from "babylonjs/Cameras/camera";
  53767. import { Engine } from "babylonjs/Engines/engine";
  53768. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53769. /**
  53770. * PostProcessRenderPipeline
  53771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53772. */
  53773. export class PostProcessRenderPipeline {
  53774. private engine;
  53775. private _renderEffects;
  53776. private _renderEffectsForIsolatedPass;
  53777. /**
  53778. * @hidden
  53779. */
  53780. protected _cameras: Camera[];
  53781. /** @hidden */
  53782. _name: string;
  53783. /**
  53784. * Gets pipeline name
  53785. */
  53786. readonly name: string;
  53787. /**
  53788. * Initializes a PostProcessRenderPipeline
  53789. * @param engine engine to add the pipeline to
  53790. * @param name name of the pipeline
  53791. */
  53792. constructor(engine: Engine, name: string);
  53793. /**
  53794. * Gets the class name
  53795. * @returns "PostProcessRenderPipeline"
  53796. */
  53797. getClassName(): string;
  53798. /**
  53799. * If all the render effects in the pipeline are supported
  53800. */
  53801. readonly isSupported: boolean;
  53802. /**
  53803. * Adds an effect to the pipeline
  53804. * @param renderEffect the effect to add
  53805. */
  53806. addEffect(renderEffect: PostProcessRenderEffect): void;
  53807. /** @hidden */
  53808. _rebuild(): void;
  53809. /** @hidden */
  53810. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53811. /** @hidden */
  53812. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53813. /** @hidden */
  53814. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53815. /** @hidden */
  53816. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53817. /** @hidden */
  53818. _attachCameras(cameras: Camera, unique: boolean): void;
  53819. /** @hidden */
  53820. _attachCameras(cameras: Camera[], unique: boolean): void;
  53821. /** @hidden */
  53822. _detachCameras(cameras: Camera): void;
  53823. /** @hidden */
  53824. _detachCameras(cameras: Nullable<Camera[]>): void;
  53825. /** @hidden */
  53826. _update(): void;
  53827. /** @hidden */
  53828. _reset(): void;
  53829. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53830. /**
  53831. * Disposes of the pipeline
  53832. */
  53833. dispose(): void;
  53834. }
  53835. }
  53836. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53837. import { Camera } from "babylonjs/Cameras/camera";
  53838. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53839. /**
  53840. * PostProcessRenderPipelineManager class
  53841. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53842. */
  53843. export class PostProcessRenderPipelineManager {
  53844. private _renderPipelines;
  53845. /**
  53846. * Initializes a PostProcessRenderPipelineManager
  53847. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53848. */
  53849. constructor();
  53850. /**
  53851. * Gets the list of supported render pipelines
  53852. */
  53853. readonly supportedPipelines: PostProcessRenderPipeline[];
  53854. /**
  53855. * Adds a pipeline to the manager
  53856. * @param renderPipeline The pipeline to add
  53857. */
  53858. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53859. /**
  53860. * Attaches a camera to the pipeline
  53861. * @param renderPipelineName The name of the pipeline to attach to
  53862. * @param cameras the camera to attach
  53863. * @param unique if the camera can be attached multiple times to the pipeline
  53864. */
  53865. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53866. /**
  53867. * Detaches a camera from the pipeline
  53868. * @param renderPipelineName The name of the pipeline to detach from
  53869. * @param cameras the camera to detach
  53870. */
  53871. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53872. /**
  53873. * Enables an effect by name on a pipeline
  53874. * @param renderPipelineName the name of the pipeline to enable the effect in
  53875. * @param renderEffectName the name of the effect to enable
  53876. * @param cameras the cameras that the effect should be enabled on
  53877. */
  53878. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53879. /**
  53880. * Disables an effect by name on a pipeline
  53881. * @param renderPipelineName the name of the pipeline to disable the effect in
  53882. * @param renderEffectName the name of the effect to disable
  53883. * @param cameras the cameras that the effect should be disabled on
  53884. */
  53885. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53886. /**
  53887. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53888. */
  53889. update(): void;
  53890. /** @hidden */
  53891. _rebuild(): void;
  53892. /**
  53893. * Disposes of the manager and pipelines
  53894. */
  53895. dispose(): void;
  53896. }
  53897. }
  53898. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53899. import { ISceneComponent } from "babylonjs/sceneComponent";
  53900. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53901. import { Scene } from "babylonjs/scene";
  53902. module "babylonjs/scene" {
  53903. interface Scene {
  53904. /** @hidden (Backing field) */
  53905. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53906. /**
  53907. * Gets the postprocess render pipeline manager
  53908. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53909. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53910. */
  53911. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53912. }
  53913. }
  53914. /**
  53915. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53916. */
  53917. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53918. /**
  53919. * The component name helpfull to identify the component in the list of scene components.
  53920. */
  53921. readonly name: string;
  53922. /**
  53923. * The scene the component belongs to.
  53924. */
  53925. scene: Scene;
  53926. /**
  53927. * Creates a new instance of the component for the given scene
  53928. * @param scene Defines the scene to register the component in
  53929. */
  53930. constructor(scene: Scene);
  53931. /**
  53932. * Registers the component in a given scene
  53933. */
  53934. register(): void;
  53935. /**
  53936. * Rebuilds the elements related to this component in case of
  53937. * context lost for instance.
  53938. */
  53939. rebuild(): void;
  53940. /**
  53941. * Disposes the component and the associated ressources
  53942. */
  53943. dispose(): void;
  53944. private _gatherRenderTargets;
  53945. }
  53946. }
  53947. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53948. import { IAnimatable } from "babylonjs/Misc/tools";
  53949. import { Camera } from "babylonjs/Cameras/camera";
  53950. import { IDisposable } from "babylonjs/scene";
  53951. import { Scene } from "babylonjs/scene";
  53952. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53953. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53954. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53955. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53956. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53957. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53958. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53959. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53960. import { Animation } from "babylonjs/Animations/animation";
  53961. /**
  53962. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53963. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53964. */
  53965. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53966. private _scene;
  53967. private _camerasToBeAttached;
  53968. /**
  53969. * ID of the sharpen post process,
  53970. */
  53971. private readonly SharpenPostProcessId;
  53972. /**
  53973. * @ignore
  53974. * ID of the image processing post process;
  53975. */
  53976. readonly ImageProcessingPostProcessId: string;
  53977. /**
  53978. * @ignore
  53979. * ID of the Fast Approximate Anti-Aliasing post process;
  53980. */
  53981. readonly FxaaPostProcessId: string;
  53982. /**
  53983. * ID of the chromatic aberration post process,
  53984. */
  53985. private readonly ChromaticAberrationPostProcessId;
  53986. /**
  53987. * ID of the grain post process
  53988. */
  53989. private readonly GrainPostProcessId;
  53990. /**
  53991. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53992. */
  53993. sharpen: SharpenPostProcess;
  53994. private _sharpenEffect;
  53995. private bloom;
  53996. /**
  53997. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53998. */
  53999. depthOfField: DepthOfFieldEffect;
  54000. /**
  54001. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54002. */
  54003. fxaa: FxaaPostProcess;
  54004. /**
  54005. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54006. */
  54007. imageProcessing: ImageProcessingPostProcess;
  54008. /**
  54009. * Chromatic aberration post process which will shift rgb colors in the image
  54010. */
  54011. chromaticAberration: ChromaticAberrationPostProcess;
  54012. private _chromaticAberrationEffect;
  54013. /**
  54014. * Grain post process which add noise to the image
  54015. */
  54016. grain: GrainPostProcess;
  54017. private _grainEffect;
  54018. /**
  54019. * Glow post process which adds a glow to emissive areas of the image
  54020. */
  54021. private _glowLayer;
  54022. /**
  54023. * Animations which can be used to tweak settings over a period of time
  54024. */
  54025. animations: Animation[];
  54026. private _imageProcessingConfigurationObserver;
  54027. private _sharpenEnabled;
  54028. private _bloomEnabled;
  54029. private _depthOfFieldEnabled;
  54030. private _depthOfFieldBlurLevel;
  54031. private _fxaaEnabled;
  54032. private _imageProcessingEnabled;
  54033. private _defaultPipelineTextureType;
  54034. private _bloomScale;
  54035. private _chromaticAberrationEnabled;
  54036. private _grainEnabled;
  54037. private _buildAllowed;
  54038. /**
  54039. * Gets active scene
  54040. */
  54041. readonly scene: Scene;
  54042. /**
  54043. * Enable or disable the sharpen process from the pipeline
  54044. */
  54045. sharpenEnabled: boolean;
  54046. private _resizeObserver;
  54047. private _hardwareScaleLevel;
  54048. private _bloomKernel;
  54049. /**
  54050. * Specifies the size of the bloom blur kernel, relative to the final output size
  54051. */
  54052. bloomKernel: number;
  54053. /**
  54054. * Specifies the weight of the bloom in the final rendering
  54055. */
  54056. private _bloomWeight;
  54057. /**
  54058. * Specifies the luma threshold for the area that will be blurred by the bloom
  54059. */
  54060. private _bloomThreshold;
  54061. private _hdr;
  54062. /**
  54063. * The strength of the bloom.
  54064. */
  54065. bloomWeight: number;
  54066. /**
  54067. * The strength of the bloom.
  54068. */
  54069. bloomThreshold: number;
  54070. /**
  54071. * The scale of the bloom, lower value will provide better performance.
  54072. */
  54073. bloomScale: number;
  54074. /**
  54075. * Enable or disable the bloom from the pipeline
  54076. */
  54077. bloomEnabled: boolean;
  54078. private _rebuildBloom;
  54079. /**
  54080. * If the depth of field is enabled.
  54081. */
  54082. depthOfFieldEnabled: boolean;
  54083. /**
  54084. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54085. */
  54086. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54087. /**
  54088. * If the anti aliasing is enabled.
  54089. */
  54090. fxaaEnabled: boolean;
  54091. private _samples;
  54092. /**
  54093. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54094. */
  54095. samples: number;
  54096. /**
  54097. * If image processing is enabled.
  54098. */
  54099. imageProcessingEnabled: boolean;
  54100. /**
  54101. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54102. */
  54103. glowLayerEnabled: boolean;
  54104. /**
  54105. * Enable or disable the chromaticAberration process from the pipeline
  54106. */
  54107. chromaticAberrationEnabled: boolean;
  54108. /**
  54109. * Enable or disable the grain process from the pipeline
  54110. */
  54111. grainEnabled: boolean;
  54112. /**
  54113. * @constructor
  54114. * @param name - The rendering pipeline name (default: "")
  54115. * @param hdr - If high dynamic range textures should be used (default: true)
  54116. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54117. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54118. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54119. */
  54120. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54121. /**
  54122. * Get the class name
  54123. * @returns "DefaultRenderingPipeline"
  54124. */
  54125. getClassName(): string;
  54126. /**
  54127. * Force the compilation of the entire pipeline.
  54128. */
  54129. prepare(): void;
  54130. private _hasCleared;
  54131. private _prevPostProcess;
  54132. private _prevPrevPostProcess;
  54133. private _setAutoClearAndTextureSharing;
  54134. private _depthOfFieldSceneObserver;
  54135. private _buildPipeline;
  54136. private _disposePostProcesses;
  54137. /**
  54138. * Adds a camera to the pipeline
  54139. * @param camera the camera to be added
  54140. */
  54141. addCamera(camera: Camera): void;
  54142. /**
  54143. * Removes a camera from the pipeline
  54144. * @param camera the camera to remove
  54145. */
  54146. removeCamera(camera: Camera): void;
  54147. /**
  54148. * Dispose of the pipeline and stop all post processes
  54149. */
  54150. dispose(): void;
  54151. /**
  54152. * Serialize the rendering pipeline (Used when exporting)
  54153. * @returns the serialized object
  54154. */
  54155. serialize(): any;
  54156. /**
  54157. * Parse the serialized pipeline
  54158. * @param source Source pipeline.
  54159. * @param scene The scene to load the pipeline to.
  54160. * @param rootUrl The URL of the serialized pipeline.
  54161. * @returns An instantiated pipeline from the serialized object.
  54162. */
  54163. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54164. }
  54165. }
  54166. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54167. /** @hidden */
  54168. export var lensHighlightsPixelShader: {
  54169. name: string;
  54170. shader: string;
  54171. };
  54172. }
  54173. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54174. /** @hidden */
  54175. export var depthOfFieldPixelShader: {
  54176. name: string;
  54177. shader: string;
  54178. };
  54179. }
  54180. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54181. import { Camera } from "babylonjs/Cameras/camera";
  54182. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54183. import { Scene } from "babylonjs/scene";
  54184. import "babylonjs/Shaders/chromaticAberration.fragment";
  54185. import "babylonjs/Shaders/lensHighlights.fragment";
  54186. import "babylonjs/Shaders/depthOfField.fragment";
  54187. /**
  54188. * BABYLON.JS Chromatic Aberration GLSL Shader
  54189. * Author: Olivier Guyot
  54190. * Separates very slightly R, G and B colors on the edges of the screen
  54191. * Inspired by Francois Tarlier & Martins Upitis
  54192. */
  54193. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54194. /**
  54195. * @ignore
  54196. * The chromatic aberration PostProcess id in the pipeline
  54197. */
  54198. LensChromaticAberrationEffect: string;
  54199. /**
  54200. * @ignore
  54201. * The highlights enhancing PostProcess id in the pipeline
  54202. */
  54203. HighlightsEnhancingEffect: string;
  54204. /**
  54205. * @ignore
  54206. * The depth-of-field PostProcess id in the pipeline
  54207. */
  54208. LensDepthOfFieldEffect: string;
  54209. private _scene;
  54210. private _depthTexture;
  54211. private _grainTexture;
  54212. private _chromaticAberrationPostProcess;
  54213. private _highlightsPostProcess;
  54214. private _depthOfFieldPostProcess;
  54215. private _edgeBlur;
  54216. private _grainAmount;
  54217. private _chromaticAberration;
  54218. private _distortion;
  54219. private _highlightsGain;
  54220. private _highlightsThreshold;
  54221. private _dofDistance;
  54222. private _dofAperture;
  54223. private _dofDarken;
  54224. private _dofPentagon;
  54225. private _blurNoise;
  54226. /**
  54227. * @constructor
  54228. *
  54229. * Effect parameters are as follow:
  54230. * {
  54231. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54232. * edge_blur: number; // from 0 to x (1 for realism)
  54233. * distortion: number; // from 0 to x (1 for realism)
  54234. * grain_amount: number; // from 0 to 1
  54235. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54236. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54237. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54238. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54239. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54240. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54241. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54242. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54243. * }
  54244. * Note: if an effect parameter is unset, effect is disabled
  54245. *
  54246. * @param name The rendering pipeline name
  54247. * @param parameters - An object containing all parameters (see above)
  54248. * @param scene The scene linked to this pipeline
  54249. * @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)
  54250. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54251. */
  54252. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54253. /**
  54254. * Sets the amount of blur at the edges
  54255. * @param amount blur amount
  54256. */
  54257. setEdgeBlur(amount: number): void;
  54258. /**
  54259. * Sets edge blur to 0
  54260. */
  54261. disableEdgeBlur(): void;
  54262. /**
  54263. * Sets the amout of grain
  54264. * @param amount Amount of grain
  54265. */
  54266. setGrainAmount(amount: number): void;
  54267. /**
  54268. * Set grain amount to 0
  54269. */
  54270. disableGrain(): void;
  54271. /**
  54272. * Sets the chromatic aberration amount
  54273. * @param amount amount of chromatic aberration
  54274. */
  54275. setChromaticAberration(amount: number): void;
  54276. /**
  54277. * Sets chromatic aberration amount to 0
  54278. */
  54279. disableChromaticAberration(): void;
  54280. /**
  54281. * Sets the EdgeDistortion amount
  54282. * @param amount amount of EdgeDistortion
  54283. */
  54284. setEdgeDistortion(amount: number): void;
  54285. /**
  54286. * Sets edge distortion to 0
  54287. */
  54288. disableEdgeDistortion(): void;
  54289. /**
  54290. * Sets the FocusDistance amount
  54291. * @param amount amount of FocusDistance
  54292. */
  54293. setFocusDistance(amount: number): void;
  54294. /**
  54295. * Disables depth of field
  54296. */
  54297. disableDepthOfField(): void;
  54298. /**
  54299. * Sets the Aperture amount
  54300. * @param amount amount of Aperture
  54301. */
  54302. setAperture(amount: number): void;
  54303. /**
  54304. * Sets the DarkenOutOfFocus amount
  54305. * @param amount amount of DarkenOutOfFocus
  54306. */
  54307. setDarkenOutOfFocus(amount: number): void;
  54308. /**
  54309. * Creates a pentagon bokeh effect
  54310. */
  54311. enablePentagonBokeh(): void;
  54312. /**
  54313. * Disables the pentagon bokeh effect
  54314. */
  54315. disablePentagonBokeh(): void;
  54316. /**
  54317. * Enables noise blur
  54318. */
  54319. enableNoiseBlur(): void;
  54320. /**
  54321. * Disables noise blur
  54322. */
  54323. disableNoiseBlur(): void;
  54324. /**
  54325. * Sets the HighlightsGain amount
  54326. * @param amount amount of HighlightsGain
  54327. */
  54328. setHighlightsGain(amount: number): void;
  54329. /**
  54330. * Sets the HighlightsThreshold amount
  54331. * @param amount amount of HighlightsThreshold
  54332. */
  54333. setHighlightsThreshold(amount: number): void;
  54334. /**
  54335. * Disables highlights
  54336. */
  54337. disableHighlights(): void;
  54338. /**
  54339. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54340. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54341. */
  54342. dispose(disableDepthRender?: boolean): void;
  54343. private _createChromaticAberrationPostProcess;
  54344. private _createHighlightsPostProcess;
  54345. private _createDepthOfFieldPostProcess;
  54346. private _createGrainTexture;
  54347. }
  54348. }
  54349. declare module "babylonjs/Shaders/ssao2.fragment" {
  54350. /** @hidden */
  54351. export var ssao2PixelShader: {
  54352. name: string;
  54353. shader: string;
  54354. };
  54355. }
  54356. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  54357. /** @hidden */
  54358. export var ssaoCombinePixelShader: {
  54359. name: string;
  54360. shader: string;
  54361. };
  54362. }
  54363. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  54364. import { Camera } from "babylonjs/Cameras/camera";
  54365. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54366. import { Scene } from "babylonjs/scene";
  54367. import "babylonjs/Shaders/ssao2.fragment";
  54368. import "babylonjs/Shaders/ssaoCombine.fragment";
  54369. /**
  54370. * Render pipeline to produce ssao effect
  54371. */
  54372. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54373. /**
  54374. * @ignore
  54375. * The PassPostProcess id in the pipeline that contains the original scene color
  54376. */
  54377. SSAOOriginalSceneColorEffect: string;
  54378. /**
  54379. * @ignore
  54380. * The SSAO PostProcess id in the pipeline
  54381. */
  54382. SSAORenderEffect: string;
  54383. /**
  54384. * @ignore
  54385. * The horizontal blur PostProcess id in the pipeline
  54386. */
  54387. SSAOBlurHRenderEffect: string;
  54388. /**
  54389. * @ignore
  54390. * The vertical blur PostProcess id in the pipeline
  54391. */
  54392. SSAOBlurVRenderEffect: string;
  54393. /**
  54394. * @ignore
  54395. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54396. */
  54397. SSAOCombineRenderEffect: string;
  54398. /**
  54399. * The output strength of the SSAO post-process. Default value is 1.0.
  54400. */
  54401. totalStrength: number;
  54402. /**
  54403. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54404. */
  54405. maxZ: number;
  54406. /**
  54407. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54408. */
  54409. minZAspect: number;
  54410. private _samples;
  54411. /**
  54412. * Number of samples used for the SSAO calculations. Default value is 8
  54413. */
  54414. samples: number;
  54415. private _textureSamples;
  54416. /**
  54417. * Number of samples to use for antialiasing
  54418. */
  54419. textureSamples: number;
  54420. /**
  54421. * Ratio object used for SSAO ratio and blur ratio
  54422. */
  54423. private _ratio;
  54424. /**
  54425. * Dynamically generated sphere sampler.
  54426. */
  54427. private _sampleSphere;
  54428. /**
  54429. * Blur filter offsets
  54430. */
  54431. private _samplerOffsets;
  54432. private _expensiveBlur;
  54433. /**
  54434. * If bilateral blur should be used
  54435. */
  54436. expensiveBlur: boolean;
  54437. /**
  54438. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54439. */
  54440. radius: number;
  54441. /**
  54442. * The base color of the SSAO post-process
  54443. * The final result is "base + ssao" between [0, 1]
  54444. */
  54445. base: number;
  54446. /**
  54447. * Support test.
  54448. */
  54449. static readonly IsSupported: boolean;
  54450. private _scene;
  54451. private _depthTexture;
  54452. private _normalTexture;
  54453. private _randomTexture;
  54454. private _originalColorPostProcess;
  54455. private _ssaoPostProcess;
  54456. private _blurHPostProcess;
  54457. private _blurVPostProcess;
  54458. private _ssaoCombinePostProcess;
  54459. private _firstUpdate;
  54460. /**
  54461. * Gets active scene
  54462. */
  54463. readonly scene: Scene;
  54464. /**
  54465. * @constructor
  54466. * @param name The rendering pipeline name
  54467. * @param scene The scene linked to this pipeline
  54468. * @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 }
  54469. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54470. */
  54471. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54472. /**
  54473. * Get the class name
  54474. * @returns "SSAO2RenderingPipeline"
  54475. */
  54476. getClassName(): string;
  54477. /**
  54478. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54479. */
  54480. dispose(disableGeometryBufferRenderer?: boolean): void;
  54481. private _createBlurPostProcess;
  54482. /** @hidden */
  54483. _rebuild(): void;
  54484. private _bits;
  54485. private _radicalInverse_VdC;
  54486. private _hammersley;
  54487. private _hemisphereSample_uniform;
  54488. private _generateHemisphere;
  54489. private _createSSAOPostProcess;
  54490. private _createSSAOCombinePostProcess;
  54491. private _createRandomTexture;
  54492. /**
  54493. * Serialize the rendering pipeline (Used when exporting)
  54494. * @returns the serialized object
  54495. */
  54496. serialize(): any;
  54497. /**
  54498. * Parse the serialized pipeline
  54499. * @param source Source pipeline.
  54500. * @param scene The scene to load the pipeline to.
  54501. * @param rootUrl The URL of the serialized pipeline.
  54502. * @returns An instantiated pipeline from the serialized object.
  54503. */
  54504. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54505. }
  54506. }
  54507. declare module "babylonjs/Shaders/ssao.fragment" {
  54508. /** @hidden */
  54509. export var ssaoPixelShader: {
  54510. name: string;
  54511. shader: string;
  54512. };
  54513. }
  54514. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54515. import { Camera } from "babylonjs/Cameras/camera";
  54516. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54517. import { Scene } from "babylonjs/scene";
  54518. import "babylonjs/Shaders/ssao.fragment";
  54519. import "babylonjs/Shaders/ssaoCombine.fragment";
  54520. /**
  54521. * Render pipeline to produce ssao effect
  54522. */
  54523. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54524. /**
  54525. * @ignore
  54526. * The PassPostProcess id in the pipeline that contains the original scene color
  54527. */
  54528. SSAOOriginalSceneColorEffect: string;
  54529. /**
  54530. * @ignore
  54531. * The SSAO PostProcess id in the pipeline
  54532. */
  54533. SSAORenderEffect: string;
  54534. /**
  54535. * @ignore
  54536. * The horizontal blur PostProcess id in the pipeline
  54537. */
  54538. SSAOBlurHRenderEffect: string;
  54539. /**
  54540. * @ignore
  54541. * The vertical blur PostProcess id in the pipeline
  54542. */
  54543. SSAOBlurVRenderEffect: string;
  54544. /**
  54545. * @ignore
  54546. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54547. */
  54548. SSAOCombineRenderEffect: string;
  54549. /**
  54550. * The output strength of the SSAO post-process. Default value is 1.0.
  54551. */
  54552. totalStrength: number;
  54553. /**
  54554. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54555. */
  54556. radius: number;
  54557. /**
  54558. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54559. * Must not be equal to fallOff and superior to fallOff.
  54560. * Default value is 0.0075
  54561. */
  54562. area: number;
  54563. /**
  54564. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54565. * Must not be equal to area and inferior to area.
  54566. * Default value is 0.000001
  54567. */
  54568. fallOff: number;
  54569. /**
  54570. * The base color of the SSAO post-process
  54571. * The final result is "base + ssao" between [0, 1]
  54572. */
  54573. base: number;
  54574. private _scene;
  54575. private _depthTexture;
  54576. private _randomTexture;
  54577. private _originalColorPostProcess;
  54578. private _ssaoPostProcess;
  54579. private _blurHPostProcess;
  54580. private _blurVPostProcess;
  54581. private _ssaoCombinePostProcess;
  54582. private _firstUpdate;
  54583. /**
  54584. * Gets active scene
  54585. */
  54586. readonly scene: Scene;
  54587. /**
  54588. * @constructor
  54589. * @param name - The rendering pipeline name
  54590. * @param scene - The scene linked to this pipeline
  54591. * @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 }
  54592. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54593. */
  54594. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54595. /**
  54596. * Get the class name
  54597. * @returns "SSAORenderingPipeline"
  54598. */
  54599. getClassName(): string;
  54600. /**
  54601. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54602. */
  54603. dispose(disableDepthRender?: boolean): void;
  54604. private _createBlurPostProcess;
  54605. /** @hidden */
  54606. _rebuild(): void;
  54607. private _createSSAOPostProcess;
  54608. private _createSSAOCombinePostProcess;
  54609. private _createRandomTexture;
  54610. }
  54611. }
  54612. declare module "babylonjs/Shaders/standard.fragment" {
  54613. /** @hidden */
  54614. export var standardPixelShader: {
  54615. name: string;
  54616. shader: string;
  54617. };
  54618. }
  54619. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54620. import { Nullable } from "babylonjs/types";
  54621. import { IAnimatable } from "babylonjs/Misc/tools";
  54622. import { Camera } from "babylonjs/Cameras/camera";
  54623. import { Texture } from "babylonjs/Materials/Textures/texture";
  54624. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54625. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54626. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54627. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54628. import { IDisposable } from "babylonjs/scene";
  54629. import { SpotLight } from "babylonjs/Lights/spotLight";
  54630. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54631. import { Scene } from "babylonjs/scene";
  54632. import { Animation } from "babylonjs/Animations/animation";
  54633. import "babylonjs/Shaders/standard.fragment";
  54634. /**
  54635. * Standard rendering pipeline
  54636. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54637. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54638. */
  54639. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54640. /**
  54641. * Public members
  54642. */
  54643. /**
  54644. * Post-process which contains the original scene color before the pipeline applies all the effects
  54645. */
  54646. originalPostProcess: Nullable<PostProcess>;
  54647. /**
  54648. * Post-process used to down scale an image x4
  54649. */
  54650. downSampleX4PostProcess: Nullable<PostProcess>;
  54651. /**
  54652. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54653. */
  54654. brightPassPostProcess: Nullable<PostProcess>;
  54655. /**
  54656. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54657. */
  54658. blurHPostProcesses: PostProcess[];
  54659. /**
  54660. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54661. */
  54662. blurVPostProcesses: PostProcess[];
  54663. /**
  54664. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54665. */
  54666. textureAdderPostProcess: Nullable<PostProcess>;
  54667. /**
  54668. * Post-process used to create volumetric lighting effect
  54669. */
  54670. volumetricLightPostProcess: Nullable<PostProcess>;
  54671. /**
  54672. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54673. */
  54674. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54675. /**
  54676. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54677. */
  54678. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54679. /**
  54680. * Post-process used to merge the volumetric light effect and the real scene color
  54681. */
  54682. volumetricLightMergePostProces: Nullable<PostProcess>;
  54683. /**
  54684. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54685. */
  54686. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54687. /**
  54688. * Base post-process used to calculate the average luminance of the final image for HDR
  54689. */
  54690. luminancePostProcess: Nullable<PostProcess>;
  54691. /**
  54692. * Post-processes used to create down sample post-processes in order to get
  54693. * the average luminance of the final image for HDR
  54694. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54695. */
  54696. luminanceDownSamplePostProcesses: PostProcess[];
  54697. /**
  54698. * Post-process used to create a HDR effect (light adaptation)
  54699. */
  54700. hdrPostProcess: Nullable<PostProcess>;
  54701. /**
  54702. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54703. */
  54704. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54705. /**
  54706. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54707. */
  54708. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54709. /**
  54710. * Post-process used to merge the final HDR post-process and the real scene color
  54711. */
  54712. hdrFinalPostProcess: Nullable<PostProcess>;
  54713. /**
  54714. * Post-process used to create a lens flare effect
  54715. */
  54716. lensFlarePostProcess: Nullable<PostProcess>;
  54717. /**
  54718. * Post-process that merges the result of the lens flare post-process and the real scene color
  54719. */
  54720. lensFlareComposePostProcess: Nullable<PostProcess>;
  54721. /**
  54722. * Post-process used to create a motion blur effect
  54723. */
  54724. motionBlurPostProcess: Nullable<PostProcess>;
  54725. /**
  54726. * Post-process used to create a depth of field effect
  54727. */
  54728. depthOfFieldPostProcess: Nullable<PostProcess>;
  54729. /**
  54730. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54731. */
  54732. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54733. /**
  54734. * Represents the brightness threshold in order to configure the illuminated surfaces
  54735. */
  54736. brightThreshold: number;
  54737. /**
  54738. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54739. */
  54740. blurWidth: number;
  54741. /**
  54742. * Sets if the blur for highlighted surfaces must be only horizontal
  54743. */
  54744. horizontalBlur: boolean;
  54745. /**
  54746. * Sets the overall exposure used by the pipeline
  54747. */
  54748. exposure: number;
  54749. /**
  54750. * Texture used typically to simulate "dirty" on camera lens
  54751. */
  54752. lensTexture: Nullable<Texture>;
  54753. /**
  54754. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54755. */
  54756. volumetricLightCoefficient: number;
  54757. /**
  54758. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54759. */
  54760. volumetricLightPower: number;
  54761. /**
  54762. * Used the set the blur intensity to smooth the volumetric lights
  54763. */
  54764. volumetricLightBlurScale: number;
  54765. /**
  54766. * Light (spot or directional) used to generate the volumetric lights rays
  54767. * The source light must have a shadow generate so the pipeline can get its
  54768. * depth map
  54769. */
  54770. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54771. /**
  54772. * For eye adaptation, represents the minimum luminance the eye can see
  54773. */
  54774. hdrMinimumLuminance: number;
  54775. /**
  54776. * For eye adaptation, represents the decrease luminance speed
  54777. */
  54778. hdrDecreaseRate: number;
  54779. /**
  54780. * For eye adaptation, represents the increase luminance speed
  54781. */
  54782. hdrIncreaseRate: number;
  54783. /**
  54784. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54785. */
  54786. lensColorTexture: Nullable<Texture>;
  54787. /**
  54788. * The overall strengh for the lens flare effect
  54789. */
  54790. lensFlareStrength: number;
  54791. /**
  54792. * Dispersion coefficient for lens flare ghosts
  54793. */
  54794. lensFlareGhostDispersal: number;
  54795. /**
  54796. * Main lens flare halo width
  54797. */
  54798. lensFlareHaloWidth: number;
  54799. /**
  54800. * Based on the lens distortion effect, defines how much the lens flare result
  54801. * is distorted
  54802. */
  54803. lensFlareDistortionStrength: number;
  54804. /**
  54805. * Lens star texture must be used to simulate rays on the flares and is available
  54806. * in the documentation
  54807. */
  54808. lensStarTexture: Nullable<Texture>;
  54809. /**
  54810. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54811. * flare effect by taking account of the dirt texture
  54812. */
  54813. lensFlareDirtTexture: Nullable<Texture>;
  54814. /**
  54815. * Represents the focal length for the depth of field effect
  54816. */
  54817. depthOfFieldDistance: number;
  54818. /**
  54819. * Represents the blur intensity for the blurred part of the depth of field effect
  54820. */
  54821. depthOfFieldBlurWidth: number;
  54822. /**
  54823. * For motion blur, defines how much the image is blurred by the movement
  54824. */
  54825. motionStrength: number;
  54826. /**
  54827. * List of animations for the pipeline (IAnimatable implementation)
  54828. */
  54829. animations: Animation[];
  54830. /**
  54831. * Private members
  54832. */
  54833. private _scene;
  54834. private _currentDepthOfFieldSource;
  54835. private _basePostProcess;
  54836. private _hdrCurrentLuminance;
  54837. private _floatTextureType;
  54838. private _ratio;
  54839. private _bloomEnabled;
  54840. private _depthOfFieldEnabled;
  54841. private _vlsEnabled;
  54842. private _lensFlareEnabled;
  54843. private _hdrEnabled;
  54844. private _motionBlurEnabled;
  54845. private _fxaaEnabled;
  54846. private _motionBlurSamples;
  54847. private _volumetricLightStepsCount;
  54848. private _samples;
  54849. /**
  54850. * @ignore
  54851. * Specifies if the bloom pipeline is enabled
  54852. */
  54853. BloomEnabled: boolean;
  54854. /**
  54855. * @ignore
  54856. * Specifies if the depth of field pipeline is enabed
  54857. */
  54858. DepthOfFieldEnabled: boolean;
  54859. /**
  54860. * @ignore
  54861. * Specifies if the lens flare pipeline is enabed
  54862. */
  54863. LensFlareEnabled: boolean;
  54864. /**
  54865. * @ignore
  54866. * Specifies if the HDR pipeline is enabled
  54867. */
  54868. HDREnabled: boolean;
  54869. /**
  54870. * @ignore
  54871. * Specifies if the volumetric lights scattering effect is enabled
  54872. */
  54873. VLSEnabled: boolean;
  54874. /**
  54875. * @ignore
  54876. * Specifies if the motion blur effect is enabled
  54877. */
  54878. MotionBlurEnabled: boolean;
  54879. /**
  54880. * Specifies if anti-aliasing is enabled
  54881. */
  54882. fxaaEnabled: boolean;
  54883. /**
  54884. * Specifies the number of steps used to calculate the volumetric lights
  54885. * Typically in interval [50, 200]
  54886. */
  54887. volumetricLightStepsCount: number;
  54888. /**
  54889. * Specifies the number of samples used for the motion blur effect
  54890. * Typically in interval [16, 64]
  54891. */
  54892. motionBlurSamples: number;
  54893. /**
  54894. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54895. */
  54896. samples: number;
  54897. /**
  54898. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54899. * @constructor
  54900. * @param name The rendering pipeline name
  54901. * @param scene The scene linked to this pipeline
  54902. * @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)
  54903. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54904. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54905. */
  54906. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54907. private _buildPipeline;
  54908. private _createDownSampleX4PostProcess;
  54909. private _createBrightPassPostProcess;
  54910. private _createBlurPostProcesses;
  54911. private _createTextureAdderPostProcess;
  54912. private _createVolumetricLightPostProcess;
  54913. private _createLuminancePostProcesses;
  54914. private _createHdrPostProcess;
  54915. private _createLensFlarePostProcess;
  54916. private _createDepthOfFieldPostProcess;
  54917. private _createMotionBlurPostProcess;
  54918. private _getDepthTexture;
  54919. private _disposePostProcesses;
  54920. /**
  54921. * Dispose of the pipeline and stop all post processes
  54922. */
  54923. dispose(): void;
  54924. /**
  54925. * Serialize the rendering pipeline (Used when exporting)
  54926. * @returns the serialized object
  54927. */
  54928. serialize(): any;
  54929. /**
  54930. * Parse the serialized pipeline
  54931. * @param source Source pipeline.
  54932. * @param scene The scene to load the pipeline to.
  54933. * @param rootUrl The URL of the serialized pipeline.
  54934. * @returns An instantiated pipeline from the serialized object.
  54935. */
  54936. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54937. /**
  54938. * Luminance steps
  54939. */
  54940. static LuminanceSteps: number;
  54941. }
  54942. }
  54943. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54944. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54945. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54946. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54947. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54948. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54949. }
  54950. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54951. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54952. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54953. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54954. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54955. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54956. }
  54957. declare module "babylonjs/Shaders/tonemap.fragment" {
  54958. /** @hidden */
  54959. export var tonemapPixelShader: {
  54960. name: string;
  54961. shader: string;
  54962. };
  54963. }
  54964. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54965. import { Camera } from "babylonjs/Cameras/camera";
  54966. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54967. import "babylonjs/Shaders/tonemap.fragment";
  54968. import { Engine } from "babylonjs/Engines/engine";
  54969. /** Defines operator used for tonemapping */
  54970. export enum TonemappingOperator {
  54971. /** Hable */
  54972. Hable = 0,
  54973. /** Reinhard */
  54974. Reinhard = 1,
  54975. /** HejiDawson */
  54976. HejiDawson = 2,
  54977. /** Photographic */
  54978. Photographic = 3
  54979. }
  54980. /**
  54981. * Defines a post process to apply tone mapping
  54982. */
  54983. export class TonemapPostProcess extends PostProcess {
  54984. private _operator;
  54985. /** Defines the required exposure adjustement */
  54986. exposureAdjustment: number;
  54987. /**
  54988. * Creates a new TonemapPostProcess
  54989. * @param name defines the name of the postprocess
  54990. * @param _operator defines the operator to use
  54991. * @param exposureAdjustment defines the required exposure adjustement
  54992. * @param camera defines the camera to use (can be null)
  54993. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54994. * @param engine defines the hosting engine (can be ignore if camera is set)
  54995. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54996. */
  54997. constructor(name: string, _operator: TonemappingOperator,
  54998. /** Defines the required exposure adjustement */
  54999. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55000. }
  55001. }
  55002. declare module "babylonjs/Shaders/depth.vertex" {
  55003. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55007. /** @hidden */
  55008. export var depthVertexShader: {
  55009. name: string;
  55010. shader: string;
  55011. };
  55012. }
  55013. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55014. /** @hidden */
  55015. export var volumetricLightScatteringPixelShader: {
  55016. name: string;
  55017. shader: string;
  55018. };
  55019. }
  55020. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55021. /** @hidden */
  55022. export var volumetricLightScatteringPassPixelShader: {
  55023. name: string;
  55024. shader: string;
  55025. };
  55026. }
  55027. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55028. import { Vector3 } from "babylonjs/Maths/math";
  55029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55030. import { Mesh } from "babylonjs/Meshes/mesh";
  55031. import { Camera } from "babylonjs/Cameras/camera";
  55032. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55033. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55034. import { Scene } from "babylonjs/scene";
  55035. import "babylonjs/Meshes/Builders/planeBuilder";
  55036. import "babylonjs/Shaders/depth.vertex";
  55037. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55038. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55039. import { Engine } from "babylonjs/Engines/engine";
  55040. /**
  55041. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55042. */
  55043. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55044. private _volumetricLightScatteringPass;
  55045. private _volumetricLightScatteringRTT;
  55046. private _viewPort;
  55047. private _screenCoordinates;
  55048. private _cachedDefines;
  55049. /**
  55050. * If not undefined, the mesh position is computed from the attached node position
  55051. */
  55052. attachedNode: {
  55053. position: Vector3;
  55054. };
  55055. /**
  55056. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55057. */
  55058. customMeshPosition: Vector3;
  55059. /**
  55060. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55061. */
  55062. useCustomMeshPosition: boolean;
  55063. /**
  55064. * If the post-process should inverse the light scattering direction
  55065. */
  55066. invert: boolean;
  55067. /**
  55068. * The internal mesh used by the post-process
  55069. */
  55070. mesh: Mesh;
  55071. /**
  55072. * @hidden
  55073. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55074. */
  55075. useDiffuseColor: boolean;
  55076. /**
  55077. * Array containing the excluded meshes not rendered in the internal pass
  55078. */
  55079. excludedMeshes: AbstractMesh[];
  55080. /**
  55081. * Controls the overall intensity of the post-process
  55082. */
  55083. exposure: number;
  55084. /**
  55085. * Dissipates each sample's contribution in range [0, 1]
  55086. */
  55087. decay: number;
  55088. /**
  55089. * Controls the overall intensity of each sample
  55090. */
  55091. weight: number;
  55092. /**
  55093. * Controls the density of each sample
  55094. */
  55095. density: number;
  55096. /**
  55097. * @constructor
  55098. * @param name The post-process name
  55099. * @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)
  55100. * @param camera The camera that the post-process will be attached to
  55101. * @param mesh The mesh used to create the light scattering
  55102. * @param samples The post-process quality, default 100
  55103. * @param samplingModeThe post-process filtering mode
  55104. * @param engine The babylon engine
  55105. * @param reusable If the post-process is reusable
  55106. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55107. */
  55108. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55109. /**
  55110. * Returns the string "VolumetricLightScatteringPostProcess"
  55111. * @returns "VolumetricLightScatteringPostProcess"
  55112. */
  55113. getClassName(): string;
  55114. private _isReady;
  55115. /**
  55116. * Sets the new light position for light scattering effect
  55117. * @param position The new custom light position
  55118. */
  55119. setCustomMeshPosition(position: Vector3): void;
  55120. /**
  55121. * Returns the light position for light scattering effect
  55122. * @return Vector3 The custom light position
  55123. */
  55124. getCustomMeshPosition(): Vector3;
  55125. /**
  55126. * Disposes the internal assets and detaches the post-process from the camera
  55127. */
  55128. dispose(camera: Camera): void;
  55129. /**
  55130. * Returns the render target texture used by the post-process
  55131. * @return the render target texture used by the post-process
  55132. */
  55133. getPass(): RenderTargetTexture;
  55134. private _meshExcluded;
  55135. private _createPass;
  55136. private _updateMeshScreenCoordinates;
  55137. /**
  55138. * Creates a default mesh for the Volumeric Light Scattering post-process
  55139. * @param name The mesh name
  55140. * @param scene The scene where to create the mesh
  55141. * @return the default mesh
  55142. */
  55143. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55144. }
  55145. }
  55146. declare module "babylonjs/PostProcesses/index" {
  55147. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55148. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55149. export * from "babylonjs/PostProcesses/bloomEffect";
  55150. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55151. export * from "babylonjs/PostProcesses/blurPostProcess";
  55152. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55153. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55154. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55155. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55156. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55157. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55158. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55159. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55160. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55161. export * from "babylonjs/PostProcesses/filterPostProcess";
  55162. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55163. export * from "babylonjs/PostProcesses/grainPostProcess";
  55164. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55165. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55166. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55167. export * from "babylonjs/PostProcesses/passPostProcess";
  55168. export * from "babylonjs/PostProcesses/postProcess";
  55169. export * from "babylonjs/PostProcesses/postProcessManager";
  55170. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55171. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55172. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55173. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55174. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55175. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55176. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55177. }
  55178. declare module "babylonjs/Probes/index" {
  55179. export * from "babylonjs/Probes/reflectionProbe";
  55180. }
  55181. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55182. import { Scene } from "babylonjs/scene";
  55183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55184. import { Color3 } from "babylonjs/Maths/math";
  55185. import { SmartArray } from "babylonjs/Misc/smartArray";
  55186. import { ISceneComponent } from "babylonjs/sceneComponent";
  55187. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55188. import "babylonjs/Meshes/Builders/boxBuilder";
  55189. import "babylonjs/Shaders/color.fragment";
  55190. import "babylonjs/Shaders/color.vertex";
  55191. module "babylonjs/scene" {
  55192. interface Scene {
  55193. /** @hidden (Backing field) */
  55194. _boundingBoxRenderer: BoundingBoxRenderer;
  55195. /** @hidden (Backing field) */
  55196. _forceShowBoundingBoxes: boolean;
  55197. /**
  55198. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55199. */
  55200. forceShowBoundingBoxes: boolean;
  55201. /**
  55202. * Gets the bounding box renderer associated with the scene
  55203. * @returns a BoundingBoxRenderer
  55204. */
  55205. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55206. }
  55207. }
  55208. module "babylonjs/Meshes/abstractMesh" {
  55209. interface AbstractMesh {
  55210. /** @hidden (Backing field) */
  55211. _showBoundingBox: boolean;
  55212. /**
  55213. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55214. */
  55215. showBoundingBox: boolean;
  55216. }
  55217. }
  55218. /**
  55219. * Component responsible of rendering the bounding box of the meshes in a scene.
  55220. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55221. */
  55222. export class BoundingBoxRenderer implements ISceneComponent {
  55223. /**
  55224. * The component name helpfull to identify the component in the list of scene components.
  55225. */
  55226. readonly name: string;
  55227. /**
  55228. * The scene the component belongs to.
  55229. */
  55230. scene: Scene;
  55231. /**
  55232. * Color of the bounding box lines placed in front of an object
  55233. */
  55234. frontColor: Color3;
  55235. /**
  55236. * Color of the bounding box lines placed behind an object
  55237. */
  55238. backColor: Color3;
  55239. /**
  55240. * Defines if the renderer should show the back lines or not
  55241. */
  55242. showBackLines: boolean;
  55243. /**
  55244. * @hidden
  55245. */
  55246. renderList: SmartArray<BoundingBox>;
  55247. private _colorShader;
  55248. private _vertexBuffers;
  55249. private _indexBuffer;
  55250. /**
  55251. * Instantiates a new bounding box renderer in a scene.
  55252. * @param scene the scene the renderer renders in
  55253. */
  55254. constructor(scene: Scene);
  55255. /**
  55256. * Registers the component in a given scene
  55257. */
  55258. register(): void;
  55259. private _evaluateSubMesh;
  55260. private _activeMesh;
  55261. private _prepareRessources;
  55262. private _createIndexBuffer;
  55263. /**
  55264. * Rebuilds the elements related to this component in case of
  55265. * context lost for instance.
  55266. */
  55267. rebuild(): void;
  55268. /**
  55269. * @hidden
  55270. */
  55271. reset(): void;
  55272. /**
  55273. * Render the bounding boxes of a specific rendering group
  55274. * @param renderingGroupId defines the rendering group to render
  55275. */
  55276. render(renderingGroupId: number): void;
  55277. /**
  55278. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55279. * @param mesh Define the mesh to render the occlusion bounding box for
  55280. */
  55281. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55282. /**
  55283. * Dispose and release the resources attached to this renderer.
  55284. */
  55285. dispose(): void;
  55286. }
  55287. }
  55288. declare module "babylonjs/Shaders/depth.fragment" {
  55289. /** @hidden */
  55290. export var depthPixelShader: {
  55291. name: string;
  55292. shader: string;
  55293. };
  55294. }
  55295. declare module "babylonjs/Rendering/depthRenderer" {
  55296. import { Nullable } from "babylonjs/types";
  55297. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55298. import { Scene } from "babylonjs/scene";
  55299. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55300. import { Camera } from "babylonjs/Cameras/camera";
  55301. import "babylonjs/Shaders/depth.fragment";
  55302. import "babylonjs/Shaders/depth.vertex";
  55303. /**
  55304. * This represents a depth renderer in Babylon.
  55305. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55306. */
  55307. export class DepthRenderer {
  55308. private _scene;
  55309. private _depthMap;
  55310. private _effect;
  55311. private _cachedDefines;
  55312. private _camera;
  55313. /**
  55314. * Specifiess that the depth renderer will only be used within
  55315. * the camera it is created for.
  55316. * This can help forcing its rendering during the camera processing.
  55317. */
  55318. useOnlyInActiveCamera: boolean;
  55319. /** @hidden */
  55320. static _SceneComponentInitialization: (scene: Scene) => void;
  55321. /**
  55322. * Instantiates a depth renderer
  55323. * @param scene The scene the renderer belongs to
  55324. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55325. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55326. */
  55327. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55328. /**
  55329. * Creates the depth rendering effect and checks if the effect is ready.
  55330. * @param subMesh The submesh to be used to render the depth map of
  55331. * @param useInstances If multiple world instances should be used
  55332. * @returns if the depth renderer is ready to render the depth map
  55333. */
  55334. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55335. /**
  55336. * Gets the texture which the depth map will be written to.
  55337. * @returns The depth map texture
  55338. */
  55339. getDepthMap(): RenderTargetTexture;
  55340. /**
  55341. * Disposes of the depth renderer.
  55342. */
  55343. dispose(): void;
  55344. }
  55345. }
  55346. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55347. import { Nullable } from "babylonjs/types";
  55348. import { Scene } from "babylonjs/scene";
  55349. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55350. import { Camera } from "babylonjs/Cameras/camera";
  55351. import { ISceneComponent } from "babylonjs/sceneComponent";
  55352. module "babylonjs/scene" {
  55353. interface Scene {
  55354. /** @hidden (Backing field) */
  55355. _depthRenderer: {
  55356. [id: string]: DepthRenderer;
  55357. };
  55358. /**
  55359. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55360. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55361. * @returns the created depth renderer
  55362. */
  55363. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55364. /**
  55365. * Disables a depth renderer for a given camera
  55366. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55367. */
  55368. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55369. }
  55370. }
  55371. /**
  55372. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55373. * in several rendering techniques.
  55374. */
  55375. export class DepthRendererSceneComponent implements ISceneComponent {
  55376. /**
  55377. * The component name helpfull to identify the component in the list of scene components.
  55378. */
  55379. readonly name: string;
  55380. /**
  55381. * The scene the component belongs to.
  55382. */
  55383. scene: Scene;
  55384. /**
  55385. * Creates a new instance of the component for the given scene
  55386. * @param scene Defines the scene to register the component in
  55387. */
  55388. constructor(scene: Scene);
  55389. /**
  55390. * Registers the component in a given scene
  55391. */
  55392. register(): void;
  55393. /**
  55394. * Rebuilds the elements related to this component in case of
  55395. * context lost for instance.
  55396. */
  55397. rebuild(): void;
  55398. /**
  55399. * Disposes the component and the associated ressources
  55400. */
  55401. dispose(): void;
  55402. private _gatherRenderTargets;
  55403. private _gatherActiveCameraRenderTargets;
  55404. }
  55405. }
  55406. declare module "babylonjs/Shaders/outline.fragment" {
  55407. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55408. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55409. /** @hidden */
  55410. export var outlinePixelShader: {
  55411. name: string;
  55412. shader: string;
  55413. };
  55414. }
  55415. declare module "babylonjs/Shaders/outline.vertex" {
  55416. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55417. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55418. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55419. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55420. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55421. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55422. /** @hidden */
  55423. export var outlineVertexShader: {
  55424. name: string;
  55425. shader: string;
  55426. };
  55427. }
  55428. declare module "babylonjs/Rendering/outlineRenderer" {
  55429. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55430. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55431. import { Scene } from "babylonjs/scene";
  55432. import { ISceneComponent } from "babylonjs/sceneComponent";
  55433. import "babylonjs/Shaders/outline.fragment";
  55434. import "babylonjs/Shaders/outline.vertex";
  55435. module "babylonjs/scene" {
  55436. interface Scene {
  55437. /** @hidden */
  55438. _outlineRenderer: OutlineRenderer;
  55439. /**
  55440. * Gets the outline renderer associated with the scene
  55441. * @returns a OutlineRenderer
  55442. */
  55443. getOutlineRenderer(): OutlineRenderer;
  55444. }
  55445. }
  55446. module "babylonjs/Meshes/abstractMesh" {
  55447. interface AbstractMesh {
  55448. /** @hidden (Backing field) */
  55449. _renderOutline: boolean;
  55450. /**
  55451. * Gets or sets a boolean indicating if the outline must be rendered as well
  55452. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55453. */
  55454. renderOutline: boolean;
  55455. /** @hidden (Backing field) */
  55456. _renderOverlay: boolean;
  55457. /**
  55458. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55459. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55460. */
  55461. renderOverlay: boolean;
  55462. }
  55463. }
  55464. /**
  55465. * This class is responsible to draw bothe outline/overlay of meshes.
  55466. * It should not be used directly but through the available method on mesh.
  55467. */
  55468. export class OutlineRenderer implements ISceneComponent {
  55469. /**
  55470. * The name of the component. Each component must have a unique name.
  55471. */
  55472. name: string;
  55473. /**
  55474. * The scene the component belongs to.
  55475. */
  55476. scene: Scene;
  55477. /**
  55478. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55479. */
  55480. zOffset: number;
  55481. private _engine;
  55482. private _effect;
  55483. private _cachedDefines;
  55484. private _savedDepthWrite;
  55485. /**
  55486. * Instantiates a new outline renderer. (There could be only one per scene).
  55487. * @param scene Defines the scene it belongs to
  55488. */
  55489. constructor(scene: Scene);
  55490. /**
  55491. * Register the component to one instance of a scene.
  55492. */
  55493. register(): void;
  55494. /**
  55495. * Rebuilds the elements related to this component in case of
  55496. * context lost for instance.
  55497. */
  55498. rebuild(): void;
  55499. /**
  55500. * Disposes the component and the associated ressources.
  55501. */
  55502. dispose(): void;
  55503. /**
  55504. * Renders the outline in the canvas.
  55505. * @param subMesh Defines the sumesh to render
  55506. * @param batch Defines the batch of meshes in case of instances
  55507. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55508. */
  55509. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55510. /**
  55511. * Returns whether or not the outline renderer is ready for a given submesh.
  55512. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55513. * @param subMesh Defines the submesh to check readyness for
  55514. * @param useInstances Defines wheter wee are trying to render instances or not
  55515. * @returns true if ready otherwise false
  55516. */
  55517. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55518. private _beforeRenderingMesh;
  55519. private _afterRenderingMesh;
  55520. }
  55521. }
  55522. declare module "babylonjs/Rendering/index" {
  55523. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55524. export * from "babylonjs/Rendering/depthRenderer";
  55525. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55526. export * from "babylonjs/Rendering/edgesRenderer";
  55527. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55528. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55529. export * from "babylonjs/Rendering/outlineRenderer";
  55530. export * from "babylonjs/Rendering/renderingGroup";
  55531. export * from "babylonjs/Rendering/renderingManager";
  55532. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55533. }
  55534. declare module "babylonjs/Sprites/index" {
  55535. export * from "babylonjs/Sprites/sprite";
  55536. export * from "babylonjs/Sprites/spriteManager";
  55537. export * from "babylonjs/Sprites/spriteSceneComponent";
  55538. }
  55539. declare module "babylonjs/Misc/assetsManager" {
  55540. import { Scene } from "babylonjs/scene";
  55541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55542. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55543. import { Skeleton } from "babylonjs/Bones/skeleton";
  55544. import { Observable } from "babylonjs/Misc/observable";
  55545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55546. import { Texture } from "babylonjs/Materials/Textures/texture";
  55547. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55548. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55549. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55550. /**
  55551. * Defines the list of states available for a task inside a AssetsManager
  55552. */
  55553. export enum AssetTaskState {
  55554. /**
  55555. * Initialization
  55556. */
  55557. INIT = 0,
  55558. /**
  55559. * Running
  55560. */
  55561. RUNNING = 1,
  55562. /**
  55563. * Done
  55564. */
  55565. DONE = 2,
  55566. /**
  55567. * Error
  55568. */
  55569. ERROR = 3
  55570. }
  55571. /**
  55572. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55573. */
  55574. export abstract class AbstractAssetTask {
  55575. /**
  55576. * Task name
  55577. */ name: string;
  55578. /**
  55579. * Callback called when the task is successful
  55580. */
  55581. onSuccess: (task: any) => void;
  55582. /**
  55583. * Callback called when the task is not successful
  55584. */
  55585. onError: (task: any, message?: string, exception?: any) => void;
  55586. /**
  55587. * Creates a new AssetsManager
  55588. * @param name defines the name of the task
  55589. */
  55590. constructor(
  55591. /**
  55592. * Task name
  55593. */ name: string);
  55594. private _isCompleted;
  55595. private _taskState;
  55596. private _errorObject;
  55597. /**
  55598. * Get if the task is completed
  55599. */
  55600. readonly isCompleted: boolean;
  55601. /**
  55602. * Gets the current state of the task
  55603. */
  55604. readonly taskState: AssetTaskState;
  55605. /**
  55606. * Gets the current error object (if task is in error)
  55607. */
  55608. readonly errorObject: {
  55609. message?: string;
  55610. exception?: any;
  55611. };
  55612. /**
  55613. * Internal only
  55614. * @hidden
  55615. */
  55616. _setErrorObject(message?: string, exception?: any): void;
  55617. /**
  55618. * Execute the current task
  55619. * @param scene defines the scene where you want your assets to be loaded
  55620. * @param onSuccess is a callback called when the task is successfully executed
  55621. * @param onError is a callback called if an error occurs
  55622. */
  55623. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55624. /**
  55625. * Execute the current task
  55626. * @param scene defines the scene where you want your assets to be loaded
  55627. * @param onSuccess is a callback called when the task is successfully executed
  55628. * @param onError is a callback called if an error occurs
  55629. */
  55630. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55631. /**
  55632. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55633. * This can be used with failed tasks that have the reason for failure fixed.
  55634. */
  55635. reset(): void;
  55636. private onErrorCallback;
  55637. private onDoneCallback;
  55638. }
  55639. /**
  55640. * Define the interface used by progress events raised during assets loading
  55641. */
  55642. export interface IAssetsProgressEvent {
  55643. /**
  55644. * Defines the number of remaining tasks to process
  55645. */
  55646. remainingCount: number;
  55647. /**
  55648. * Defines the total number of tasks
  55649. */
  55650. totalCount: number;
  55651. /**
  55652. * Defines the task that was just processed
  55653. */
  55654. task: AbstractAssetTask;
  55655. }
  55656. /**
  55657. * Class used to share progress information about assets loading
  55658. */
  55659. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55660. /**
  55661. * Defines the number of remaining tasks to process
  55662. */
  55663. remainingCount: number;
  55664. /**
  55665. * Defines the total number of tasks
  55666. */
  55667. totalCount: number;
  55668. /**
  55669. * Defines the task that was just processed
  55670. */
  55671. task: AbstractAssetTask;
  55672. /**
  55673. * Creates a AssetsProgressEvent
  55674. * @param remainingCount defines the number of remaining tasks to process
  55675. * @param totalCount defines the total number of tasks
  55676. * @param task defines the task that was just processed
  55677. */
  55678. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55679. }
  55680. /**
  55681. * Define a task used by AssetsManager to load meshes
  55682. */
  55683. export class MeshAssetTask extends AbstractAssetTask {
  55684. /**
  55685. * Defines the name of the task
  55686. */
  55687. name: string;
  55688. /**
  55689. * Defines the list of mesh's names you want to load
  55690. */
  55691. meshesNames: any;
  55692. /**
  55693. * Defines the root url to use as a base to load your meshes and associated resources
  55694. */
  55695. rootUrl: string;
  55696. /**
  55697. * Defines the filename of the scene to load from
  55698. */
  55699. sceneFilename: string;
  55700. /**
  55701. * Gets the list of loaded meshes
  55702. */
  55703. loadedMeshes: Array<AbstractMesh>;
  55704. /**
  55705. * Gets the list of loaded particle systems
  55706. */
  55707. loadedParticleSystems: Array<IParticleSystem>;
  55708. /**
  55709. * Gets the list of loaded skeletons
  55710. */
  55711. loadedSkeletons: Array<Skeleton>;
  55712. /**
  55713. * Gets the list of loaded animation groups
  55714. */
  55715. loadedAnimationGroups: Array<AnimationGroup>;
  55716. /**
  55717. * Callback called when the task is successful
  55718. */
  55719. onSuccess: (task: MeshAssetTask) => void;
  55720. /**
  55721. * Callback called when the task is successful
  55722. */
  55723. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55724. /**
  55725. * Creates a new MeshAssetTask
  55726. * @param name defines the name of the task
  55727. * @param meshesNames defines the list of mesh's names you want to load
  55728. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55729. * @param sceneFilename defines the filename of the scene to load from
  55730. */
  55731. constructor(
  55732. /**
  55733. * Defines the name of the task
  55734. */
  55735. name: string,
  55736. /**
  55737. * Defines the list of mesh's names you want to load
  55738. */
  55739. meshesNames: any,
  55740. /**
  55741. * Defines the root url to use as a base to load your meshes and associated resources
  55742. */
  55743. rootUrl: string,
  55744. /**
  55745. * Defines the filename of the scene to load from
  55746. */
  55747. sceneFilename: string);
  55748. /**
  55749. * Execute the current task
  55750. * @param scene defines the scene where you want your assets to be loaded
  55751. * @param onSuccess is a callback called when the task is successfully executed
  55752. * @param onError is a callback called if an error occurs
  55753. */
  55754. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55755. }
  55756. /**
  55757. * Define a task used by AssetsManager to load text content
  55758. */
  55759. export class TextFileAssetTask extends AbstractAssetTask {
  55760. /**
  55761. * Defines the name of the task
  55762. */
  55763. name: string;
  55764. /**
  55765. * Defines the location of the file to load
  55766. */
  55767. url: string;
  55768. /**
  55769. * Gets the loaded text string
  55770. */
  55771. text: string;
  55772. /**
  55773. * Callback called when the task is successful
  55774. */
  55775. onSuccess: (task: TextFileAssetTask) => void;
  55776. /**
  55777. * Callback called when the task is successful
  55778. */
  55779. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55780. /**
  55781. * Creates a new TextFileAssetTask object
  55782. * @param name defines the name of the task
  55783. * @param url defines the location of the file to load
  55784. */
  55785. constructor(
  55786. /**
  55787. * Defines the name of the task
  55788. */
  55789. name: string,
  55790. /**
  55791. * Defines the location of the file to load
  55792. */
  55793. url: string);
  55794. /**
  55795. * Execute the current task
  55796. * @param scene defines the scene where you want your assets to be loaded
  55797. * @param onSuccess is a callback called when the task is successfully executed
  55798. * @param onError is a callback called if an error occurs
  55799. */
  55800. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55801. }
  55802. /**
  55803. * Define a task used by AssetsManager to load binary data
  55804. */
  55805. export class BinaryFileAssetTask extends AbstractAssetTask {
  55806. /**
  55807. * Defines the name of the task
  55808. */
  55809. name: string;
  55810. /**
  55811. * Defines the location of the file to load
  55812. */
  55813. url: string;
  55814. /**
  55815. * Gets the lodaded data (as an array buffer)
  55816. */
  55817. data: ArrayBuffer;
  55818. /**
  55819. * Callback called when the task is successful
  55820. */
  55821. onSuccess: (task: BinaryFileAssetTask) => void;
  55822. /**
  55823. * Callback called when the task is successful
  55824. */
  55825. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55826. /**
  55827. * Creates a new BinaryFileAssetTask object
  55828. * @param name defines the name of the new task
  55829. * @param url defines the location of the file to load
  55830. */
  55831. constructor(
  55832. /**
  55833. * Defines the name of the task
  55834. */
  55835. name: string,
  55836. /**
  55837. * Defines the location of the file to load
  55838. */
  55839. url: string);
  55840. /**
  55841. * Execute the current task
  55842. * @param scene defines the scene where you want your assets to be loaded
  55843. * @param onSuccess is a callback called when the task is successfully executed
  55844. * @param onError is a callback called if an error occurs
  55845. */
  55846. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55847. }
  55848. /**
  55849. * Define a task used by AssetsManager to load images
  55850. */
  55851. export class ImageAssetTask extends AbstractAssetTask {
  55852. /**
  55853. * Defines the name of the task
  55854. */
  55855. name: string;
  55856. /**
  55857. * Defines the location of the image to load
  55858. */
  55859. url: string;
  55860. /**
  55861. * Gets the loaded images
  55862. */
  55863. image: HTMLImageElement;
  55864. /**
  55865. * Callback called when the task is successful
  55866. */
  55867. onSuccess: (task: ImageAssetTask) => void;
  55868. /**
  55869. * Callback called when the task is successful
  55870. */
  55871. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55872. /**
  55873. * Creates a new ImageAssetTask
  55874. * @param name defines the name of the task
  55875. * @param url defines the location of the image to load
  55876. */
  55877. constructor(
  55878. /**
  55879. * Defines the name of the task
  55880. */
  55881. name: string,
  55882. /**
  55883. * Defines the location of the image to load
  55884. */
  55885. url: string);
  55886. /**
  55887. * Execute the current task
  55888. * @param scene defines the scene where you want your assets to be loaded
  55889. * @param onSuccess is a callback called when the task is successfully executed
  55890. * @param onError is a callback called if an error occurs
  55891. */
  55892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55893. }
  55894. /**
  55895. * Defines the interface used by texture loading tasks
  55896. */
  55897. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55898. /**
  55899. * Gets the loaded texture
  55900. */
  55901. texture: TEX;
  55902. }
  55903. /**
  55904. * Define a task used by AssetsManager to load 2D textures
  55905. */
  55906. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55907. /**
  55908. * Defines the name of the task
  55909. */
  55910. name: string;
  55911. /**
  55912. * Defines the location of the file to load
  55913. */
  55914. url: string;
  55915. /**
  55916. * Defines if mipmap should not be generated (default is false)
  55917. */
  55918. noMipmap?: boolean | undefined;
  55919. /**
  55920. * Defines if texture must be inverted on Y axis (default is false)
  55921. */
  55922. invertY?: boolean | undefined;
  55923. /**
  55924. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55925. */
  55926. samplingMode: number;
  55927. /**
  55928. * Gets the loaded texture
  55929. */
  55930. texture: Texture;
  55931. /**
  55932. * Callback called when the task is successful
  55933. */
  55934. onSuccess: (task: TextureAssetTask) => void;
  55935. /**
  55936. * Callback called when the task is successful
  55937. */
  55938. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55939. /**
  55940. * Creates a new TextureAssetTask object
  55941. * @param name defines the name of the task
  55942. * @param url defines the location of the file to load
  55943. * @param noMipmap defines if mipmap should not be generated (default is false)
  55944. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55945. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55946. */
  55947. constructor(
  55948. /**
  55949. * Defines the name of the task
  55950. */
  55951. name: string,
  55952. /**
  55953. * Defines the location of the file to load
  55954. */
  55955. url: string,
  55956. /**
  55957. * Defines if mipmap should not be generated (default is false)
  55958. */
  55959. noMipmap?: boolean | undefined,
  55960. /**
  55961. * Defines if texture must be inverted on Y axis (default is false)
  55962. */
  55963. invertY?: boolean | undefined,
  55964. /**
  55965. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55966. */
  55967. samplingMode?: number);
  55968. /**
  55969. * Execute the current task
  55970. * @param scene defines the scene where you want your assets to be loaded
  55971. * @param onSuccess is a callback called when the task is successfully executed
  55972. * @param onError is a callback called if an error occurs
  55973. */
  55974. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55975. }
  55976. /**
  55977. * Define a task used by AssetsManager to load cube textures
  55978. */
  55979. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55980. /**
  55981. * Defines the name of the task
  55982. */
  55983. name: string;
  55984. /**
  55985. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55986. */
  55987. url: string;
  55988. /**
  55989. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55990. */
  55991. extensions?: string[] | undefined;
  55992. /**
  55993. * Defines if mipmaps should not be generated (default is false)
  55994. */
  55995. noMipmap?: boolean | undefined;
  55996. /**
  55997. * Defines the explicit list of files (undefined by default)
  55998. */
  55999. files?: string[] | undefined;
  56000. /**
  56001. * Gets the loaded texture
  56002. */
  56003. texture: CubeTexture;
  56004. /**
  56005. * Callback called when the task is successful
  56006. */
  56007. onSuccess: (task: CubeTextureAssetTask) => void;
  56008. /**
  56009. * Callback called when the task is successful
  56010. */
  56011. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56012. /**
  56013. * Creates a new CubeTextureAssetTask
  56014. * @param name defines the name of the task
  56015. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56016. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56017. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56018. * @param files defines the explicit list of files (undefined by default)
  56019. */
  56020. constructor(
  56021. /**
  56022. * Defines the name of the task
  56023. */
  56024. name: string,
  56025. /**
  56026. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56027. */
  56028. url: string,
  56029. /**
  56030. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56031. */
  56032. extensions?: string[] | undefined,
  56033. /**
  56034. * Defines if mipmaps should not be generated (default is false)
  56035. */
  56036. noMipmap?: boolean | undefined,
  56037. /**
  56038. * Defines the explicit list of files (undefined by default)
  56039. */
  56040. files?: string[] | undefined);
  56041. /**
  56042. * Execute the current task
  56043. * @param scene defines the scene where you want your assets to be loaded
  56044. * @param onSuccess is a callback called when the task is successfully executed
  56045. * @param onError is a callback called if an error occurs
  56046. */
  56047. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56048. }
  56049. /**
  56050. * Define a task used by AssetsManager to load HDR cube textures
  56051. */
  56052. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56053. /**
  56054. * Defines the name of the task
  56055. */
  56056. name: string;
  56057. /**
  56058. * Defines the location of the file to load
  56059. */
  56060. url: string;
  56061. /**
  56062. * Defines the desired size (the more it increases the longer the generation will be)
  56063. */
  56064. size: number;
  56065. /**
  56066. * Defines if mipmaps should not be generated (default is false)
  56067. */
  56068. noMipmap: boolean;
  56069. /**
  56070. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56071. */
  56072. generateHarmonics: boolean;
  56073. /**
  56074. * 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)
  56075. */
  56076. gammaSpace: boolean;
  56077. /**
  56078. * Internal Use Only
  56079. */
  56080. reserved: boolean;
  56081. /**
  56082. * Gets the loaded texture
  56083. */
  56084. texture: HDRCubeTexture;
  56085. /**
  56086. * Callback called when the task is successful
  56087. */
  56088. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56089. /**
  56090. * Callback called when the task is successful
  56091. */
  56092. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56093. /**
  56094. * Creates a new HDRCubeTextureAssetTask object
  56095. * @param name defines the name of the task
  56096. * @param url defines the location of the file to load
  56097. * @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.
  56098. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56099. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56100. * @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)
  56101. * @param reserved Internal use only
  56102. */
  56103. constructor(
  56104. /**
  56105. * Defines the name of the task
  56106. */
  56107. name: string,
  56108. /**
  56109. * Defines the location of the file to load
  56110. */
  56111. url: string,
  56112. /**
  56113. * Defines the desired size (the more it increases the longer the generation will be)
  56114. */
  56115. size: number,
  56116. /**
  56117. * Defines if mipmaps should not be generated (default is false)
  56118. */
  56119. noMipmap?: boolean,
  56120. /**
  56121. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56122. */
  56123. generateHarmonics?: boolean,
  56124. /**
  56125. * 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)
  56126. */
  56127. gammaSpace?: boolean,
  56128. /**
  56129. * Internal Use Only
  56130. */
  56131. reserved?: boolean);
  56132. /**
  56133. * Execute the current task
  56134. * @param scene defines the scene where you want your assets to be loaded
  56135. * @param onSuccess is a callback called when the task is successfully executed
  56136. * @param onError is a callback called if an error occurs
  56137. */
  56138. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56139. }
  56140. /**
  56141. * This class can be used to easily import assets into a scene
  56142. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56143. */
  56144. export class AssetsManager {
  56145. private _scene;
  56146. private _isLoading;
  56147. protected _tasks: AbstractAssetTask[];
  56148. protected _waitingTasksCount: number;
  56149. protected _totalTasksCount: number;
  56150. /**
  56151. * Callback called when all tasks are processed
  56152. */
  56153. onFinish: (tasks: AbstractAssetTask[]) => void;
  56154. /**
  56155. * Callback called when a task is successful
  56156. */
  56157. onTaskSuccess: (task: AbstractAssetTask) => void;
  56158. /**
  56159. * Callback called when a task had an error
  56160. */
  56161. onTaskError: (task: AbstractAssetTask) => void;
  56162. /**
  56163. * Callback called when a task is done (whatever the result is)
  56164. */
  56165. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56166. /**
  56167. * Observable called when all tasks are processed
  56168. */
  56169. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56170. /**
  56171. * Observable called when a task had an error
  56172. */
  56173. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56174. /**
  56175. * Observable called when a task is successful
  56176. */
  56177. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56178. /**
  56179. * Observable called when a task is done (whatever the result is)
  56180. */
  56181. onProgressObservable: Observable<IAssetsProgressEvent>;
  56182. /**
  56183. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56184. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56185. */
  56186. useDefaultLoadingScreen: boolean;
  56187. /**
  56188. * Creates a new AssetsManager
  56189. * @param scene defines the scene to work on
  56190. */
  56191. constructor(scene: Scene);
  56192. /**
  56193. * Add a MeshAssetTask to the list of active tasks
  56194. * @param taskName defines the name of the new task
  56195. * @param meshesNames defines the name of meshes to load
  56196. * @param rootUrl defines the root url to use to locate files
  56197. * @param sceneFilename defines the filename of the scene file
  56198. * @returns a new MeshAssetTask object
  56199. */
  56200. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56201. /**
  56202. * Add a TextFileAssetTask to the list of active tasks
  56203. * @param taskName defines the name of the new task
  56204. * @param url defines the url of the file to load
  56205. * @returns a new TextFileAssetTask object
  56206. */
  56207. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56208. /**
  56209. * Add a BinaryFileAssetTask to the list of active tasks
  56210. * @param taskName defines the name of the new task
  56211. * @param url defines the url of the file to load
  56212. * @returns a new BinaryFileAssetTask object
  56213. */
  56214. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56215. /**
  56216. * Add a ImageAssetTask to the list of active tasks
  56217. * @param taskName defines the name of the new task
  56218. * @param url defines the url of the file to load
  56219. * @returns a new ImageAssetTask object
  56220. */
  56221. addImageTask(taskName: string, url: string): ImageAssetTask;
  56222. /**
  56223. * Add a TextureAssetTask to the list of active tasks
  56224. * @param taskName defines the name of the new task
  56225. * @param url defines the url of the file to load
  56226. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56227. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56228. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56229. * @returns a new TextureAssetTask object
  56230. */
  56231. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56232. /**
  56233. * Add a CubeTextureAssetTask to the list of active tasks
  56234. * @param taskName defines the name of the new task
  56235. * @param url defines the url of the file to load
  56236. * @param extensions defines the extension to use to load the cube map (can be null)
  56237. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56238. * @param files defines the list of files to load (can be null)
  56239. * @returns a new CubeTextureAssetTask object
  56240. */
  56241. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56242. /**
  56243. *
  56244. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56245. * @param taskName defines the name of the new task
  56246. * @param url defines the url of the file to load
  56247. * @param size defines the size you want for the cubemap (can be null)
  56248. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56249. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56250. * @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)
  56251. * @param reserved Internal use only
  56252. * @returns a new HDRCubeTextureAssetTask object
  56253. */
  56254. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56255. /**
  56256. * Remove a task from the assets manager.
  56257. * @param task the task to remove
  56258. */
  56259. removeTask(task: AbstractAssetTask): void;
  56260. private _decreaseWaitingTasksCount;
  56261. private _runTask;
  56262. /**
  56263. * Reset the AssetsManager and remove all tasks
  56264. * @return the current instance of the AssetsManager
  56265. */
  56266. reset(): AssetsManager;
  56267. /**
  56268. * Start the loading process
  56269. * @return the current instance of the AssetsManager
  56270. */
  56271. load(): AssetsManager;
  56272. }
  56273. }
  56274. declare module "babylonjs/Misc/deferred" {
  56275. /**
  56276. * Wrapper class for promise with external resolve and reject.
  56277. */
  56278. export class Deferred<T> {
  56279. /**
  56280. * The promise associated with this deferred object.
  56281. */
  56282. readonly promise: Promise<T>;
  56283. private _resolve;
  56284. private _reject;
  56285. /**
  56286. * The resolve method of the promise associated with this deferred object.
  56287. */
  56288. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56289. /**
  56290. * The reject method of the promise associated with this deferred object.
  56291. */
  56292. readonly reject: (reason?: any) => void;
  56293. /**
  56294. * Constructor for this deferred object.
  56295. */
  56296. constructor();
  56297. }
  56298. }
  56299. declare module "babylonjs/Misc/filesInput" {
  56300. import { Engine } from "babylonjs/Engines/engine";
  56301. import { Scene } from "babylonjs/scene";
  56302. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56303. /**
  56304. * Class used to help managing file picking and drag'n'drop
  56305. */
  56306. export class FilesInput {
  56307. /**
  56308. * List of files ready to be loaded
  56309. */
  56310. static readonly FilesToLoad: {
  56311. [key: string]: File;
  56312. };
  56313. /**
  56314. * Callback called when a file is processed
  56315. */
  56316. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56317. private _engine;
  56318. private _currentScene;
  56319. private _sceneLoadedCallback;
  56320. private _progressCallback;
  56321. private _additionalRenderLoopLogicCallback;
  56322. private _textureLoadingCallback;
  56323. private _startingProcessingFilesCallback;
  56324. private _onReloadCallback;
  56325. private _errorCallback;
  56326. private _elementToMonitor;
  56327. private _sceneFileToLoad;
  56328. private _filesToLoad;
  56329. /**
  56330. * Creates a new FilesInput
  56331. * @param engine defines the rendering engine
  56332. * @param scene defines the hosting scene
  56333. * @param sceneLoadedCallback callback called when scene is loaded
  56334. * @param progressCallback callback called to track progress
  56335. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56336. * @param textureLoadingCallback callback called when a texture is loading
  56337. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56338. * @param onReloadCallback callback called when a reload is requested
  56339. * @param errorCallback callback call if an error occurs
  56340. */
  56341. 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);
  56342. private _dragEnterHandler;
  56343. private _dragOverHandler;
  56344. private _dropHandler;
  56345. /**
  56346. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56347. * @param elementToMonitor defines the DOM element to track
  56348. */
  56349. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56350. /**
  56351. * Release all associated resources
  56352. */
  56353. dispose(): void;
  56354. private renderFunction;
  56355. private drag;
  56356. private drop;
  56357. private _traverseFolder;
  56358. private _processFiles;
  56359. /**
  56360. * Load files from a drop event
  56361. * @param event defines the drop event to use as source
  56362. */
  56363. loadFiles(event: any): void;
  56364. private _processReload;
  56365. /**
  56366. * Reload the current scene from the loaded files
  56367. */
  56368. reload(): void;
  56369. }
  56370. }
  56371. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56372. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56373. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56374. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56375. }
  56376. declare module "babylonjs/Misc/sceneOptimizer" {
  56377. import { Scene, IDisposable } from "babylonjs/scene";
  56378. import { Observable } from "babylonjs/Misc/observable";
  56379. /**
  56380. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56382. */
  56383. export class SceneOptimization {
  56384. /**
  56385. * Defines the priority of this optimization (0 by default which means first in the list)
  56386. */
  56387. priority: number;
  56388. /**
  56389. * Gets a string describing the action executed by the current optimization
  56390. * @returns description string
  56391. */
  56392. getDescription(): string;
  56393. /**
  56394. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56395. * @param scene defines the current scene where to apply this optimization
  56396. * @param optimizer defines the current optimizer
  56397. * @returns true if everything that can be done was applied
  56398. */
  56399. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56400. /**
  56401. * Creates the SceneOptimization object
  56402. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56403. * @param desc defines the description associated with the optimization
  56404. */
  56405. constructor(
  56406. /**
  56407. * Defines the priority of this optimization (0 by default which means first in the list)
  56408. */
  56409. priority?: number);
  56410. }
  56411. /**
  56412. * Defines an optimization used to reduce the size of render target textures
  56413. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56414. */
  56415. export class TextureOptimization extends SceneOptimization {
  56416. /**
  56417. * Defines the priority of this optimization (0 by default which means first in the list)
  56418. */
  56419. priority: number;
  56420. /**
  56421. * 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
  56422. */
  56423. maximumSize: number;
  56424. /**
  56425. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56426. */
  56427. step: number;
  56428. /**
  56429. * Gets a string describing the action executed by the current optimization
  56430. * @returns description string
  56431. */
  56432. getDescription(): string;
  56433. /**
  56434. * Creates the TextureOptimization object
  56435. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56436. * @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
  56437. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56438. */
  56439. constructor(
  56440. /**
  56441. * Defines the priority of this optimization (0 by default which means first in the list)
  56442. */
  56443. priority?: number,
  56444. /**
  56445. * 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
  56446. */
  56447. maximumSize?: number,
  56448. /**
  56449. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56450. */
  56451. step?: number);
  56452. /**
  56453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56454. * @param scene defines the current scene where to apply this optimization
  56455. * @param optimizer defines the current optimizer
  56456. * @returns true if everything that can be done was applied
  56457. */
  56458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56459. }
  56460. /**
  56461. * Defines an optimization used to increase or decrease the rendering resolution
  56462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56463. */
  56464. export class HardwareScalingOptimization extends SceneOptimization {
  56465. /**
  56466. * Defines the priority of this optimization (0 by default which means first in the list)
  56467. */
  56468. priority: number;
  56469. /**
  56470. * Defines the maximum scale to use (2 by default)
  56471. */
  56472. maximumScale: number;
  56473. /**
  56474. * Defines the step to use between two passes (0.5 by default)
  56475. */
  56476. step: number;
  56477. private _currentScale;
  56478. private _directionOffset;
  56479. /**
  56480. * Gets a string describing the action executed by the current optimization
  56481. * @return description string
  56482. */
  56483. getDescription(): string;
  56484. /**
  56485. * Creates the HardwareScalingOptimization object
  56486. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56487. * @param maximumScale defines the maximum scale to use (2 by default)
  56488. * @param step defines the step to use between two passes (0.5 by default)
  56489. */
  56490. constructor(
  56491. /**
  56492. * Defines the priority of this optimization (0 by default which means first in the list)
  56493. */
  56494. priority?: number,
  56495. /**
  56496. * Defines the maximum scale to use (2 by default)
  56497. */
  56498. maximumScale?: number,
  56499. /**
  56500. * Defines the step to use between two passes (0.5 by default)
  56501. */
  56502. step?: number);
  56503. /**
  56504. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56505. * @param scene defines the current scene where to apply this optimization
  56506. * @param optimizer defines the current optimizer
  56507. * @returns true if everything that can be done was applied
  56508. */
  56509. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56510. }
  56511. /**
  56512. * Defines an optimization used to remove shadows
  56513. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56514. */
  56515. export class ShadowsOptimization extends SceneOptimization {
  56516. /**
  56517. * Gets a string describing the action executed by the current optimization
  56518. * @return description string
  56519. */
  56520. getDescription(): string;
  56521. /**
  56522. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56523. * @param scene defines the current scene where to apply this optimization
  56524. * @param optimizer defines the current optimizer
  56525. * @returns true if everything that can be done was applied
  56526. */
  56527. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56528. }
  56529. /**
  56530. * Defines an optimization used to turn post-processes off
  56531. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56532. */
  56533. export class PostProcessesOptimization extends SceneOptimization {
  56534. /**
  56535. * Gets a string describing the action executed by the current optimization
  56536. * @return description string
  56537. */
  56538. getDescription(): string;
  56539. /**
  56540. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56541. * @param scene defines the current scene where to apply this optimization
  56542. * @param optimizer defines the current optimizer
  56543. * @returns true if everything that can be done was applied
  56544. */
  56545. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56546. }
  56547. /**
  56548. * Defines an optimization used to turn lens flares off
  56549. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56550. */
  56551. export class LensFlaresOptimization extends SceneOptimization {
  56552. /**
  56553. * Gets a string describing the action executed by the current optimization
  56554. * @return description string
  56555. */
  56556. getDescription(): string;
  56557. /**
  56558. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56559. * @param scene defines the current scene where to apply this optimization
  56560. * @param optimizer defines the current optimizer
  56561. * @returns true if everything that can be done was applied
  56562. */
  56563. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56564. }
  56565. /**
  56566. * Defines an optimization based on user defined callback.
  56567. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56568. */
  56569. export class CustomOptimization extends SceneOptimization {
  56570. /**
  56571. * Callback called to apply the custom optimization.
  56572. */
  56573. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56574. /**
  56575. * Callback called to get custom description
  56576. */
  56577. onGetDescription: () => string;
  56578. /**
  56579. * Gets a string describing the action executed by the current optimization
  56580. * @returns description string
  56581. */
  56582. getDescription(): string;
  56583. /**
  56584. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56585. * @param scene defines the current scene where to apply this optimization
  56586. * @param optimizer defines the current optimizer
  56587. * @returns true if everything that can be done was applied
  56588. */
  56589. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56590. }
  56591. /**
  56592. * Defines an optimization used to turn particles off
  56593. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56594. */
  56595. export class ParticlesOptimization extends SceneOptimization {
  56596. /**
  56597. * Gets a string describing the action executed by the current optimization
  56598. * @return description string
  56599. */
  56600. getDescription(): string;
  56601. /**
  56602. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56603. * @param scene defines the current scene where to apply this optimization
  56604. * @param optimizer defines the current optimizer
  56605. * @returns true if everything that can be done was applied
  56606. */
  56607. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56608. }
  56609. /**
  56610. * Defines an optimization used to turn render targets off
  56611. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56612. */
  56613. export class RenderTargetsOptimization extends SceneOptimization {
  56614. /**
  56615. * Gets a string describing the action executed by the current optimization
  56616. * @return description string
  56617. */
  56618. getDescription(): string;
  56619. /**
  56620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56621. * @param scene defines the current scene where to apply this optimization
  56622. * @param optimizer defines the current optimizer
  56623. * @returns true if everything that can be done was applied
  56624. */
  56625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56626. }
  56627. /**
  56628. * Defines an optimization used to merge meshes with compatible materials
  56629. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56630. */
  56631. export class MergeMeshesOptimization extends SceneOptimization {
  56632. private static _UpdateSelectionTree;
  56633. /**
  56634. * Gets or sets a boolean which defines if optimization octree has to be updated
  56635. */
  56636. /**
  56637. * Gets or sets a boolean which defines if optimization octree has to be updated
  56638. */
  56639. static UpdateSelectionTree: boolean;
  56640. /**
  56641. * Gets a string describing the action executed by the current optimization
  56642. * @return description string
  56643. */
  56644. getDescription(): string;
  56645. private _canBeMerged;
  56646. /**
  56647. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56648. * @param scene defines the current scene where to apply this optimization
  56649. * @param optimizer defines the current optimizer
  56650. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56651. * @returns true if everything that can be done was applied
  56652. */
  56653. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56654. }
  56655. /**
  56656. * Defines a list of options used by SceneOptimizer
  56657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56658. */
  56659. export class SceneOptimizerOptions {
  56660. /**
  56661. * Defines the target frame rate to reach (60 by default)
  56662. */
  56663. targetFrameRate: number;
  56664. /**
  56665. * Defines the interval between two checkes (2000ms by default)
  56666. */
  56667. trackerDuration: number;
  56668. /**
  56669. * Gets the list of optimizations to apply
  56670. */
  56671. optimizations: SceneOptimization[];
  56672. /**
  56673. * Creates a new list of options used by SceneOptimizer
  56674. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56675. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56676. */
  56677. constructor(
  56678. /**
  56679. * Defines the target frame rate to reach (60 by default)
  56680. */
  56681. targetFrameRate?: number,
  56682. /**
  56683. * Defines the interval between two checkes (2000ms by default)
  56684. */
  56685. trackerDuration?: number);
  56686. /**
  56687. * Add a new optimization
  56688. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56689. * @returns the current SceneOptimizerOptions
  56690. */
  56691. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56692. /**
  56693. * Add a new custom optimization
  56694. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56695. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56696. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56697. * @returns the current SceneOptimizerOptions
  56698. */
  56699. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56700. /**
  56701. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56702. * @param targetFrameRate defines the target frame rate (60 by default)
  56703. * @returns a SceneOptimizerOptions object
  56704. */
  56705. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56706. /**
  56707. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56708. * @param targetFrameRate defines the target frame rate (60 by default)
  56709. * @returns a SceneOptimizerOptions object
  56710. */
  56711. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56712. /**
  56713. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56714. * @param targetFrameRate defines the target frame rate (60 by default)
  56715. * @returns a SceneOptimizerOptions object
  56716. */
  56717. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56718. }
  56719. /**
  56720. * Class used to run optimizations in order to reach a target frame rate
  56721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56722. */
  56723. export class SceneOptimizer implements IDisposable {
  56724. private _isRunning;
  56725. private _options;
  56726. private _scene;
  56727. private _currentPriorityLevel;
  56728. private _targetFrameRate;
  56729. private _trackerDuration;
  56730. private _currentFrameRate;
  56731. private _sceneDisposeObserver;
  56732. private _improvementMode;
  56733. /**
  56734. * Defines an observable called when the optimizer reaches the target frame rate
  56735. */
  56736. onSuccessObservable: Observable<SceneOptimizer>;
  56737. /**
  56738. * Defines an observable called when the optimizer enables an optimization
  56739. */
  56740. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56741. /**
  56742. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56743. */
  56744. onFailureObservable: Observable<SceneOptimizer>;
  56745. /**
  56746. * Gets a boolean indicating if the optimizer is in improvement mode
  56747. */
  56748. readonly isInImprovementMode: boolean;
  56749. /**
  56750. * Gets the current priority level (0 at start)
  56751. */
  56752. readonly currentPriorityLevel: number;
  56753. /**
  56754. * Gets the current frame rate checked by the SceneOptimizer
  56755. */
  56756. readonly currentFrameRate: number;
  56757. /**
  56758. * Gets or sets the current target frame rate (60 by default)
  56759. */
  56760. /**
  56761. * Gets or sets the current target frame rate (60 by default)
  56762. */
  56763. targetFrameRate: number;
  56764. /**
  56765. * Gets or sets the current interval between two checks (every 2000ms by default)
  56766. */
  56767. /**
  56768. * Gets or sets the current interval between two checks (every 2000ms by default)
  56769. */
  56770. trackerDuration: number;
  56771. /**
  56772. * Gets the list of active optimizations
  56773. */
  56774. readonly optimizations: SceneOptimization[];
  56775. /**
  56776. * Creates a new SceneOptimizer
  56777. * @param scene defines the scene to work on
  56778. * @param options defines the options to use with the SceneOptimizer
  56779. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56780. * @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)
  56781. */
  56782. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56783. /**
  56784. * Stops the current optimizer
  56785. */
  56786. stop(): void;
  56787. /**
  56788. * Reset the optimizer to initial step (current priority level = 0)
  56789. */
  56790. reset(): void;
  56791. /**
  56792. * Start the optimizer. By default it will try to reach a specific framerate
  56793. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56794. */
  56795. start(): void;
  56796. private _checkCurrentState;
  56797. /**
  56798. * Release all resources
  56799. */
  56800. dispose(): void;
  56801. /**
  56802. * Helper function to create a SceneOptimizer with one single line of code
  56803. * @param scene defines the scene to work on
  56804. * @param options defines the options to use with the SceneOptimizer
  56805. * @param onSuccess defines a callback to call on success
  56806. * @param onFailure defines a callback to call on failure
  56807. * @returns the new SceneOptimizer object
  56808. */
  56809. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56810. }
  56811. }
  56812. declare module "babylonjs/Misc/sceneSerializer" {
  56813. import { Scene } from "babylonjs/scene";
  56814. /**
  56815. * Class used to serialize a scene into a string
  56816. */
  56817. export class SceneSerializer {
  56818. /**
  56819. * Clear cache used by a previous serialization
  56820. */
  56821. static ClearCache(): void;
  56822. /**
  56823. * Serialize a scene into a JSON compatible object
  56824. * @param scene defines the scene to serialize
  56825. * @returns a JSON compatible object
  56826. */
  56827. static Serialize(scene: Scene): any;
  56828. /**
  56829. * Serialize a mesh into a JSON compatible object
  56830. * @param toSerialize defines the mesh to serialize
  56831. * @param withParents defines if parents must be serialized as well
  56832. * @param withChildren defines if children must be serialized as well
  56833. * @returns a JSON compatible object
  56834. */
  56835. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56836. }
  56837. }
  56838. declare module "babylonjs/Misc/videoRecorder" {
  56839. import { Nullable } from "babylonjs/types";
  56840. import { Engine } from "babylonjs/Engines/engine";
  56841. /**
  56842. * This represents the different options avilable for the video capture.
  56843. */
  56844. export interface VideoRecorderOptions {
  56845. /** Defines the mime type of the video */
  56846. mimeType: string;
  56847. /** Defines the video the video should be recorded at */
  56848. fps: number;
  56849. /** Defines the chunk size for the recording data */
  56850. recordChunckSize: number;
  56851. /** The audio tracks to attach to the record */
  56852. audioTracks?: MediaStreamTrack[];
  56853. }
  56854. /**
  56855. * This can helps recording videos from BabylonJS.
  56856. * This is based on the available WebRTC functionalities of the browser.
  56857. *
  56858. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56859. */
  56860. export class VideoRecorder {
  56861. private static readonly _defaultOptions;
  56862. /**
  56863. * Returns wehther or not the VideoRecorder is available in your browser.
  56864. * @param engine Defines the Babylon Engine to check the support for
  56865. * @returns true if supported otherwise false
  56866. */
  56867. static IsSupported(engine: Engine): boolean;
  56868. private readonly _options;
  56869. private _canvas;
  56870. private _mediaRecorder;
  56871. private _recordedChunks;
  56872. private _fileName;
  56873. private _resolve;
  56874. private _reject;
  56875. /**
  56876. * True wether a recording is already in progress.
  56877. */
  56878. readonly isRecording: boolean;
  56879. /**
  56880. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56881. * a video file.
  56882. * @param engine Defines the BabylonJS Engine you wish to record
  56883. * @param options Defines options that can be used to customized the capture
  56884. */
  56885. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56886. /**
  56887. * Stops the current recording before the default capture timeout passed in the startRecording
  56888. * functions.
  56889. */
  56890. stopRecording(): void;
  56891. /**
  56892. * Starts recording the canvas for a max duration specified in parameters.
  56893. * @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.
  56894. * @param maxDuration Defines the maximum recording time in seconds.
  56895. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56896. * @return a promise callback at the end of the recording with the video data in Blob.
  56897. */
  56898. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56899. /**
  56900. * Releases internal resources used during the recording.
  56901. */
  56902. dispose(): void;
  56903. private _handleDataAvailable;
  56904. private _handleError;
  56905. private _handleStop;
  56906. }
  56907. }
  56908. declare module "babylonjs/Misc/workerPool" {
  56909. import { IDisposable } from "babylonjs/scene";
  56910. /**
  56911. * Helper class to push actions to a pool of workers.
  56912. */
  56913. export class WorkerPool implements IDisposable {
  56914. private _workerInfos;
  56915. private _pendingActions;
  56916. /**
  56917. * Constructor
  56918. * @param workers Array of workers to use for actions
  56919. */
  56920. constructor(workers: Array<Worker>);
  56921. /**
  56922. * Terminates all workers and clears any pending actions.
  56923. */
  56924. dispose(): void;
  56925. /**
  56926. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56927. * pended until a worker has completed its action.
  56928. * @param action The action to perform. Call onComplete when the action is complete.
  56929. */
  56930. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56931. private _execute;
  56932. }
  56933. }
  56934. declare module "babylonjs/Misc/screenshotTools" {
  56935. import { Camera } from "babylonjs/Cameras/camera";
  56936. import { Engine } from "babylonjs/Engines/engine";
  56937. /**
  56938. * Class containing a set of static utilities functions for screenshots
  56939. */
  56940. export class ScreenshotTools {
  56941. /**
  56942. * Captures a screenshot of the current rendering
  56943. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56944. * @param engine defines the rendering engine
  56945. * @param camera defines the source camera
  56946. * @param size This parameter can be set to a single number or to an object with the
  56947. * following (optional) properties: precision, width, height. If a single number is passed,
  56948. * it will be used for both width and height. If an object is passed, the screenshot size
  56949. * will be derived from the parameters. The precision property is a multiplier allowing
  56950. * rendering at a higher or lower resolution
  56951. * @param successCallback defines the callback receives a single parameter which contains the
  56952. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56953. * src parameter of an <img> to display it
  56954. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56955. * Check your browser for supported MIME types
  56956. */
  56957. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56958. /**
  56959. * Generates an image screenshot from the specified camera.
  56960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56961. * @param engine The engine to use for rendering
  56962. * @param camera The camera to use for rendering
  56963. * @param size This parameter can be set to a single number or to an object with the
  56964. * following (optional) properties: precision, width, height. If a single number is passed,
  56965. * it will be used for both width and height. If an object is passed, the screenshot size
  56966. * will be derived from the parameters. The precision property is a multiplier allowing
  56967. * rendering at a higher or lower resolution
  56968. * @param successCallback The callback receives a single parameter which contains the
  56969. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56970. * src parameter of an <img> to display it
  56971. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56972. * Check your browser for supported MIME types
  56973. * @param samples Texture samples (default: 1)
  56974. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56975. * @param fileName A name for for the downloaded file.
  56976. */
  56977. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56978. }
  56979. }
  56980. declare module "babylonjs/Misc/index" {
  56981. export * from "babylonjs/Misc/andOrNotEvaluator";
  56982. export * from "babylonjs/Misc/assetsManager";
  56983. export * from "babylonjs/Misc/dds";
  56984. export * from "babylonjs/Misc/decorators";
  56985. export * from "babylonjs/Misc/deferred";
  56986. export * from "babylonjs/Misc/environmentTextureTools";
  56987. export * from "babylonjs/Misc/filesInput";
  56988. export * from "babylonjs/Misc/HighDynamicRange/index";
  56989. export * from "babylonjs/Misc/khronosTextureContainer";
  56990. export * from "babylonjs/Misc/observable";
  56991. export * from "babylonjs/Misc/performanceMonitor";
  56992. export * from "babylonjs/Misc/promise";
  56993. export * from "babylonjs/Misc/sceneOptimizer";
  56994. export * from "babylonjs/Misc/sceneSerializer";
  56995. export * from "babylonjs/Misc/smartArray";
  56996. export * from "babylonjs/Misc/stringDictionary";
  56997. export * from "babylonjs/Misc/tags";
  56998. export * from "babylonjs/Misc/textureTools";
  56999. export * from "babylonjs/Misc/tga";
  57000. export * from "babylonjs/Misc/tools";
  57001. export * from "babylonjs/Misc/videoRecorder";
  57002. export * from "babylonjs/Misc/virtualJoystick";
  57003. export * from "babylonjs/Misc/workerPool";
  57004. export * from "babylonjs/Misc/logger";
  57005. export * from "babylonjs/Misc/typeStore";
  57006. export * from "babylonjs/Misc/filesInputStore";
  57007. export * from "babylonjs/Misc/deepCopier";
  57008. export * from "babylonjs/Misc/pivotTools";
  57009. export * from "babylonjs/Misc/precisionDate";
  57010. export * from "babylonjs/Misc/screenshotTools";
  57011. export * from "babylonjs/Misc/typeStore";
  57012. }
  57013. declare module "babylonjs/index" {
  57014. export * from "babylonjs/abstractScene";
  57015. export * from "babylonjs/Actions/index";
  57016. export * from "babylonjs/Animations/index";
  57017. export * from "babylonjs/assetContainer";
  57018. export * from "babylonjs/Audio/index";
  57019. export * from "babylonjs/Behaviors/index";
  57020. export * from "babylonjs/Bones/index";
  57021. export * from "babylonjs/Cameras/index";
  57022. export * from "babylonjs/Collisions/index";
  57023. export * from "babylonjs/Culling/index";
  57024. export * from "babylonjs/Debug/index";
  57025. export * from "babylonjs/Engines/index";
  57026. export * from "babylonjs/Events/index";
  57027. export * from "babylonjs/Gamepads/index";
  57028. export * from "babylonjs/Gizmos/index";
  57029. export * from "babylonjs/Helpers/index";
  57030. export * from "babylonjs/Instrumentation/index";
  57031. export * from "babylonjs/Layers/index";
  57032. export * from "babylonjs/LensFlares/index";
  57033. export * from "babylonjs/Lights/index";
  57034. export * from "babylonjs/Loading/index";
  57035. export * from "babylonjs/Materials/index";
  57036. export * from "babylonjs/Maths/index";
  57037. export * from "babylonjs/Meshes/index";
  57038. export * from "babylonjs/Morph/index";
  57039. export * from "babylonjs/node";
  57040. export * from "babylonjs/Offline/index";
  57041. export * from "babylonjs/Particles/index";
  57042. export * from "babylonjs/Physics/index";
  57043. export * from "babylonjs/PostProcesses/index";
  57044. export * from "babylonjs/Probes/index";
  57045. export * from "babylonjs/Rendering/index";
  57046. export * from "babylonjs/scene";
  57047. export * from "babylonjs/sceneComponent";
  57048. export * from "babylonjs/Sprites/index";
  57049. export * from "babylonjs/States/index";
  57050. export * from "babylonjs/Misc/index";
  57051. export * from "babylonjs/types";
  57052. }
  57053. declare module "babylonjs/Animations/pathCursor" {
  57054. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57055. /**
  57056. * A cursor which tracks a point on a path
  57057. */
  57058. export class PathCursor {
  57059. private path;
  57060. /**
  57061. * Stores path cursor callbacks for when an onchange event is triggered
  57062. */
  57063. private _onchange;
  57064. /**
  57065. * The value of the path cursor
  57066. */
  57067. value: number;
  57068. /**
  57069. * The animation array of the path cursor
  57070. */
  57071. animations: Animation[];
  57072. /**
  57073. * Initializes the path cursor
  57074. * @param path The path to track
  57075. */
  57076. constructor(path: Path2);
  57077. /**
  57078. * Gets the cursor point on the path
  57079. * @returns A point on the path cursor at the cursor location
  57080. */
  57081. getPoint(): Vector3;
  57082. /**
  57083. * Moves the cursor ahead by the step amount
  57084. * @param step The amount to move the cursor forward
  57085. * @returns This path cursor
  57086. */
  57087. moveAhead(step?: number): PathCursor;
  57088. /**
  57089. * Moves the cursor behind by the step amount
  57090. * @param step The amount to move the cursor back
  57091. * @returns This path cursor
  57092. */
  57093. moveBack(step?: number): PathCursor;
  57094. /**
  57095. * Moves the cursor by the step amount
  57096. * If the step amount is greater than one, an exception is thrown
  57097. * @param step The amount to move the cursor
  57098. * @returns This path cursor
  57099. */
  57100. move(step: number): PathCursor;
  57101. /**
  57102. * Ensures that the value is limited between zero and one
  57103. * @returns This path cursor
  57104. */
  57105. private ensureLimits;
  57106. /**
  57107. * Runs onchange callbacks on change (used by the animation engine)
  57108. * @returns This path cursor
  57109. */
  57110. private raiseOnChange;
  57111. /**
  57112. * Executes a function on change
  57113. * @param f A path cursor onchange callback
  57114. * @returns This path cursor
  57115. */
  57116. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57117. }
  57118. }
  57119. declare module "babylonjs/Legacy/legacy" {
  57120. import * as Babylon from "babylonjs/index";
  57121. export * from "babylonjs/index";
  57122. }
  57123. declare module "babylonjs/Shaders/blur.fragment" {
  57124. /** @hidden */
  57125. export var blurPixelShader: {
  57126. name: string;
  57127. shader: string;
  57128. };
  57129. }
  57130. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57131. /** @hidden */
  57132. export var bones300Declaration: {
  57133. name: string;
  57134. shader: string;
  57135. };
  57136. }
  57137. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57138. /** @hidden */
  57139. export var instances300Declaration: {
  57140. name: string;
  57141. shader: string;
  57142. };
  57143. }
  57144. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57145. /** @hidden */
  57146. export var pointCloudVertexDeclaration: {
  57147. name: string;
  57148. shader: string;
  57149. };
  57150. }
  57151. // Mixins
  57152. interface Window {
  57153. mozIndexedDB: IDBFactory;
  57154. webkitIndexedDB: IDBFactory;
  57155. msIndexedDB: IDBFactory;
  57156. webkitURL: typeof URL;
  57157. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57158. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57159. WebGLRenderingContext: WebGLRenderingContext;
  57160. MSGesture: MSGesture;
  57161. CANNON: any;
  57162. AudioContext: AudioContext;
  57163. webkitAudioContext: AudioContext;
  57164. PointerEvent: any;
  57165. Math: Math;
  57166. Uint8Array: Uint8ArrayConstructor;
  57167. Float32Array: Float32ArrayConstructor;
  57168. mozURL: typeof URL;
  57169. msURL: typeof URL;
  57170. VRFrameData: any; // WebVR, from specs 1.1
  57171. DracoDecoderModule: any;
  57172. setImmediate(handler: (...args: any[]) => void): number;
  57173. }
  57174. interface HTMLCanvasElement {
  57175. requestPointerLock(): void;
  57176. msRequestPointerLock?(): void;
  57177. mozRequestPointerLock?(): void;
  57178. webkitRequestPointerLock?(): void;
  57179. /** Track wether a record is in progress */
  57180. isRecording: boolean;
  57181. /** Capture Stream method defined by some browsers */
  57182. captureStream(fps?: number): MediaStream;
  57183. }
  57184. interface CanvasRenderingContext2D {
  57185. msImageSmoothingEnabled: boolean;
  57186. }
  57187. interface MouseEvent {
  57188. mozMovementX: number;
  57189. mozMovementY: number;
  57190. webkitMovementX: number;
  57191. webkitMovementY: number;
  57192. msMovementX: number;
  57193. msMovementY: number;
  57194. }
  57195. interface Navigator {
  57196. mozGetVRDevices: (any: any) => any;
  57197. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57198. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57199. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57200. webkitGetGamepads(): Gamepad[];
  57201. msGetGamepads(): Gamepad[];
  57202. webkitGamepads(): Gamepad[];
  57203. }
  57204. interface HTMLVideoElement {
  57205. mozSrcObject: any;
  57206. }
  57207. interface Math {
  57208. fround(x: number): number;
  57209. imul(a: number, b: number): number;
  57210. }
  57211. interface WebGLProgram {
  57212. context?: WebGLRenderingContext;
  57213. vertexShader?: WebGLShader;
  57214. fragmentShader?: WebGLShader;
  57215. isParallelCompiled: boolean;
  57216. onCompiled?: () => void;
  57217. }
  57218. interface WebGLRenderingContext {
  57219. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57220. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57221. vertexAttribDivisor(index: number, divisor: number): void;
  57222. createVertexArray(): any;
  57223. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57224. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57225. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57226. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57227. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57228. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57229. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57230. // Queries
  57231. createQuery(): WebGLQuery;
  57232. deleteQuery(query: WebGLQuery): void;
  57233. beginQuery(target: number, query: WebGLQuery): void;
  57234. endQuery(target: number): void;
  57235. getQueryParameter(query: WebGLQuery, pname: number): any;
  57236. getQuery(target: number, pname: number): any;
  57237. MAX_SAMPLES: number;
  57238. RGBA8: number;
  57239. READ_FRAMEBUFFER: number;
  57240. DRAW_FRAMEBUFFER: number;
  57241. UNIFORM_BUFFER: number;
  57242. HALF_FLOAT_OES: number;
  57243. RGBA16F: number;
  57244. RGBA32F: number;
  57245. R32F: number;
  57246. RG32F: number;
  57247. RGB32F: number;
  57248. R16F: number;
  57249. RG16F: number;
  57250. RGB16F: number;
  57251. RED: number;
  57252. RG: number;
  57253. R8: number;
  57254. RG8: number;
  57255. UNSIGNED_INT_24_8: number;
  57256. DEPTH24_STENCIL8: number;
  57257. /* Multiple Render Targets */
  57258. drawBuffers(buffers: number[]): void;
  57259. readBuffer(src: number): void;
  57260. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57261. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57262. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57263. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57264. // Occlusion Query
  57265. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57266. ANY_SAMPLES_PASSED: number;
  57267. QUERY_RESULT_AVAILABLE: number;
  57268. QUERY_RESULT: number;
  57269. }
  57270. interface WebGLBuffer {
  57271. references: number;
  57272. capacity: number;
  57273. is32Bits: boolean;
  57274. }
  57275. interface WebGLProgram {
  57276. transformFeedback?: WebGLTransformFeedback | null;
  57277. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57278. }
  57279. interface EXT_disjoint_timer_query {
  57280. QUERY_COUNTER_BITS_EXT: number;
  57281. TIME_ELAPSED_EXT: number;
  57282. TIMESTAMP_EXT: number;
  57283. GPU_DISJOINT_EXT: number;
  57284. QUERY_RESULT_EXT: number;
  57285. QUERY_RESULT_AVAILABLE_EXT: number;
  57286. queryCounterEXT(query: WebGLQuery, target: number): void;
  57287. createQueryEXT(): WebGLQuery;
  57288. beginQueryEXT(target: number, query: WebGLQuery): void;
  57289. endQueryEXT(target: number): void;
  57290. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57291. deleteQueryEXT(query: WebGLQuery): void;
  57292. }
  57293. interface WebGLUniformLocation {
  57294. _currentState: any;
  57295. }
  57296. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57297. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57298. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57299. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57300. interface WebGLRenderingContext {
  57301. readonly RASTERIZER_DISCARD: number;
  57302. readonly DEPTH_COMPONENT24: number;
  57303. readonly TEXTURE_3D: number;
  57304. readonly TEXTURE_2D_ARRAY: number;
  57305. readonly TEXTURE_COMPARE_FUNC: number;
  57306. readonly TEXTURE_COMPARE_MODE: number;
  57307. readonly COMPARE_REF_TO_TEXTURE: number;
  57308. readonly TEXTURE_WRAP_R: number;
  57309. readonly HALF_FLOAT: number;
  57310. readonly RGB8: number;
  57311. readonly RED_INTEGER: number;
  57312. readonly RG_INTEGER: number;
  57313. readonly RGB_INTEGER: number;
  57314. readonly RGBA_INTEGER: number;
  57315. readonly R8_SNORM: number;
  57316. readonly RG8_SNORM: number;
  57317. readonly RGB8_SNORM: number;
  57318. readonly RGBA8_SNORM: number;
  57319. readonly R8I: number;
  57320. readonly RG8I: number;
  57321. readonly RGB8I: number;
  57322. readonly RGBA8I: number;
  57323. readonly R8UI: number;
  57324. readonly RG8UI: number;
  57325. readonly RGB8UI: number;
  57326. readonly RGBA8UI: number;
  57327. readonly R16I: number;
  57328. readonly RG16I: number;
  57329. readonly RGB16I: number;
  57330. readonly RGBA16I: number;
  57331. readonly R16UI: number;
  57332. readonly RG16UI: number;
  57333. readonly RGB16UI: number;
  57334. readonly RGBA16UI: number;
  57335. readonly R32I: number;
  57336. readonly RG32I: number;
  57337. readonly RGB32I: number;
  57338. readonly RGBA32I: number;
  57339. readonly R32UI: number;
  57340. readonly RG32UI: number;
  57341. readonly RGB32UI: number;
  57342. readonly RGBA32UI: number;
  57343. readonly RGB10_A2UI: number;
  57344. readonly R11F_G11F_B10F: number;
  57345. readonly RGB9_E5: number;
  57346. readonly RGB10_A2: number;
  57347. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57348. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57349. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57350. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57351. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57352. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57353. 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;
  57354. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57355. readonly TRANSFORM_FEEDBACK: number;
  57356. readonly INTERLEAVED_ATTRIBS: number;
  57357. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57358. createTransformFeedback(): WebGLTransformFeedback;
  57359. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57360. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57361. beginTransformFeedback(primitiveMode: number): void;
  57362. endTransformFeedback(): void;
  57363. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57364. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57365. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57366. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57367. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57368. }
  57369. interface ImageBitmap {
  57370. readonly width: number;
  57371. readonly height: number;
  57372. close(): void;
  57373. }
  57374. interface WebGLQuery extends WebGLObject {
  57375. }
  57376. declare var WebGLQuery: {
  57377. prototype: WebGLQuery;
  57378. new(): WebGLQuery;
  57379. };
  57380. interface WebGLSampler extends WebGLObject {
  57381. }
  57382. declare var WebGLSampler: {
  57383. prototype: WebGLSampler;
  57384. new(): WebGLSampler;
  57385. };
  57386. interface WebGLSync extends WebGLObject {
  57387. }
  57388. declare var WebGLSync: {
  57389. prototype: WebGLSync;
  57390. new(): WebGLSync;
  57391. };
  57392. interface WebGLTransformFeedback extends WebGLObject {
  57393. }
  57394. declare var WebGLTransformFeedback: {
  57395. prototype: WebGLTransformFeedback;
  57396. new(): WebGLTransformFeedback;
  57397. };
  57398. interface WebGLVertexArrayObject extends WebGLObject {
  57399. }
  57400. declare var WebGLVertexArrayObject: {
  57401. prototype: WebGLVertexArrayObject;
  57402. new(): WebGLVertexArrayObject;
  57403. };
  57404. // Type definitions for WebVR API
  57405. // Project: https://w3c.github.io/webvr/
  57406. // Definitions by: six a <https://github.com/lostfictions>
  57407. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57408. interface VRDisplay extends EventTarget {
  57409. /**
  57410. * Dictionary of capabilities describing the VRDisplay.
  57411. */
  57412. readonly capabilities: VRDisplayCapabilities;
  57413. /**
  57414. * z-depth defining the far plane of the eye view frustum
  57415. * enables mapping of values in the render target depth
  57416. * attachment to scene coordinates. Initially set to 10000.0.
  57417. */
  57418. depthFar: number;
  57419. /**
  57420. * z-depth defining the near plane of the eye view frustum
  57421. * enables mapping of values in the render target depth
  57422. * attachment to scene coordinates. Initially set to 0.01.
  57423. */
  57424. depthNear: number;
  57425. /**
  57426. * An identifier for this distinct VRDisplay. Used as an
  57427. * association point in the Gamepad API.
  57428. */
  57429. readonly displayId: number;
  57430. /**
  57431. * A display name, a user-readable name identifying it.
  57432. */
  57433. readonly displayName: string;
  57434. readonly isConnected: boolean;
  57435. readonly isPresenting: boolean;
  57436. /**
  57437. * If this VRDisplay supports room-scale experiences, the optional
  57438. * stage attribute contains details on the room-scale parameters.
  57439. */
  57440. readonly stageParameters: VRStageParameters | null;
  57441. /**
  57442. * Passing the value returned by `requestAnimationFrame` to
  57443. * `cancelAnimationFrame` will unregister the callback.
  57444. * @param handle Define the hanle of the request to cancel
  57445. */
  57446. cancelAnimationFrame(handle: number): void;
  57447. /**
  57448. * Stops presenting to the VRDisplay.
  57449. * @returns a promise to know when it stopped
  57450. */
  57451. exitPresent(): Promise<void>;
  57452. /**
  57453. * Return the current VREyeParameters for the given eye.
  57454. * @param whichEye Define the eye we want the parameter for
  57455. * @returns the eye parameters
  57456. */
  57457. getEyeParameters(whichEye: string): VREyeParameters;
  57458. /**
  57459. * Populates the passed VRFrameData with the information required to render
  57460. * the current frame.
  57461. * @param frameData Define the data structure to populate
  57462. * @returns true if ok otherwise false
  57463. */
  57464. getFrameData(frameData: VRFrameData): boolean;
  57465. /**
  57466. * Get the layers currently being presented.
  57467. * @returns the list of VR layers
  57468. */
  57469. getLayers(): VRLayer[];
  57470. /**
  57471. * Return a VRPose containing the future predicted pose of the VRDisplay
  57472. * when the current frame will be presented. The value returned will not
  57473. * change until JavaScript has returned control to the browser.
  57474. *
  57475. * The VRPose will contain the position, orientation, velocity,
  57476. * and acceleration of each of these properties.
  57477. * @returns the pose object
  57478. */
  57479. getPose(): VRPose;
  57480. /**
  57481. * Return the current instantaneous pose of the VRDisplay, with no
  57482. * prediction applied.
  57483. * @returns the current instantaneous pose
  57484. */
  57485. getImmediatePose(): VRPose;
  57486. /**
  57487. * The callback passed to `requestAnimationFrame` will be called
  57488. * any time a new frame should be rendered. When the VRDisplay is
  57489. * presenting the callback will be called at the native refresh
  57490. * rate of the HMD. When not presenting this function acts
  57491. * identically to how window.requestAnimationFrame acts. Content should
  57492. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57493. * asynchronously from other displays and at differing refresh rates.
  57494. * @param callback Define the eaction to run next frame
  57495. * @returns the request handle it
  57496. */
  57497. requestAnimationFrame(callback: FrameRequestCallback): number;
  57498. /**
  57499. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57500. * Repeat calls while already presenting will update the VRLayers being displayed.
  57501. * @param layers Define the list of layer to present
  57502. * @returns a promise to know when the request has been fulfilled
  57503. */
  57504. requestPresent(layers: VRLayer[]): Promise<void>;
  57505. /**
  57506. * Reset the pose for this display, treating its current position and
  57507. * orientation as the "origin/zero" values. VRPose.position,
  57508. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57509. * updated when calling resetPose(). This should be called in only
  57510. * sitting-space experiences.
  57511. */
  57512. resetPose(): void;
  57513. /**
  57514. * The VRLayer provided to the VRDisplay will be captured and presented
  57515. * in the HMD. Calling this function has the same effect on the source
  57516. * canvas as any other operation that uses its source image, and canvases
  57517. * created without preserveDrawingBuffer set to true will be cleared.
  57518. * @param pose Define the pose to submit
  57519. */
  57520. submitFrame(pose?: VRPose): void;
  57521. }
  57522. declare var VRDisplay: {
  57523. prototype: VRDisplay;
  57524. new(): VRDisplay;
  57525. };
  57526. interface VRLayer {
  57527. leftBounds?: number[] | Float32Array | null;
  57528. rightBounds?: number[] | Float32Array | null;
  57529. source?: HTMLCanvasElement | null;
  57530. }
  57531. interface VRDisplayCapabilities {
  57532. readonly canPresent: boolean;
  57533. readonly hasExternalDisplay: boolean;
  57534. readonly hasOrientation: boolean;
  57535. readonly hasPosition: boolean;
  57536. readonly maxLayers: number;
  57537. }
  57538. interface VREyeParameters {
  57539. /** @deprecated */
  57540. readonly fieldOfView: VRFieldOfView;
  57541. readonly offset: Float32Array;
  57542. readonly renderHeight: number;
  57543. readonly renderWidth: number;
  57544. }
  57545. interface VRFieldOfView {
  57546. readonly downDegrees: number;
  57547. readonly leftDegrees: number;
  57548. readonly rightDegrees: number;
  57549. readonly upDegrees: number;
  57550. }
  57551. interface VRFrameData {
  57552. readonly leftProjectionMatrix: Float32Array;
  57553. readonly leftViewMatrix: Float32Array;
  57554. readonly pose: VRPose;
  57555. readonly rightProjectionMatrix: Float32Array;
  57556. readonly rightViewMatrix: Float32Array;
  57557. readonly timestamp: number;
  57558. }
  57559. interface VRPose {
  57560. readonly angularAcceleration: Float32Array | null;
  57561. readonly angularVelocity: Float32Array | null;
  57562. readonly linearAcceleration: Float32Array | null;
  57563. readonly linearVelocity: Float32Array | null;
  57564. readonly orientation: Float32Array | null;
  57565. readonly position: Float32Array | null;
  57566. readonly timestamp: number;
  57567. }
  57568. interface VRStageParameters {
  57569. sittingToStandingTransform?: Float32Array;
  57570. sizeX?: number;
  57571. sizeY?: number;
  57572. }
  57573. interface Navigator {
  57574. getVRDisplays(): Promise<VRDisplay[]>;
  57575. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57576. }
  57577. interface Window {
  57578. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57579. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57580. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57581. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57582. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57583. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57584. }
  57585. interface Gamepad {
  57586. readonly displayId: number;
  57587. }
  57588. interface XRDevice {
  57589. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57590. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57591. }
  57592. interface XRSession {
  57593. getInputSources(): Array<any>;
  57594. baseLayer: XRWebGLLayer;
  57595. requestFrameOfReference(type: string): Promise<void>;
  57596. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57597. end(): Promise<void>;
  57598. requestAnimationFrame: Function;
  57599. addEventListener: Function;
  57600. }
  57601. interface XRSessionCreationOptions {
  57602. outputContext?: WebGLRenderingContext | null;
  57603. immersive?: boolean;
  57604. environmentIntegration?: boolean;
  57605. }
  57606. interface XRLayer {
  57607. getViewport: Function;
  57608. framebufferWidth: number;
  57609. framebufferHeight: number;
  57610. }
  57611. interface XRView {
  57612. projectionMatrix: Float32Array;
  57613. }
  57614. interface XRFrame {
  57615. getDevicePose: Function;
  57616. getInputPose: Function;
  57617. views: Array<XRView>;
  57618. baseLayer: XRLayer;
  57619. }
  57620. interface XRFrameOfReference {
  57621. }
  57622. interface XRWebGLLayer extends XRLayer {
  57623. framebuffer: WebGLFramebuffer;
  57624. }
  57625. declare var XRWebGLLayer: {
  57626. prototype: XRWebGLLayer;
  57627. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57628. };
  57629. declare module "babylonjs" {
  57630. export * from "babylonjs/Legacy/legacy";
  57631. }
  57632. declare module BABYLON {
  57633. /** Alias type for value that can be null */
  57634. export type Nullable<T> = T | null;
  57635. /**
  57636. * Alias type for number that are floats
  57637. * @ignorenaming
  57638. */
  57639. export type float = number;
  57640. /**
  57641. * Alias type for number that are doubles.
  57642. * @ignorenaming
  57643. */
  57644. export type double = number;
  57645. /**
  57646. * Alias type for number that are integer
  57647. * @ignorenaming
  57648. */
  57649. export type int = number;
  57650. /** Alias type for number array or Float32Array */
  57651. export type FloatArray = number[] | Float32Array;
  57652. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57653. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57654. /**
  57655. * Alias for types that can be used by a Buffer or VertexBuffer.
  57656. */
  57657. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57658. /**
  57659. * Alias type for primitive types
  57660. * @ignorenaming
  57661. */
  57662. type Primitive = undefined | null | boolean | string | number | Function;
  57663. /**
  57664. * Type modifier to make all the properties of an object Readonly
  57665. */
  57666. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57667. /**
  57668. * Type modifier to make all the properties of an object Readonly recursively
  57669. */
  57670. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57671. /** @hidden */
  57672. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57673. }
  57674. /** @hidden */
  57675. /** @hidden */
  57676. type DeepImmutableObject<T> = {
  57677. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57678. };
  57679. }
  57680. declare module BABYLON {
  57681. /**
  57682. * Class containing a set of static utilities functions for arrays.
  57683. */
  57684. export class ArrayTools {
  57685. /**
  57686. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57687. * @param size the number of element to construct and put in the array
  57688. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57689. * @returns a new array filled with new objects
  57690. */
  57691. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57692. }
  57693. }
  57694. declare module BABYLON {
  57695. /**
  57696. * Scalar computation library
  57697. */
  57698. export class Scalar {
  57699. /**
  57700. * Two pi constants convenient for computation.
  57701. */
  57702. static TwoPi: number;
  57703. /**
  57704. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57705. * @param a number
  57706. * @param b number
  57707. * @param epsilon (default = 1.401298E-45)
  57708. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57709. */
  57710. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57711. /**
  57712. * Returns a string : the upper case translation of the number i to hexadecimal.
  57713. * @param i number
  57714. * @returns the upper case translation of the number i to hexadecimal.
  57715. */
  57716. static ToHex(i: number): string;
  57717. /**
  57718. * Returns -1 if value is negative and +1 is value is positive.
  57719. * @param value the value
  57720. * @returns the value itself if it's equal to zero.
  57721. */
  57722. static Sign(value: number): number;
  57723. /**
  57724. * Returns the value itself if it's between min and max.
  57725. * Returns min if the value is lower than min.
  57726. * Returns max if the value is greater than max.
  57727. * @param value the value to clmap
  57728. * @param min the min value to clamp to (default: 0)
  57729. * @param max the max value to clamp to (default: 1)
  57730. * @returns the clamped value
  57731. */
  57732. static Clamp(value: number, min?: number, max?: number): number;
  57733. /**
  57734. * the log2 of value.
  57735. * @param value the value to compute log2 of
  57736. * @returns the log2 of value.
  57737. */
  57738. static Log2(value: number): number;
  57739. /**
  57740. * Loops the value, so that it is never larger than length and never smaller than 0.
  57741. *
  57742. * This is similar to the modulo operator but it works with floating point numbers.
  57743. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57744. * With t = 5 and length = 2.5, the result would be 0.0.
  57745. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57746. * @param value the value
  57747. * @param length the length
  57748. * @returns the looped value
  57749. */
  57750. static Repeat(value: number, length: number): number;
  57751. /**
  57752. * Normalize the value between 0.0 and 1.0 using min and max values
  57753. * @param value value to normalize
  57754. * @param min max to normalize between
  57755. * @param max min to normalize between
  57756. * @returns the normalized value
  57757. */
  57758. static Normalize(value: number, min: number, max: number): number;
  57759. /**
  57760. * Denormalize the value from 0.0 and 1.0 using min and max values
  57761. * @param normalized value to denormalize
  57762. * @param min max to denormalize between
  57763. * @param max min to denormalize between
  57764. * @returns the denormalized value
  57765. */
  57766. static Denormalize(normalized: number, min: number, max: number): number;
  57767. /**
  57768. * Calculates the shortest difference between two given angles given in degrees.
  57769. * @param current current angle in degrees
  57770. * @param target target angle in degrees
  57771. * @returns the delta
  57772. */
  57773. static DeltaAngle(current: number, target: number): number;
  57774. /**
  57775. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57776. * @param tx value
  57777. * @param length length
  57778. * @returns The returned value will move back and forth between 0 and length
  57779. */
  57780. static PingPong(tx: number, length: number): number;
  57781. /**
  57782. * Interpolates between min and max with smoothing at the limits.
  57783. *
  57784. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57785. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57786. * @param from from
  57787. * @param to to
  57788. * @param tx value
  57789. * @returns the smooth stepped value
  57790. */
  57791. static SmoothStep(from: number, to: number, tx: number): number;
  57792. /**
  57793. * Moves a value current towards target.
  57794. *
  57795. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57796. * Negative values of maxDelta pushes the value away from target.
  57797. * @param current current value
  57798. * @param target target value
  57799. * @param maxDelta max distance to move
  57800. * @returns resulting value
  57801. */
  57802. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57803. /**
  57804. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57805. *
  57806. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57807. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57808. * @param current current value
  57809. * @param target target value
  57810. * @param maxDelta max distance to move
  57811. * @returns resulting angle
  57812. */
  57813. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57814. /**
  57815. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57816. * @param start start value
  57817. * @param end target value
  57818. * @param amount amount to lerp between
  57819. * @returns the lerped value
  57820. */
  57821. static Lerp(start: number, end: number, amount: number): number;
  57822. /**
  57823. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57824. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57825. * @param start start value
  57826. * @param end target value
  57827. * @param amount amount to lerp between
  57828. * @returns the lerped value
  57829. */
  57830. static LerpAngle(start: number, end: number, amount: number): number;
  57831. /**
  57832. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57833. * @param a start value
  57834. * @param b target value
  57835. * @param value value between a and b
  57836. * @returns the inverseLerp value
  57837. */
  57838. static InverseLerp(a: number, b: number, value: number): number;
  57839. /**
  57840. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57841. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57842. * @param value1 spline value
  57843. * @param tangent1 spline value
  57844. * @param value2 spline value
  57845. * @param tangent2 spline value
  57846. * @param amount input value
  57847. * @returns hermite result
  57848. */
  57849. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57850. /**
  57851. * Returns a random float number between and min and max values
  57852. * @param min min value of random
  57853. * @param max max value of random
  57854. * @returns random value
  57855. */
  57856. static RandomRange(min: number, max: number): number;
  57857. /**
  57858. * This function returns percentage of a number in a given range.
  57859. *
  57860. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57861. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57862. * @param number to convert to percentage
  57863. * @param min min range
  57864. * @param max max range
  57865. * @returns the percentage
  57866. */
  57867. static RangeToPercent(number: number, min: number, max: number): number;
  57868. /**
  57869. * This function returns number that corresponds to the percentage in a given range.
  57870. *
  57871. * PercentToRange(0.34,0,100) will return 34.
  57872. * @param percent to convert to number
  57873. * @param min min range
  57874. * @param max max range
  57875. * @returns the number
  57876. */
  57877. static PercentToRange(percent: number, min: number, max: number): number;
  57878. /**
  57879. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57880. * @param angle The angle to normalize in radian.
  57881. * @return The converted angle.
  57882. */
  57883. static NormalizeRadians(angle: number): number;
  57884. }
  57885. }
  57886. declare module BABYLON {
  57887. /**
  57888. * Constant used to convert a value to gamma space
  57889. * @ignorenaming
  57890. */
  57891. export const ToGammaSpace: number;
  57892. /**
  57893. * Constant used to convert a value to linear space
  57894. * @ignorenaming
  57895. */
  57896. export const ToLinearSpace = 2.2;
  57897. /**
  57898. * Constant used to define the minimal number value in Babylon.js
  57899. * @ignorenaming
  57900. */
  57901. export const Epsilon = 0.001;
  57902. /**
  57903. * Class used to hold a RBG color
  57904. */
  57905. export class Color3 {
  57906. /**
  57907. * Defines the red component (between 0 and 1, default is 0)
  57908. */
  57909. r: number;
  57910. /**
  57911. * Defines the green component (between 0 and 1, default is 0)
  57912. */
  57913. g: number;
  57914. /**
  57915. * Defines the blue component (between 0 and 1, default is 0)
  57916. */
  57917. b: number;
  57918. /**
  57919. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57920. * @param r defines the red component (between 0 and 1, default is 0)
  57921. * @param g defines the green component (between 0 and 1, default is 0)
  57922. * @param b defines the blue component (between 0 and 1, default is 0)
  57923. */
  57924. constructor(
  57925. /**
  57926. * Defines the red component (between 0 and 1, default is 0)
  57927. */
  57928. r?: number,
  57929. /**
  57930. * Defines the green component (between 0 and 1, default is 0)
  57931. */
  57932. g?: number,
  57933. /**
  57934. * Defines the blue component (between 0 and 1, default is 0)
  57935. */
  57936. b?: number);
  57937. /**
  57938. * Creates a string with the Color3 current values
  57939. * @returns the string representation of the Color3 object
  57940. */
  57941. toString(): string;
  57942. /**
  57943. * Returns the string "Color3"
  57944. * @returns "Color3"
  57945. */
  57946. getClassName(): string;
  57947. /**
  57948. * Compute the Color3 hash code
  57949. * @returns an unique number that can be used to hash Color3 objects
  57950. */
  57951. getHashCode(): number;
  57952. /**
  57953. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57954. * @param array defines the array where to store the r,g,b components
  57955. * @param index defines an optional index in the target array to define where to start storing values
  57956. * @returns the current Color3 object
  57957. */
  57958. toArray(array: FloatArray, index?: number): Color3;
  57959. /**
  57960. * Returns a new Color4 object from the current Color3 and the given alpha
  57961. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57962. * @returns a new Color4 object
  57963. */
  57964. toColor4(alpha?: number): Color4;
  57965. /**
  57966. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57967. * @returns the new array
  57968. */
  57969. asArray(): number[];
  57970. /**
  57971. * Returns the luminance value
  57972. * @returns a float value
  57973. */
  57974. toLuminance(): number;
  57975. /**
  57976. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57977. * @param otherColor defines the second operand
  57978. * @returns the new Color3 object
  57979. */
  57980. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57981. /**
  57982. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57983. * @param otherColor defines the second operand
  57984. * @param result defines the Color3 object where to store the result
  57985. * @returns the current Color3
  57986. */
  57987. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57988. /**
  57989. * Determines equality between Color3 objects
  57990. * @param otherColor defines the second operand
  57991. * @returns true if the rgb values are equal to the given ones
  57992. */
  57993. equals(otherColor: DeepImmutable<Color3>): boolean;
  57994. /**
  57995. * Determines equality between the current Color3 object and a set of r,b,g values
  57996. * @param r defines the red component to check
  57997. * @param g defines the green component to check
  57998. * @param b defines the blue component to check
  57999. * @returns true if the rgb values are equal to the given ones
  58000. */
  58001. equalsFloats(r: number, g: number, b: number): boolean;
  58002. /**
  58003. * Multiplies in place each rgb value by scale
  58004. * @param scale defines the scaling factor
  58005. * @returns the updated Color3
  58006. */
  58007. scale(scale: number): Color3;
  58008. /**
  58009. * Multiplies the rgb values by scale and stores the result into "result"
  58010. * @param scale defines the scaling factor
  58011. * @param result defines the Color3 object where to store the result
  58012. * @returns the unmodified current Color3
  58013. */
  58014. scaleToRef(scale: number, result: Color3): Color3;
  58015. /**
  58016. * Scale the current Color3 values by a factor and add the result to a given Color3
  58017. * @param scale defines the scale factor
  58018. * @param result defines color to store the result into
  58019. * @returns the unmodified current Color3
  58020. */
  58021. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58022. /**
  58023. * Clamps the rgb values by the min and max values and stores the result into "result"
  58024. * @param min defines minimum clamping value (default is 0)
  58025. * @param max defines maximum clamping value (default is 1)
  58026. * @param result defines color to store the result into
  58027. * @returns the original Color3
  58028. */
  58029. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58030. /**
  58031. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58032. * @param otherColor defines the second operand
  58033. * @returns the new Color3
  58034. */
  58035. add(otherColor: DeepImmutable<Color3>): Color3;
  58036. /**
  58037. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58038. * @param otherColor defines the second operand
  58039. * @param result defines Color3 object to store the result into
  58040. * @returns the unmodified current Color3
  58041. */
  58042. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58043. /**
  58044. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58045. * @param otherColor defines the second operand
  58046. * @returns the new Color3
  58047. */
  58048. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58049. /**
  58050. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58051. * @param otherColor defines the second operand
  58052. * @param result defines Color3 object to store the result into
  58053. * @returns the unmodified current Color3
  58054. */
  58055. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58056. /**
  58057. * Copy the current object
  58058. * @returns a new Color3 copied the current one
  58059. */
  58060. clone(): Color3;
  58061. /**
  58062. * Copies the rgb values from the source in the current Color3
  58063. * @param source defines the source Color3 object
  58064. * @returns the updated Color3 object
  58065. */
  58066. copyFrom(source: DeepImmutable<Color3>): Color3;
  58067. /**
  58068. * Updates the Color3 rgb values from the given floats
  58069. * @param r defines the red component to read from
  58070. * @param g defines the green component to read from
  58071. * @param b defines the blue component to read from
  58072. * @returns the current Color3 object
  58073. */
  58074. copyFromFloats(r: number, g: number, b: number): Color3;
  58075. /**
  58076. * Updates the Color3 rgb values from the given floats
  58077. * @param r defines the red component to read from
  58078. * @param g defines the green component to read from
  58079. * @param b defines the blue component to read from
  58080. * @returns the current Color3 object
  58081. */
  58082. set(r: number, g: number, b: number): Color3;
  58083. /**
  58084. * Compute the Color3 hexadecimal code as a string
  58085. * @returns a string containing the hexadecimal representation of the Color3 object
  58086. */
  58087. toHexString(): string;
  58088. /**
  58089. * Computes a new Color3 converted from the current one to linear space
  58090. * @returns a new Color3 object
  58091. */
  58092. toLinearSpace(): Color3;
  58093. /**
  58094. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58095. * @param convertedColor defines the Color3 object where to store the linear space version
  58096. * @returns the unmodified Color3
  58097. */
  58098. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58099. /**
  58100. * Computes a new Color3 converted from the current one to gamma space
  58101. * @returns a new Color3 object
  58102. */
  58103. toGammaSpace(): Color3;
  58104. /**
  58105. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58106. * @param convertedColor defines the Color3 object where to store the gamma space version
  58107. * @returns the unmodified Color3
  58108. */
  58109. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58110. private static _BlackReadOnly;
  58111. /**
  58112. * Creates a new Color3 from the string containing valid hexadecimal values
  58113. * @param hex defines a string containing valid hexadecimal values
  58114. * @returns a new Color3 object
  58115. */
  58116. static FromHexString(hex: string): Color3;
  58117. /**
  58118. * Creates a new Vector3 from the starting index of the given array
  58119. * @param array defines the source array
  58120. * @param offset defines an offset in the source array
  58121. * @returns a new Color3 object
  58122. */
  58123. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58124. /**
  58125. * Creates a new Color3 from integer values (< 256)
  58126. * @param r defines the red component to read from (value between 0 and 255)
  58127. * @param g defines the green component to read from (value between 0 and 255)
  58128. * @param b defines the blue component to read from (value between 0 and 255)
  58129. * @returns a new Color3 object
  58130. */
  58131. static FromInts(r: number, g: number, b: number): Color3;
  58132. /**
  58133. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58134. * @param start defines the start Color3 value
  58135. * @param end defines the end Color3 value
  58136. * @param amount defines the gradient value between start and end
  58137. * @returns a new Color3 object
  58138. */
  58139. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58140. /**
  58141. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58142. * @param left defines the start value
  58143. * @param right defines the end value
  58144. * @param amount defines the gradient factor
  58145. * @param result defines the Color3 object where to store the result
  58146. */
  58147. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58148. /**
  58149. * Returns a Color3 value containing a red color
  58150. * @returns a new Color3 object
  58151. */
  58152. static Red(): Color3;
  58153. /**
  58154. * Returns a Color3 value containing a green color
  58155. * @returns a new Color3 object
  58156. */
  58157. static Green(): Color3;
  58158. /**
  58159. * Returns a Color3 value containing a blue color
  58160. * @returns a new Color3 object
  58161. */
  58162. static Blue(): Color3;
  58163. /**
  58164. * Returns a Color3 value containing a black color
  58165. * @returns a new Color3 object
  58166. */
  58167. static Black(): Color3;
  58168. /**
  58169. * Gets a Color3 value containing a black color that must not be updated
  58170. */
  58171. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58172. /**
  58173. * Returns a Color3 value containing a white color
  58174. * @returns a new Color3 object
  58175. */
  58176. static White(): Color3;
  58177. /**
  58178. * Returns a Color3 value containing a purple color
  58179. * @returns a new Color3 object
  58180. */
  58181. static Purple(): Color3;
  58182. /**
  58183. * Returns a Color3 value containing a magenta color
  58184. * @returns a new Color3 object
  58185. */
  58186. static Magenta(): Color3;
  58187. /**
  58188. * Returns a Color3 value containing a yellow color
  58189. * @returns a new Color3 object
  58190. */
  58191. static Yellow(): Color3;
  58192. /**
  58193. * Returns a Color3 value containing a gray color
  58194. * @returns a new Color3 object
  58195. */
  58196. static Gray(): Color3;
  58197. /**
  58198. * Returns a Color3 value containing a teal color
  58199. * @returns a new Color3 object
  58200. */
  58201. static Teal(): Color3;
  58202. /**
  58203. * Returns a Color3 value containing a random color
  58204. * @returns a new Color3 object
  58205. */
  58206. static Random(): Color3;
  58207. }
  58208. /**
  58209. * Class used to hold a RBGA color
  58210. */
  58211. export class Color4 {
  58212. /**
  58213. * Defines the red component (between 0 and 1, default is 0)
  58214. */
  58215. r: number;
  58216. /**
  58217. * Defines the green component (between 0 and 1, default is 0)
  58218. */
  58219. g: number;
  58220. /**
  58221. * Defines the blue component (between 0 and 1, default is 0)
  58222. */
  58223. b: number;
  58224. /**
  58225. * Defines the alpha component (between 0 and 1, default is 1)
  58226. */
  58227. a: number;
  58228. /**
  58229. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58230. * @param r defines the red component (between 0 and 1, default is 0)
  58231. * @param g defines the green component (between 0 and 1, default is 0)
  58232. * @param b defines the blue component (between 0 and 1, default is 0)
  58233. * @param a defines the alpha component (between 0 and 1, default is 1)
  58234. */
  58235. constructor(
  58236. /**
  58237. * Defines the red component (between 0 and 1, default is 0)
  58238. */
  58239. r?: number,
  58240. /**
  58241. * Defines the green component (between 0 and 1, default is 0)
  58242. */
  58243. g?: number,
  58244. /**
  58245. * Defines the blue component (between 0 and 1, default is 0)
  58246. */
  58247. b?: number,
  58248. /**
  58249. * Defines the alpha component (between 0 and 1, default is 1)
  58250. */
  58251. a?: number);
  58252. /**
  58253. * Adds in place the given Color4 values to the current Color4 object
  58254. * @param right defines the second operand
  58255. * @returns the current updated Color4 object
  58256. */
  58257. addInPlace(right: DeepImmutable<Color4>): Color4;
  58258. /**
  58259. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58260. * @returns the new array
  58261. */
  58262. asArray(): number[];
  58263. /**
  58264. * Stores from the starting index in the given array the Color4 successive values
  58265. * @param array defines the array where to store the r,g,b components
  58266. * @param index defines an optional index in the target array to define where to start storing values
  58267. * @returns the current Color4 object
  58268. */
  58269. toArray(array: number[], index?: number): Color4;
  58270. /**
  58271. * Determines equality between Color4 objects
  58272. * @param otherColor defines the second operand
  58273. * @returns true if the rgba values are equal to the given ones
  58274. */
  58275. equals(otherColor: DeepImmutable<Color4>): boolean;
  58276. /**
  58277. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58278. * @param right defines the second operand
  58279. * @returns a new Color4 object
  58280. */
  58281. add(right: DeepImmutable<Color4>): Color4;
  58282. /**
  58283. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58284. * @param right defines the second operand
  58285. * @returns a new Color4 object
  58286. */
  58287. subtract(right: DeepImmutable<Color4>): Color4;
  58288. /**
  58289. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58290. * @param right defines the second operand
  58291. * @param result defines the Color4 object where to store the result
  58292. * @returns the current Color4 object
  58293. */
  58294. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58295. /**
  58296. * Creates a new Color4 with the current Color4 values multiplied by scale
  58297. * @param scale defines the scaling factor to apply
  58298. * @returns a new Color4 object
  58299. */
  58300. scale(scale: number): Color4;
  58301. /**
  58302. * Multiplies the current Color4 values by scale and stores the result in "result"
  58303. * @param scale defines the scaling factor to apply
  58304. * @param result defines the Color4 object where to store the result
  58305. * @returns the current unmodified Color4
  58306. */
  58307. scaleToRef(scale: number, result: Color4): Color4;
  58308. /**
  58309. * Scale the current Color4 values by a factor and add the result to a given Color4
  58310. * @param scale defines the scale factor
  58311. * @param result defines the Color4 object where to store the result
  58312. * @returns the unmodified current Color4
  58313. */
  58314. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58315. /**
  58316. * Clamps the rgb values by the min and max values and stores the result into "result"
  58317. * @param min defines minimum clamping value (default is 0)
  58318. * @param max defines maximum clamping value (default is 1)
  58319. * @param result defines color to store the result into.
  58320. * @returns the cuurent Color4
  58321. */
  58322. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58323. /**
  58324. * Multipy an Color4 value by another and return a new Color4 object
  58325. * @param color defines the Color4 value to multiply by
  58326. * @returns a new Color4 object
  58327. */
  58328. multiply(color: Color4): Color4;
  58329. /**
  58330. * Multipy a Color4 value by another and push the result in a reference value
  58331. * @param color defines the Color4 value to multiply by
  58332. * @param result defines the Color4 to fill the result in
  58333. * @returns the result Color4
  58334. */
  58335. multiplyToRef(color: Color4, result: Color4): Color4;
  58336. /**
  58337. * Creates a string with the Color4 current values
  58338. * @returns the string representation of the Color4 object
  58339. */
  58340. toString(): string;
  58341. /**
  58342. * Returns the string "Color4"
  58343. * @returns "Color4"
  58344. */
  58345. getClassName(): string;
  58346. /**
  58347. * Compute the Color4 hash code
  58348. * @returns an unique number that can be used to hash Color4 objects
  58349. */
  58350. getHashCode(): number;
  58351. /**
  58352. * Creates a new Color4 copied from the current one
  58353. * @returns a new Color4 object
  58354. */
  58355. clone(): Color4;
  58356. /**
  58357. * Copies the given Color4 values into the current one
  58358. * @param source defines the source Color4 object
  58359. * @returns the current updated Color4 object
  58360. */
  58361. copyFrom(source: Color4): Color4;
  58362. /**
  58363. * Copies the given float values into the current one
  58364. * @param r defines the red component to read from
  58365. * @param g defines the green component to read from
  58366. * @param b defines the blue component to read from
  58367. * @param a defines the alpha component to read from
  58368. * @returns the current updated Color4 object
  58369. */
  58370. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58371. /**
  58372. * Copies the given float values into the current one
  58373. * @param r defines the red component to read from
  58374. * @param g defines the green component to read from
  58375. * @param b defines the blue component to read from
  58376. * @param a defines the alpha component to read from
  58377. * @returns the current updated Color4 object
  58378. */
  58379. set(r: number, g: number, b: number, a: number): Color4;
  58380. /**
  58381. * Compute the Color4 hexadecimal code as a string
  58382. * @returns a string containing the hexadecimal representation of the Color4 object
  58383. */
  58384. toHexString(): string;
  58385. /**
  58386. * Computes a new Color4 converted from the current one to linear space
  58387. * @returns a new Color4 object
  58388. */
  58389. toLinearSpace(): Color4;
  58390. /**
  58391. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58392. * @param convertedColor defines the Color4 object where to store the linear space version
  58393. * @returns the unmodified Color4
  58394. */
  58395. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58396. /**
  58397. * Computes a new Color4 converted from the current one to gamma space
  58398. * @returns a new Color4 object
  58399. */
  58400. toGammaSpace(): Color4;
  58401. /**
  58402. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58403. * @param convertedColor defines the Color4 object where to store the gamma space version
  58404. * @returns the unmodified Color4
  58405. */
  58406. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58407. /**
  58408. * Creates a new Color4 from the string containing valid hexadecimal values
  58409. * @param hex defines a string containing valid hexadecimal values
  58410. * @returns a new Color4 object
  58411. */
  58412. static FromHexString(hex: string): Color4;
  58413. /**
  58414. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58415. * @param left defines the start value
  58416. * @param right defines the end value
  58417. * @param amount defines the gradient factor
  58418. * @returns a new Color4 object
  58419. */
  58420. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58421. /**
  58422. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58423. * @param left defines the start value
  58424. * @param right defines the end value
  58425. * @param amount defines the gradient factor
  58426. * @param result defines the Color4 object where to store data
  58427. */
  58428. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58429. /**
  58430. * Creates a new Color4 from a Color3 and an alpha value
  58431. * @param color3 defines the source Color3 to read from
  58432. * @param alpha defines the alpha component (1.0 by default)
  58433. * @returns a new Color4 object
  58434. */
  58435. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58436. /**
  58437. * Creates a new Color4 from the starting index element of the given array
  58438. * @param array defines the source array to read from
  58439. * @param offset defines the offset in the source array
  58440. * @returns a new Color4 object
  58441. */
  58442. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58443. /**
  58444. * Creates a new Color3 from integer values (< 256)
  58445. * @param r defines the red component to read from (value between 0 and 255)
  58446. * @param g defines the green component to read from (value between 0 and 255)
  58447. * @param b defines the blue component to read from (value between 0 and 255)
  58448. * @param a defines the alpha component to read from (value between 0 and 255)
  58449. * @returns a new Color3 object
  58450. */
  58451. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58452. /**
  58453. * Check the content of a given array and convert it to an array containing RGBA data
  58454. * If the original array was already containing count * 4 values then it is returned directly
  58455. * @param colors defines the array to check
  58456. * @param count defines the number of RGBA data to expect
  58457. * @returns an array containing count * 4 values (RGBA)
  58458. */
  58459. static CheckColors4(colors: number[], count: number): number[];
  58460. }
  58461. /**
  58462. * Class representing a vector containing 2 coordinates
  58463. */
  58464. export class Vector2 {
  58465. /** defines the first coordinate */
  58466. x: number;
  58467. /** defines the second coordinate */
  58468. y: number;
  58469. /**
  58470. * Creates a new Vector2 from the given x and y coordinates
  58471. * @param x defines the first coordinate
  58472. * @param y defines the second coordinate
  58473. */
  58474. constructor(
  58475. /** defines the first coordinate */
  58476. x?: number,
  58477. /** defines the second coordinate */
  58478. y?: number);
  58479. /**
  58480. * Gets a string with the Vector2 coordinates
  58481. * @returns a string with the Vector2 coordinates
  58482. */
  58483. toString(): string;
  58484. /**
  58485. * Gets class name
  58486. * @returns the string "Vector2"
  58487. */
  58488. getClassName(): string;
  58489. /**
  58490. * Gets current vector hash code
  58491. * @returns the Vector2 hash code as a number
  58492. */
  58493. getHashCode(): number;
  58494. /**
  58495. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58496. * @param array defines the source array
  58497. * @param index defines the offset in source array
  58498. * @returns the current Vector2
  58499. */
  58500. toArray(array: FloatArray, index?: number): Vector2;
  58501. /**
  58502. * Copy the current vector to an array
  58503. * @returns a new array with 2 elements: the Vector2 coordinates.
  58504. */
  58505. asArray(): number[];
  58506. /**
  58507. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58508. * @param source defines the source Vector2
  58509. * @returns the current updated Vector2
  58510. */
  58511. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58512. /**
  58513. * Sets the Vector2 coordinates with the given floats
  58514. * @param x defines the first coordinate
  58515. * @param y defines the second coordinate
  58516. * @returns the current updated Vector2
  58517. */
  58518. copyFromFloats(x: number, y: number): Vector2;
  58519. /**
  58520. * Sets the Vector2 coordinates with the given floats
  58521. * @param x defines the first coordinate
  58522. * @param y defines the second coordinate
  58523. * @returns the current updated Vector2
  58524. */
  58525. set(x: number, y: number): Vector2;
  58526. /**
  58527. * Add another vector with the current one
  58528. * @param otherVector defines the other vector
  58529. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58530. */
  58531. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58532. /**
  58533. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58534. * @param otherVector defines the other vector
  58535. * @param result defines the target vector
  58536. * @returns the unmodified current Vector2
  58537. */
  58538. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58539. /**
  58540. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58541. * @param otherVector defines the other vector
  58542. * @returns the current updated Vector2
  58543. */
  58544. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58545. /**
  58546. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58547. * @param otherVector defines the other vector
  58548. * @returns a new Vector2
  58549. */
  58550. addVector3(otherVector: Vector3): Vector2;
  58551. /**
  58552. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58553. * @param otherVector defines the other vector
  58554. * @returns a new Vector2
  58555. */
  58556. subtract(otherVector: Vector2): Vector2;
  58557. /**
  58558. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58559. * @param otherVector defines the other vector
  58560. * @param result defines the target vector
  58561. * @returns the unmodified current Vector2
  58562. */
  58563. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58564. /**
  58565. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58566. * @param otherVector defines the other vector
  58567. * @returns the current updated Vector2
  58568. */
  58569. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58570. /**
  58571. * Multiplies in place the current Vector2 coordinates by the given ones
  58572. * @param otherVector defines the other vector
  58573. * @returns the current updated Vector2
  58574. */
  58575. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58576. /**
  58577. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58578. * @param otherVector defines the other vector
  58579. * @returns a new Vector2
  58580. */
  58581. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58582. /**
  58583. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58584. * @param otherVector defines the other vector
  58585. * @param result defines the target vector
  58586. * @returns the unmodified current Vector2
  58587. */
  58588. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58589. /**
  58590. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58591. * @param x defines the first coordinate
  58592. * @param y defines the second coordinate
  58593. * @returns a new Vector2
  58594. */
  58595. multiplyByFloats(x: number, y: number): Vector2;
  58596. /**
  58597. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58598. * @param otherVector defines the other vector
  58599. * @returns a new Vector2
  58600. */
  58601. divide(otherVector: Vector2): Vector2;
  58602. /**
  58603. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58604. * @param otherVector defines the other vector
  58605. * @param result defines the target vector
  58606. * @returns the unmodified current Vector2
  58607. */
  58608. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58609. /**
  58610. * Divides the current Vector2 coordinates by the given ones
  58611. * @param otherVector defines the other vector
  58612. * @returns the current updated Vector2
  58613. */
  58614. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58615. /**
  58616. * Gets a new Vector2 with current Vector2 negated coordinates
  58617. * @returns a new Vector2
  58618. */
  58619. negate(): Vector2;
  58620. /**
  58621. * Multiply the Vector2 coordinates by scale
  58622. * @param scale defines the scaling factor
  58623. * @returns the current updated Vector2
  58624. */
  58625. scaleInPlace(scale: number): Vector2;
  58626. /**
  58627. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58628. * @param scale defines the scaling factor
  58629. * @returns a new Vector2
  58630. */
  58631. scale(scale: number): Vector2;
  58632. /**
  58633. * Scale the current Vector2 values by a factor to a given Vector2
  58634. * @param scale defines the scale factor
  58635. * @param result defines the Vector2 object where to store the result
  58636. * @returns the unmodified current Vector2
  58637. */
  58638. scaleToRef(scale: number, result: Vector2): Vector2;
  58639. /**
  58640. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58641. * @param scale defines the scale factor
  58642. * @param result defines the Vector2 object where to store the result
  58643. * @returns the unmodified current Vector2
  58644. */
  58645. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58646. /**
  58647. * Gets a boolean if two vectors are equals
  58648. * @param otherVector defines the other vector
  58649. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58650. */
  58651. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58652. /**
  58653. * Gets a boolean if two vectors are equals (using an epsilon value)
  58654. * @param otherVector defines the other vector
  58655. * @param epsilon defines the minimal distance to consider equality
  58656. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58657. */
  58658. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58659. /**
  58660. * Gets a new Vector2 from current Vector2 floored values
  58661. * @returns a new Vector2
  58662. */
  58663. floor(): Vector2;
  58664. /**
  58665. * Gets a new Vector2 from current Vector2 floored values
  58666. * @returns a new Vector2
  58667. */
  58668. fract(): Vector2;
  58669. /**
  58670. * Gets the length of the vector
  58671. * @returns the vector length (float)
  58672. */
  58673. length(): number;
  58674. /**
  58675. * Gets the vector squared length
  58676. * @returns the vector squared length (float)
  58677. */
  58678. lengthSquared(): number;
  58679. /**
  58680. * Normalize the vector
  58681. * @returns the current updated Vector2
  58682. */
  58683. normalize(): Vector2;
  58684. /**
  58685. * Gets a new Vector2 copied from the Vector2
  58686. * @returns a new Vector2
  58687. */
  58688. clone(): Vector2;
  58689. /**
  58690. * Gets a new Vector2(0, 0)
  58691. * @returns a new Vector2
  58692. */
  58693. static Zero(): Vector2;
  58694. /**
  58695. * Gets a new Vector2(1, 1)
  58696. * @returns a new Vector2
  58697. */
  58698. static One(): Vector2;
  58699. /**
  58700. * Gets a new Vector2 set from the given index element of the given array
  58701. * @param array defines the data source
  58702. * @param offset defines the offset in the data source
  58703. * @returns a new Vector2
  58704. */
  58705. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58706. /**
  58707. * Sets "result" from the given index element of the given array
  58708. * @param array defines the data source
  58709. * @param offset defines the offset in the data source
  58710. * @param result defines the target vector
  58711. */
  58712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58713. /**
  58714. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58715. * @param value1 defines 1st point of control
  58716. * @param value2 defines 2nd point of control
  58717. * @param value3 defines 3rd point of control
  58718. * @param value4 defines 4th point of control
  58719. * @param amount defines the interpolation factor
  58720. * @returns a new Vector2
  58721. */
  58722. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58723. /**
  58724. * 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".
  58725. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58726. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58727. * @param value defines the value to clamp
  58728. * @param min defines the lower limit
  58729. * @param max defines the upper limit
  58730. * @returns a new Vector2
  58731. */
  58732. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58733. /**
  58734. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58735. * @param value1 defines the 1st control point
  58736. * @param tangent1 defines the outgoing tangent
  58737. * @param value2 defines the 2nd control point
  58738. * @param tangent2 defines the incoming tangent
  58739. * @param amount defines the interpolation factor
  58740. * @returns a new Vector2
  58741. */
  58742. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58743. /**
  58744. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58745. * @param start defines the start vector
  58746. * @param end defines the end vector
  58747. * @param amount defines the interpolation factor
  58748. * @returns a new Vector2
  58749. */
  58750. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58751. /**
  58752. * Gets the dot product of the vector "left" and the vector "right"
  58753. * @param left defines first vector
  58754. * @param right defines second vector
  58755. * @returns the dot product (float)
  58756. */
  58757. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58758. /**
  58759. * Returns a new Vector2 equal to the normalized given vector
  58760. * @param vector defines the vector to normalize
  58761. * @returns a new Vector2
  58762. */
  58763. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58764. /**
  58765. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58766. * @param left defines 1st vector
  58767. * @param right defines 2nd vector
  58768. * @returns a new Vector2
  58769. */
  58770. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58771. /**
  58772. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58773. * @param left defines 1st vector
  58774. * @param right defines 2nd vector
  58775. * @returns a new Vector2
  58776. */
  58777. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58778. /**
  58779. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58780. * @param vector defines the vector to transform
  58781. * @param transformation defines the matrix to apply
  58782. * @returns a new Vector2
  58783. */
  58784. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58785. /**
  58786. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58787. * @param vector defines the vector to transform
  58788. * @param transformation defines the matrix to apply
  58789. * @param result defines the target vector
  58790. */
  58791. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58792. /**
  58793. * Determines if a given vector is included in a triangle
  58794. * @param p defines the vector to test
  58795. * @param p0 defines 1st triangle point
  58796. * @param p1 defines 2nd triangle point
  58797. * @param p2 defines 3rd triangle point
  58798. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58799. */
  58800. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58801. /**
  58802. * Gets the distance between the vectors "value1" and "value2"
  58803. * @param value1 defines first vector
  58804. * @param value2 defines second vector
  58805. * @returns the distance between vectors
  58806. */
  58807. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58808. /**
  58809. * Returns the squared distance between the vectors "value1" and "value2"
  58810. * @param value1 defines first vector
  58811. * @param value2 defines second vector
  58812. * @returns the squared distance between vectors
  58813. */
  58814. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58815. /**
  58816. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58817. * @param value1 defines first vector
  58818. * @param value2 defines second vector
  58819. * @returns a new Vector2
  58820. */
  58821. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58822. /**
  58823. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58824. * @param p defines the middle point
  58825. * @param segA defines one point of the segment
  58826. * @param segB defines the other point of the segment
  58827. * @returns the shortest distance
  58828. */
  58829. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58830. }
  58831. /**
  58832. * Classed used to store (x,y,z) vector representation
  58833. * A Vector3 is the main object used in 3D geometry
  58834. * It can represent etiher the coordinates of a point the space, either a direction
  58835. * Reminder: js uses a left handed forward facing system
  58836. */
  58837. export class Vector3 {
  58838. /**
  58839. * Defines the first coordinates (on X axis)
  58840. */
  58841. x: number;
  58842. /**
  58843. * Defines the second coordinates (on Y axis)
  58844. */
  58845. y: number;
  58846. /**
  58847. * Defines the third coordinates (on Z axis)
  58848. */
  58849. z: number;
  58850. private static _UpReadOnly;
  58851. /**
  58852. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58853. * @param x defines the first coordinates (on X axis)
  58854. * @param y defines the second coordinates (on Y axis)
  58855. * @param z defines the third coordinates (on Z axis)
  58856. */
  58857. constructor(
  58858. /**
  58859. * Defines the first coordinates (on X axis)
  58860. */
  58861. x?: number,
  58862. /**
  58863. * Defines the second coordinates (on Y axis)
  58864. */
  58865. y?: number,
  58866. /**
  58867. * Defines the third coordinates (on Z axis)
  58868. */
  58869. z?: number);
  58870. /**
  58871. * Creates a string representation of the Vector3
  58872. * @returns a string with the Vector3 coordinates.
  58873. */
  58874. toString(): string;
  58875. /**
  58876. * Gets the class name
  58877. * @returns the string "Vector3"
  58878. */
  58879. getClassName(): string;
  58880. /**
  58881. * Creates the Vector3 hash code
  58882. * @returns a number which tends to be unique between Vector3 instances
  58883. */
  58884. getHashCode(): number;
  58885. /**
  58886. * Creates an array containing three elements : the coordinates of the Vector3
  58887. * @returns a new array of numbers
  58888. */
  58889. asArray(): number[];
  58890. /**
  58891. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58892. * @param array defines the destination array
  58893. * @param index defines the offset in the destination array
  58894. * @returns the current Vector3
  58895. */
  58896. toArray(array: FloatArray, index?: number): Vector3;
  58897. /**
  58898. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58899. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58900. */
  58901. toQuaternion(): Quaternion;
  58902. /**
  58903. * Adds the given vector to the current Vector3
  58904. * @param otherVector defines the second operand
  58905. * @returns the current updated Vector3
  58906. */
  58907. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58908. /**
  58909. * Adds the given coordinates to the current Vector3
  58910. * @param x defines the x coordinate of the operand
  58911. * @param y defines the y coordinate of the operand
  58912. * @param z defines the z coordinate of the operand
  58913. * @returns the current updated Vector3
  58914. */
  58915. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58916. /**
  58917. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58918. * @param otherVector defines the second operand
  58919. * @returns the resulting Vector3
  58920. */
  58921. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58922. /**
  58923. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58924. * @param otherVector defines the second operand
  58925. * @param result defines the Vector3 object where to store the result
  58926. * @returns the current Vector3
  58927. */
  58928. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58929. /**
  58930. * Subtract the given vector from the current Vector3
  58931. * @param otherVector defines the second operand
  58932. * @returns the current updated Vector3
  58933. */
  58934. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58935. /**
  58936. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58937. * @param otherVector defines the second operand
  58938. * @returns the resulting Vector3
  58939. */
  58940. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58941. /**
  58942. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58943. * @param otherVector defines the second operand
  58944. * @param result defines the Vector3 object where to store the result
  58945. * @returns the current Vector3
  58946. */
  58947. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58948. /**
  58949. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58950. * @param x defines the x coordinate of the operand
  58951. * @param y defines the y coordinate of the operand
  58952. * @param z defines the z coordinate of the operand
  58953. * @returns the resulting Vector3
  58954. */
  58955. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58956. /**
  58957. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58958. * @param x defines the x coordinate of the operand
  58959. * @param y defines the y coordinate of the operand
  58960. * @param z defines the z coordinate of the operand
  58961. * @param result defines the Vector3 object where to store the result
  58962. * @returns the current Vector3
  58963. */
  58964. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58965. /**
  58966. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58967. * @returns a new Vector3
  58968. */
  58969. negate(): Vector3;
  58970. /**
  58971. * Multiplies the Vector3 coordinates by the float "scale"
  58972. * @param scale defines the multiplier factor
  58973. * @returns the current updated Vector3
  58974. */
  58975. scaleInPlace(scale: number): Vector3;
  58976. /**
  58977. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58978. * @param scale defines the multiplier factor
  58979. * @returns a new Vector3
  58980. */
  58981. scale(scale: number): Vector3;
  58982. /**
  58983. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58984. * @param scale defines the multiplier factor
  58985. * @param result defines the Vector3 object where to store the result
  58986. * @returns the current Vector3
  58987. */
  58988. scaleToRef(scale: number, result: Vector3): Vector3;
  58989. /**
  58990. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58991. * @param scale defines the scale factor
  58992. * @param result defines the Vector3 object where to store the result
  58993. * @returns the unmodified current Vector3
  58994. */
  58995. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58996. /**
  58997. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58998. * @param otherVector defines the second operand
  58999. * @returns true if both vectors are equals
  59000. */
  59001. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59002. /**
  59003. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59004. * @param otherVector defines the second operand
  59005. * @param epsilon defines the minimal distance to define values as equals
  59006. * @returns true if both vectors are distant less than epsilon
  59007. */
  59008. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59009. /**
  59010. * Returns true if the current Vector3 coordinates equals the given floats
  59011. * @param x defines the x coordinate of the operand
  59012. * @param y defines the y coordinate of the operand
  59013. * @param z defines the z coordinate of the operand
  59014. * @returns true if both vectors are equals
  59015. */
  59016. equalsToFloats(x: number, y: number, z: number): boolean;
  59017. /**
  59018. * Multiplies the current Vector3 coordinates by the given ones
  59019. * @param otherVector defines the second operand
  59020. * @returns the current updated Vector3
  59021. */
  59022. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59023. /**
  59024. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59025. * @param otherVector defines the second operand
  59026. * @returns the new Vector3
  59027. */
  59028. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59029. /**
  59030. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59031. * @param otherVector defines the second operand
  59032. * @param result defines the Vector3 object where to store the result
  59033. * @returns the current Vector3
  59034. */
  59035. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59036. /**
  59037. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59038. * @param x defines the x coordinate of the operand
  59039. * @param y defines the y coordinate of the operand
  59040. * @param z defines the z coordinate of the operand
  59041. * @returns the new Vector3
  59042. */
  59043. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59044. /**
  59045. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59046. * @param otherVector defines the second operand
  59047. * @returns the new Vector3
  59048. */
  59049. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59050. /**
  59051. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59052. * @param otherVector defines the second operand
  59053. * @param result defines the Vector3 object where to store the result
  59054. * @returns the current Vector3
  59055. */
  59056. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59057. /**
  59058. * Divides the current Vector3 coordinates by the given ones.
  59059. * @param otherVector defines the second operand
  59060. * @returns the current updated Vector3
  59061. */
  59062. divideInPlace(otherVector: Vector3): Vector3;
  59063. /**
  59064. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59065. * @param other defines the second operand
  59066. * @returns the current updated Vector3
  59067. */
  59068. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59069. /**
  59070. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59071. * @param other defines the second operand
  59072. * @returns the current updated Vector3
  59073. */
  59074. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59075. /**
  59076. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59077. * @param x defines the x coordinate of the operand
  59078. * @param y defines the y coordinate of the operand
  59079. * @param z defines the z coordinate of the operand
  59080. * @returns the current updated Vector3
  59081. */
  59082. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59083. /**
  59084. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59085. * @param x defines the x coordinate of the operand
  59086. * @param y defines the y coordinate of the operand
  59087. * @param z defines the z coordinate of the operand
  59088. * @returns the current updated Vector3
  59089. */
  59090. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59091. /**
  59092. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59093. * Check if is non uniform within a certain amount of decimal places to account for this
  59094. * @param epsilon the amount the values can differ
  59095. * @returns if the the vector is non uniform to a certain number of decimal places
  59096. */
  59097. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59098. /**
  59099. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59100. */
  59101. readonly isNonUniform: boolean;
  59102. /**
  59103. * Gets a new Vector3 from current Vector3 floored values
  59104. * @returns a new Vector3
  59105. */
  59106. floor(): Vector3;
  59107. /**
  59108. * Gets a new Vector3 from current Vector3 floored values
  59109. * @returns a new Vector3
  59110. */
  59111. fract(): Vector3;
  59112. /**
  59113. * Gets the length of the Vector3
  59114. * @returns the length of the Vecto3
  59115. */
  59116. length(): number;
  59117. /**
  59118. * Gets the squared length of the Vector3
  59119. * @returns squared length of the Vector3
  59120. */
  59121. lengthSquared(): number;
  59122. /**
  59123. * Normalize the current Vector3.
  59124. * Please note that this is an in place operation.
  59125. * @returns the current updated Vector3
  59126. */
  59127. normalize(): Vector3;
  59128. /**
  59129. * Reorders the x y z properties of the vector in place
  59130. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59131. * @returns the current updated vector
  59132. */
  59133. reorderInPlace(order: string): this;
  59134. /**
  59135. * Rotates the vector around 0,0,0 by a quaternion
  59136. * @param quaternion the rotation quaternion
  59137. * @param result vector to store the result
  59138. * @returns the resulting vector
  59139. */
  59140. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59141. /**
  59142. * Rotates a vector around a given point
  59143. * @param quaternion the rotation quaternion
  59144. * @param point the point to rotate around
  59145. * @param result vector to store the result
  59146. * @returns the resulting vector
  59147. */
  59148. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59149. /**
  59150. * Normalize the current Vector3 with the given input length.
  59151. * Please note that this is an in place operation.
  59152. * @param len the length of the vector
  59153. * @returns the current updated Vector3
  59154. */
  59155. normalizeFromLength(len: number): Vector3;
  59156. /**
  59157. * Normalize the current Vector3 to a new vector
  59158. * @returns the new Vector3
  59159. */
  59160. normalizeToNew(): Vector3;
  59161. /**
  59162. * Normalize the current Vector3 to the reference
  59163. * @param reference define the Vector3 to update
  59164. * @returns the updated Vector3
  59165. */
  59166. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59167. /**
  59168. * Creates a new Vector3 copied from the current Vector3
  59169. * @returns the new Vector3
  59170. */
  59171. clone(): Vector3;
  59172. /**
  59173. * Copies the given vector coordinates to the current Vector3 ones
  59174. * @param source defines the source Vector3
  59175. * @returns the current updated Vector3
  59176. */
  59177. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59178. /**
  59179. * Copies the given floats to the current Vector3 coordinates
  59180. * @param x defines the x coordinate of the operand
  59181. * @param y defines the y coordinate of the operand
  59182. * @param z defines the z coordinate of the operand
  59183. * @returns the current updated Vector3
  59184. */
  59185. copyFromFloats(x: number, y: number, z: number): Vector3;
  59186. /**
  59187. * Copies the given floats to the current Vector3 coordinates
  59188. * @param x defines the x coordinate of the operand
  59189. * @param y defines the y coordinate of the operand
  59190. * @param z defines the z coordinate of the operand
  59191. * @returns the current updated Vector3
  59192. */
  59193. set(x: number, y: number, z: number): Vector3;
  59194. /**
  59195. * Copies the given float to the current Vector3 coordinates
  59196. * @param v defines the x, y and z coordinates of the operand
  59197. * @returns the current updated Vector3
  59198. */
  59199. setAll(v: number): Vector3;
  59200. /**
  59201. * Get the clip factor between two vectors
  59202. * @param vector0 defines the first operand
  59203. * @param vector1 defines the second operand
  59204. * @param axis defines the axis to use
  59205. * @param size defines the size along the axis
  59206. * @returns the clip factor
  59207. */
  59208. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59209. /**
  59210. * Get angle between two vectors
  59211. * @param vector0 angle between vector0 and vector1
  59212. * @param vector1 angle between vector0 and vector1
  59213. * @param normal direction of the normal
  59214. * @return the angle between vector0 and vector1
  59215. */
  59216. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59217. /**
  59218. * Returns a new Vector3 set from the index "offset" of the given array
  59219. * @param array defines the source array
  59220. * @param offset defines the offset in the source array
  59221. * @returns the new Vector3
  59222. */
  59223. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59224. /**
  59225. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59226. * This function is deprecated. Use FromArray instead
  59227. * @param array defines the source array
  59228. * @param offset defines the offset in the source array
  59229. * @returns the new Vector3
  59230. */
  59231. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59232. /**
  59233. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59234. * @param array defines the source array
  59235. * @param offset defines the offset in the source array
  59236. * @param result defines the Vector3 where to store the result
  59237. */
  59238. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59239. /**
  59240. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59241. * This function is deprecated. Use FromArrayToRef instead.
  59242. * @param array defines the source array
  59243. * @param offset defines the offset in the source array
  59244. * @param result defines the Vector3 where to store the result
  59245. */
  59246. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59247. /**
  59248. * Sets the given vector "result" with the given floats.
  59249. * @param x defines the x coordinate of the source
  59250. * @param y defines the y coordinate of the source
  59251. * @param z defines the z coordinate of the source
  59252. * @param result defines the Vector3 where to store the result
  59253. */
  59254. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59255. /**
  59256. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59257. * @returns a new empty Vector3
  59258. */
  59259. static Zero(): Vector3;
  59260. /**
  59261. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59262. * @returns a new unit Vector3
  59263. */
  59264. static One(): Vector3;
  59265. /**
  59266. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59267. * @returns a new up Vector3
  59268. */
  59269. static Up(): Vector3;
  59270. /**
  59271. * Gets a up Vector3 that must not be updated
  59272. */
  59273. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59274. /**
  59275. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59276. * @returns a new down Vector3
  59277. */
  59278. static Down(): Vector3;
  59279. /**
  59280. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59281. * @returns a new forward Vector3
  59282. */
  59283. static Forward(): Vector3;
  59284. /**
  59285. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59286. * @returns a new forward Vector3
  59287. */
  59288. static Backward(): Vector3;
  59289. /**
  59290. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59291. * @returns a new right Vector3
  59292. */
  59293. static Right(): Vector3;
  59294. /**
  59295. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59296. * @returns a new left Vector3
  59297. */
  59298. static Left(): Vector3;
  59299. /**
  59300. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59301. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59302. * @param vector defines the Vector3 to transform
  59303. * @param transformation defines the transformation matrix
  59304. * @returns the transformed Vector3
  59305. */
  59306. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59307. /**
  59308. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59309. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59310. * @param vector defines the Vector3 to transform
  59311. * @param transformation defines the transformation matrix
  59312. * @param result defines the Vector3 where to store the result
  59313. */
  59314. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59315. /**
  59316. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59317. * This method computes tranformed coordinates only, not transformed direction vectors
  59318. * @param x define the x coordinate of the source vector
  59319. * @param y define the y coordinate of the source vector
  59320. * @param z define the z coordinate of the source vector
  59321. * @param transformation defines the transformation matrix
  59322. * @param result defines the Vector3 where to store the result
  59323. */
  59324. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59325. /**
  59326. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59327. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59328. * @param vector defines the Vector3 to transform
  59329. * @param transformation defines the transformation matrix
  59330. * @returns the new Vector3
  59331. */
  59332. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59333. /**
  59334. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59335. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59336. * @param vector defines the Vector3 to transform
  59337. * @param transformation defines the transformation matrix
  59338. * @param result defines the Vector3 where to store the result
  59339. */
  59340. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59341. /**
  59342. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59343. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59344. * @param x define the x coordinate of the source vector
  59345. * @param y define the y coordinate of the source vector
  59346. * @param z define the z coordinate of the source vector
  59347. * @param transformation defines the transformation matrix
  59348. * @param result defines the Vector3 where to store the result
  59349. */
  59350. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59351. /**
  59352. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59353. * @param value1 defines the first control point
  59354. * @param value2 defines the second control point
  59355. * @param value3 defines the third control point
  59356. * @param value4 defines the fourth control point
  59357. * @param amount defines the amount on the spline to use
  59358. * @returns the new Vector3
  59359. */
  59360. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59361. /**
  59362. * 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"
  59363. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59364. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59365. * @param value defines the current value
  59366. * @param min defines the lower range value
  59367. * @param max defines the upper range value
  59368. * @returns the new Vector3
  59369. */
  59370. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59371. /**
  59372. * 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"
  59373. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59374. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59375. * @param value defines the current value
  59376. * @param min defines the lower range value
  59377. * @param max defines the upper range value
  59378. * @param result defines the Vector3 where to store the result
  59379. */
  59380. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59381. /**
  59382. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59383. * @param value1 defines the first control point
  59384. * @param tangent1 defines the first tangent vector
  59385. * @param value2 defines the second control point
  59386. * @param tangent2 defines the second tangent vector
  59387. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59388. * @returns the new Vector3
  59389. */
  59390. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59391. /**
  59392. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59393. * @param start defines the start value
  59394. * @param end defines the end value
  59395. * @param amount max defines amount between both (between 0 and 1)
  59396. * @returns the new Vector3
  59397. */
  59398. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59399. /**
  59400. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59401. * @param start defines the start value
  59402. * @param end defines the end value
  59403. * @param amount max defines amount between both (between 0 and 1)
  59404. * @param result defines the Vector3 where to store the result
  59405. */
  59406. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59407. /**
  59408. * Returns the dot product (float) between the vectors "left" and "right"
  59409. * @param left defines the left operand
  59410. * @param right defines the right operand
  59411. * @returns the dot product
  59412. */
  59413. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59414. /**
  59415. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59416. * The cross product is then orthogonal to both "left" and "right"
  59417. * @param left defines the left operand
  59418. * @param right defines the right operand
  59419. * @returns the cross product
  59420. */
  59421. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59422. /**
  59423. * Sets the given vector "result" with the cross product of "left" and "right"
  59424. * The cross product is then orthogonal to both "left" and "right"
  59425. * @param left defines the left operand
  59426. * @param right defines the right operand
  59427. * @param result defines the Vector3 where to store the result
  59428. */
  59429. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59430. /**
  59431. * Returns a new Vector3 as the normalization of the given vector
  59432. * @param vector defines the Vector3 to normalize
  59433. * @returns the new Vector3
  59434. */
  59435. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59436. /**
  59437. * Sets the given vector "result" with the normalization of the given first vector
  59438. * @param vector defines the Vector3 to normalize
  59439. * @param result defines the Vector3 where to store the result
  59440. */
  59441. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59442. /**
  59443. * Project a Vector3 onto screen space
  59444. * @param vector defines the Vector3 to project
  59445. * @param world defines the world matrix to use
  59446. * @param transform defines the transform (view x projection) matrix to use
  59447. * @param viewport defines the screen viewport to use
  59448. * @returns the new Vector3
  59449. */
  59450. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59451. /** @hidden */
  59452. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59453. /**
  59454. * Unproject from screen space to object space
  59455. * @param source defines the screen space Vector3 to use
  59456. * @param viewportWidth defines the current width of the viewport
  59457. * @param viewportHeight defines the current height of the viewport
  59458. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59459. * @param transform defines the transform (view x projection) matrix to use
  59460. * @returns the new Vector3
  59461. */
  59462. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59463. /**
  59464. * Unproject from screen space to object space
  59465. * @param source defines the screen space Vector3 to use
  59466. * @param viewportWidth defines the current width of the viewport
  59467. * @param viewportHeight defines the current height of the viewport
  59468. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59469. * @param view defines the view matrix to use
  59470. * @param projection defines the projection matrix to use
  59471. * @returns the new Vector3
  59472. */
  59473. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59474. /**
  59475. * Unproject from screen space to object space
  59476. * @param source defines the screen space Vector3 to use
  59477. * @param viewportWidth defines the current width of the viewport
  59478. * @param viewportHeight defines the current height of the viewport
  59479. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59480. * @param view defines the view matrix to use
  59481. * @param projection defines the projection matrix to use
  59482. * @param result defines the Vector3 where to store the result
  59483. */
  59484. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59485. /**
  59486. * Unproject from screen space to object space
  59487. * @param sourceX defines the screen space x coordinate to use
  59488. * @param sourceY defines the screen space y coordinate to use
  59489. * @param sourceZ defines the screen space z coordinate to use
  59490. * @param viewportWidth defines the current width of the viewport
  59491. * @param viewportHeight defines the current height of the viewport
  59492. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59493. * @param view defines the view matrix to use
  59494. * @param projection defines the projection matrix to use
  59495. * @param result defines the Vector3 where to store the result
  59496. */
  59497. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59498. /**
  59499. * Gets the minimal coordinate values between two Vector3
  59500. * @param left defines the first operand
  59501. * @param right defines the second operand
  59502. * @returns the new Vector3
  59503. */
  59504. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59505. /**
  59506. * Gets the maximal coordinate values between two Vector3
  59507. * @param left defines the first operand
  59508. * @param right defines the second operand
  59509. * @returns the new Vector3
  59510. */
  59511. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59512. /**
  59513. * Returns the distance between the vectors "value1" and "value2"
  59514. * @param value1 defines the first operand
  59515. * @param value2 defines the second operand
  59516. * @returns the distance
  59517. */
  59518. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59519. /**
  59520. * Returns the squared distance between the vectors "value1" and "value2"
  59521. * @param value1 defines the first operand
  59522. * @param value2 defines the second operand
  59523. * @returns the squared distance
  59524. */
  59525. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59526. /**
  59527. * Returns a new Vector3 located at the center between "value1" and "value2"
  59528. * @param value1 defines the first operand
  59529. * @param value2 defines the second operand
  59530. * @returns the new Vector3
  59531. */
  59532. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59533. /**
  59534. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59535. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59536. * to something in order to rotate it from its local system to the given target system
  59537. * Note: axis1, axis2 and axis3 are normalized during this operation
  59538. * @param axis1 defines the first axis
  59539. * @param axis2 defines the second axis
  59540. * @param axis3 defines the third axis
  59541. * @returns a new Vector3
  59542. */
  59543. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59544. /**
  59545. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59546. * @param axis1 defines the first axis
  59547. * @param axis2 defines the second axis
  59548. * @param axis3 defines the third axis
  59549. * @param ref defines the Vector3 where to store the result
  59550. */
  59551. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59552. }
  59553. /**
  59554. * Vector4 class created for EulerAngle class conversion to Quaternion
  59555. */
  59556. export class Vector4 {
  59557. /** x value of the vector */
  59558. x: number;
  59559. /** y value of the vector */
  59560. y: number;
  59561. /** z value of the vector */
  59562. z: number;
  59563. /** w value of the vector */
  59564. w: number;
  59565. /**
  59566. * Creates a Vector4 object from the given floats.
  59567. * @param x x value of the vector
  59568. * @param y y value of the vector
  59569. * @param z z value of the vector
  59570. * @param w w value of the vector
  59571. */
  59572. constructor(
  59573. /** x value of the vector */
  59574. x: number,
  59575. /** y value of the vector */
  59576. y: number,
  59577. /** z value of the vector */
  59578. z: number,
  59579. /** w value of the vector */
  59580. w: number);
  59581. /**
  59582. * Returns the string with the Vector4 coordinates.
  59583. * @returns a string containing all the vector values
  59584. */
  59585. toString(): string;
  59586. /**
  59587. * Returns the string "Vector4".
  59588. * @returns "Vector4"
  59589. */
  59590. getClassName(): string;
  59591. /**
  59592. * Returns the Vector4 hash code.
  59593. * @returns a unique hash code
  59594. */
  59595. getHashCode(): number;
  59596. /**
  59597. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59598. * @returns the resulting array
  59599. */
  59600. asArray(): number[];
  59601. /**
  59602. * Populates the given array from the given index with the Vector4 coordinates.
  59603. * @param array array to populate
  59604. * @param index index of the array to start at (default: 0)
  59605. * @returns the Vector4.
  59606. */
  59607. toArray(array: FloatArray, index?: number): Vector4;
  59608. /**
  59609. * Adds the given vector to the current Vector4.
  59610. * @param otherVector the vector to add
  59611. * @returns the updated Vector4.
  59612. */
  59613. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59614. /**
  59615. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59616. * @param otherVector the vector to add
  59617. * @returns the resulting vector
  59618. */
  59619. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59620. /**
  59621. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59622. * @param otherVector the vector to add
  59623. * @param result the vector to store the result
  59624. * @returns the current Vector4.
  59625. */
  59626. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59627. /**
  59628. * Subtract in place the given vector from the current Vector4.
  59629. * @param otherVector the vector to subtract
  59630. * @returns the updated Vector4.
  59631. */
  59632. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59633. /**
  59634. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59635. * @param otherVector the vector to add
  59636. * @returns the new vector with the result
  59637. */
  59638. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59639. /**
  59640. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59641. * @param otherVector the vector to subtract
  59642. * @param result the vector to store the result
  59643. * @returns the current Vector4.
  59644. */
  59645. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59646. /**
  59647. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59648. */
  59649. /**
  59650. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59651. * @param x value to subtract
  59652. * @param y value to subtract
  59653. * @param z value to subtract
  59654. * @param w value to subtract
  59655. * @returns new vector containing the result
  59656. */
  59657. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59658. /**
  59659. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59660. * @param x value to subtract
  59661. * @param y value to subtract
  59662. * @param z value to subtract
  59663. * @param w value to subtract
  59664. * @param result the vector to store the result in
  59665. * @returns the current Vector4.
  59666. */
  59667. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59668. /**
  59669. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59670. * @returns a new vector with the negated values
  59671. */
  59672. negate(): Vector4;
  59673. /**
  59674. * Multiplies the current Vector4 coordinates by scale (float).
  59675. * @param scale the number to scale with
  59676. * @returns the updated Vector4.
  59677. */
  59678. scaleInPlace(scale: number): Vector4;
  59679. /**
  59680. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59681. * @param scale the number to scale with
  59682. * @returns a new vector with the result
  59683. */
  59684. scale(scale: number): Vector4;
  59685. /**
  59686. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59687. * @param scale the number to scale with
  59688. * @param result a vector to store the result in
  59689. * @returns the current Vector4.
  59690. */
  59691. scaleToRef(scale: number, result: Vector4): Vector4;
  59692. /**
  59693. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59694. * @param scale defines the scale factor
  59695. * @param result defines the Vector4 object where to store the result
  59696. * @returns the unmodified current Vector4
  59697. */
  59698. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59699. /**
  59700. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59701. * @param otherVector the vector to compare against
  59702. * @returns true if they are equal
  59703. */
  59704. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59705. /**
  59706. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59707. * @param otherVector vector to compare against
  59708. * @param epsilon (Default: very small number)
  59709. * @returns true if they are equal
  59710. */
  59711. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59712. /**
  59713. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59714. * @param x x value to compare against
  59715. * @param y y value to compare against
  59716. * @param z z value to compare against
  59717. * @param w w value to compare against
  59718. * @returns true if equal
  59719. */
  59720. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59721. /**
  59722. * Multiplies in place the current Vector4 by the given one.
  59723. * @param otherVector vector to multiple with
  59724. * @returns the updated Vector4.
  59725. */
  59726. multiplyInPlace(otherVector: Vector4): Vector4;
  59727. /**
  59728. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59729. * @param otherVector vector to multiple with
  59730. * @returns resulting new vector
  59731. */
  59732. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59733. /**
  59734. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59735. * @param otherVector vector to multiple with
  59736. * @param result vector to store the result
  59737. * @returns the current Vector4.
  59738. */
  59739. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59740. /**
  59741. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59742. * @param x x value multiply with
  59743. * @param y y value multiply with
  59744. * @param z z value multiply with
  59745. * @param w w value multiply with
  59746. * @returns resulting new vector
  59747. */
  59748. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59749. /**
  59750. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59751. * @param otherVector vector to devide with
  59752. * @returns resulting new vector
  59753. */
  59754. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59755. /**
  59756. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59757. * @param otherVector vector to devide with
  59758. * @param result vector to store the result
  59759. * @returns the current Vector4.
  59760. */
  59761. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59762. /**
  59763. * Divides the current Vector3 coordinates by the given ones.
  59764. * @param otherVector vector to devide with
  59765. * @returns the updated Vector3.
  59766. */
  59767. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59768. /**
  59769. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59770. * @param other defines the second operand
  59771. * @returns the current updated Vector4
  59772. */
  59773. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59774. /**
  59775. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59776. * @param other defines the second operand
  59777. * @returns the current updated Vector4
  59778. */
  59779. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59780. /**
  59781. * Gets a new Vector4 from current Vector4 floored values
  59782. * @returns a new Vector4
  59783. */
  59784. floor(): Vector4;
  59785. /**
  59786. * Gets a new Vector4 from current Vector3 floored values
  59787. * @returns a new Vector4
  59788. */
  59789. fract(): Vector4;
  59790. /**
  59791. * Returns the Vector4 length (float).
  59792. * @returns the length
  59793. */
  59794. length(): number;
  59795. /**
  59796. * Returns the Vector4 squared length (float).
  59797. * @returns the length squared
  59798. */
  59799. lengthSquared(): number;
  59800. /**
  59801. * Normalizes in place the Vector4.
  59802. * @returns the updated Vector4.
  59803. */
  59804. normalize(): Vector4;
  59805. /**
  59806. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59807. * @returns this converted to a new vector3
  59808. */
  59809. toVector3(): Vector3;
  59810. /**
  59811. * Returns a new Vector4 copied from the current one.
  59812. * @returns the new cloned vector
  59813. */
  59814. clone(): Vector4;
  59815. /**
  59816. * Updates the current Vector4 with the given one coordinates.
  59817. * @param source the source vector to copy from
  59818. * @returns the updated Vector4.
  59819. */
  59820. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59821. /**
  59822. * Updates the current Vector4 coordinates with the given floats.
  59823. * @param x float to copy from
  59824. * @param y float to copy from
  59825. * @param z float to copy from
  59826. * @param w float to copy from
  59827. * @returns the updated Vector4.
  59828. */
  59829. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59830. /**
  59831. * Updates the current Vector4 coordinates with the given floats.
  59832. * @param x float to set from
  59833. * @param y float to set from
  59834. * @param z float to set from
  59835. * @param w float to set from
  59836. * @returns the updated Vector4.
  59837. */
  59838. set(x: number, y: number, z: number, w: number): Vector4;
  59839. /**
  59840. * Copies the given float to the current Vector3 coordinates
  59841. * @param v defines the x, y, z and w coordinates of the operand
  59842. * @returns the current updated Vector3
  59843. */
  59844. setAll(v: number): Vector4;
  59845. /**
  59846. * Returns a new Vector4 set from the starting index of the given array.
  59847. * @param array the array to pull values from
  59848. * @param offset the offset into the array to start at
  59849. * @returns the new vector
  59850. */
  59851. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59852. /**
  59853. * Updates the given vector "result" from the starting index of the given array.
  59854. * @param array the array to pull values from
  59855. * @param offset the offset into the array to start at
  59856. * @param result the vector to store the result in
  59857. */
  59858. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59859. /**
  59860. * Updates the given vector "result" from the starting index of the given Float32Array.
  59861. * @param array the array to pull values from
  59862. * @param offset the offset into the array to start at
  59863. * @param result the vector to store the result in
  59864. */
  59865. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59866. /**
  59867. * Updates the given vector "result" coordinates from the given floats.
  59868. * @param x float to set from
  59869. * @param y float to set from
  59870. * @param z float to set from
  59871. * @param w float to set from
  59872. * @param result the vector to the floats in
  59873. */
  59874. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59875. /**
  59876. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59877. * @returns the new vector
  59878. */
  59879. static Zero(): Vector4;
  59880. /**
  59881. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59882. * @returns the new vector
  59883. */
  59884. static One(): Vector4;
  59885. /**
  59886. * Returns a new normalized Vector4 from the given one.
  59887. * @param vector the vector to normalize
  59888. * @returns the vector
  59889. */
  59890. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59891. /**
  59892. * Updates the given vector "result" from the normalization of the given one.
  59893. * @param vector the vector to normalize
  59894. * @param result the vector to store the result in
  59895. */
  59896. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59897. /**
  59898. * Returns a vector with the minimum values from the left and right vectors
  59899. * @param left left vector to minimize
  59900. * @param right right vector to minimize
  59901. * @returns a new vector with the minimum of the left and right vector values
  59902. */
  59903. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59904. /**
  59905. * Returns a vector with the maximum values from the left and right vectors
  59906. * @param left left vector to maximize
  59907. * @param right right vector to maximize
  59908. * @returns a new vector with the maximum of the left and right vector values
  59909. */
  59910. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59911. /**
  59912. * Returns the distance (float) between the vectors "value1" and "value2".
  59913. * @param value1 value to calulate the distance between
  59914. * @param value2 value to calulate the distance between
  59915. * @return the distance between the two vectors
  59916. */
  59917. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59918. /**
  59919. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59920. * @param value1 value to calulate the distance between
  59921. * @param value2 value to calulate the distance between
  59922. * @return the distance between the two vectors squared
  59923. */
  59924. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59925. /**
  59926. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59927. * @param value1 value to calulate the center between
  59928. * @param value2 value to calulate the center between
  59929. * @return the center between the two vectors
  59930. */
  59931. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59932. /**
  59933. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59934. * This methods computes transformed normalized direction vectors only.
  59935. * @param vector the vector to transform
  59936. * @param transformation the transformation matrix to apply
  59937. * @returns the new vector
  59938. */
  59939. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59940. /**
  59941. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59942. * This methods computes transformed normalized direction vectors only.
  59943. * @param vector the vector to transform
  59944. * @param transformation the transformation matrix to apply
  59945. * @param result the vector to store the result in
  59946. */
  59947. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59948. /**
  59949. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59950. * This methods computes transformed normalized direction vectors only.
  59951. * @param x value to transform
  59952. * @param y value to transform
  59953. * @param z value to transform
  59954. * @param w value to transform
  59955. * @param transformation the transformation matrix to apply
  59956. * @param result the vector to store the results in
  59957. */
  59958. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59959. /**
  59960. * Creates a new Vector4 from a Vector3
  59961. * @param source defines the source data
  59962. * @param w defines the 4th component (default is 0)
  59963. * @returns a new Vector4
  59964. */
  59965. static FromVector3(source: Vector3, w?: number): Vector4;
  59966. }
  59967. /**
  59968. * Interface for the size containing width and height
  59969. */
  59970. export interface ISize {
  59971. /**
  59972. * Width
  59973. */
  59974. width: number;
  59975. /**
  59976. * Heighht
  59977. */
  59978. height: number;
  59979. }
  59980. /**
  59981. * Size containing widht and height
  59982. */
  59983. export class Size implements ISize {
  59984. /**
  59985. * Width
  59986. */
  59987. width: number;
  59988. /**
  59989. * Height
  59990. */
  59991. height: number;
  59992. /**
  59993. * Creates a Size object from the given width and height (floats).
  59994. * @param width width of the new size
  59995. * @param height height of the new size
  59996. */
  59997. constructor(width: number, height: number);
  59998. /**
  59999. * Returns a string with the Size width and height
  60000. * @returns a string with the Size width and height
  60001. */
  60002. toString(): string;
  60003. /**
  60004. * "Size"
  60005. * @returns the string "Size"
  60006. */
  60007. getClassName(): string;
  60008. /**
  60009. * Returns the Size hash code.
  60010. * @returns a hash code for a unique width and height
  60011. */
  60012. getHashCode(): number;
  60013. /**
  60014. * Updates the current size from the given one.
  60015. * @param src the given size
  60016. */
  60017. copyFrom(src: Size): void;
  60018. /**
  60019. * Updates in place the current Size from the given floats.
  60020. * @param width width of the new size
  60021. * @param height height of the new size
  60022. * @returns the updated Size.
  60023. */
  60024. copyFromFloats(width: number, height: number): Size;
  60025. /**
  60026. * Updates in place the current Size from the given floats.
  60027. * @param width width to set
  60028. * @param height height to set
  60029. * @returns the updated Size.
  60030. */
  60031. set(width: number, height: number): Size;
  60032. /**
  60033. * Multiplies the width and height by numbers
  60034. * @param w factor to multiple the width by
  60035. * @param h factor to multiple the height by
  60036. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60037. */
  60038. multiplyByFloats(w: number, h: number): Size;
  60039. /**
  60040. * Clones the size
  60041. * @returns a new Size copied from the given one.
  60042. */
  60043. clone(): Size;
  60044. /**
  60045. * True if the current Size and the given one width and height are strictly equal.
  60046. * @param other the other size to compare against
  60047. * @returns True if the current Size and the given one width and height are strictly equal.
  60048. */
  60049. equals(other: Size): boolean;
  60050. /**
  60051. * The surface of the Size : width * height (float).
  60052. */
  60053. readonly surface: number;
  60054. /**
  60055. * Create a new size of zero
  60056. * @returns a new Size set to (0.0, 0.0)
  60057. */
  60058. static Zero(): Size;
  60059. /**
  60060. * Sums the width and height of two sizes
  60061. * @param otherSize size to add to this size
  60062. * @returns a new Size set as the addition result of the current Size and the given one.
  60063. */
  60064. add(otherSize: Size): Size;
  60065. /**
  60066. * Subtracts the width and height of two
  60067. * @param otherSize size to subtract to this size
  60068. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60069. */
  60070. subtract(otherSize: Size): Size;
  60071. /**
  60072. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60073. * @param start starting size to lerp between
  60074. * @param end end size to lerp between
  60075. * @param amount amount to lerp between the start and end values
  60076. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60077. */
  60078. static Lerp(start: Size, end: Size, amount: number): Size;
  60079. }
  60080. /**
  60081. * Class used to store quaternion data
  60082. * @see https://en.wikipedia.org/wiki/Quaternion
  60083. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60084. */
  60085. export class Quaternion {
  60086. /** defines the first component (0 by default) */
  60087. x: number;
  60088. /** defines the second component (0 by default) */
  60089. y: number;
  60090. /** defines the third component (0 by default) */
  60091. z: number;
  60092. /** defines the fourth component (1.0 by default) */
  60093. w: number;
  60094. /**
  60095. * Creates a new Quaternion from the given floats
  60096. * @param x defines the first component (0 by default)
  60097. * @param y defines the second component (0 by default)
  60098. * @param z defines the third component (0 by default)
  60099. * @param w defines the fourth component (1.0 by default)
  60100. */
  60101. constructor(
  60102. /** defines the first component (0 by default) */
  60103. x?: number,
  60104. /** defines the second component (0 by default) */
  60105. y?: number,
  60106. /** defines the third component (0 by default) */
  60107. z?: number,
  60108. /** defines the fourth component (1.0 by default) */
  60109. w?: number);
  60110. /**
  60111. * Gets a string representation for the current quaternion
  60112. * @returns a string with the Quaternion coordinates
  60113. */
  60114. toString(): string;
  60115. /**
  60116. * Gets the class name of the quaternion
  60117. * @returns the string "Quaternion"
  60118. */
  60119. getClassName(): string;
  60120. /**
  60121. * Gets a hash code for this quaternion
  60122. * @returns the quaternion hash code
  60123. */
  60124. getHashCode(): number;
  60125. /**
  60126. * Copy the quaternion to an array
  60127. * @returns a new array populated with 4 elements from the quaternion coordinates
  60128. */
  60129. asArray(): number[];
  60130. /**
  60131. * Check if two quaternions are equals
  60132. * @param otherQuaternion defines the second operand
  60133. * @return true if the current quaternion and the given one coordinates are strictly equals
  60134. */
  60135. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60136. /**
  60137. * Clone the current quaternion
  60138. * @returns a new quaternion copied from the current one
  60139. */
  60140. clone(): Quaternion;
  60141. /**
  60142. * Copy a quaternion to the current one
  60143. * @param other defines the other quaternion
  60144. * @returns the updated current quaternion
  60145. */
  60146. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60147. /**
  60148. * Updates the current quaternion with the given float coordinates
  60149. * @param x defines the x coordinate
  60150. * @param y defines the y coordinate
  60151. * @param z defines the z coordinate
  60152. * @param w defines the w coordinate
  60153. * @returns the updated current quaternion
  60154. */
  60155. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60156. /**
  60157. * Updates the current quaternion from the given float coordinates
  60158. * @param x defines the x coordinate
  60159. * @param y defines the y coordinate
  60160. * @param z defines the z coordinate
  60161. * @param w defines the w coordinate
  60162. * @returns the updated current quaternion
  60163. */
  60164. set(x: number, y: number, z: number, w: number): Quaternion;
  60165. /**
  60166. * Adds two quaternions
  60167. * @param other defines the second operand
  60168. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60169. */
  60170. add(other: DeepImmutable<Quaternion>): Quaternion;
  60171. /**
  60172. * Add a quaternion to the current one
  60173. * @param other defines the quaternion to add
  60174. * @returns the current quaternion
  60175. */
  60176. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60177. /**
  60178. * Subtract two quaternions
  60179. * @param other defines the second operand
  60180. * @returns a new quaternion as the subtraction result of the given one from the current one
  60181. */
  60182. subtract(other: Quaternion): Quaternion;
  60183. /**
  60184. * Multiplies the current quaternion by a scale factor
  60185. * @param value defines the scale factor
  60186. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60187. */
  60188. scale(value: number): Quaternion;
  60189. /**
  60190. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60191. * @param scale defines the scale factor
  60192. * @param result defines the Quaternion object where to store the result
  60193. * @returns the unmodified current quaternion
  60194. */
  60195. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60196. /**
  60197. * Multiplies in place the current quaternion by a scale factor
  60198. * @param value defines the scale factor
  60199. * @returns the current modified quaternion
  60200. */
  60201. scaleInPlace(value: number): Quaternion;
  60202. /**
  60203. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60204. * @param scale defines the scale factor
  60205. * @param result defines the Quaternion object where to store the result
  60206. * @returns the unmodified current quaternion
  60207. */
  60208. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60209. /**
  60210. * Multiplies two quaternions
  60211. * @param q1 defines the second operand
  60212. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60213. */
  60214. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60215. /**
  60216. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60217. * @param q1 defines the second operand
  60218. * @param result defines the target quaternion
  60219. * @returns the current quaternion
  60220. */
  60221. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60222. /**
  60223. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60224. * @param q1 defines the second operand
  60225. * @returns the currentupdated quaternion
  60226. */
  60227. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60228. /**
  60229. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60230. * @param ref defines the target quaternion
  60231. * @returns the current quaternion
  60232. */
  60233. conjugateToRef(ref: Quaternion): Quaternion;
  60234. /**
  60235. * Conjugates in place (1-q) the current quaternion
  60236. * @returns the current updated quaternion
  60237. */
  60238. conjugateInPlace(): Quaternion;
  60239. /**
  60240. * Conjugates in place (1-q) the current quaternion
  60241. * @returns a new quaternion
  60242. */
  60243. conjugate(): Quaternion;
  60244. /**
  60245. * Gets length of current quaternion
  60246. * @returns the quaternion length (float)
  60247. */
  60248. length(): number;
  60249. /**
  60250. * Normalize in place the current quaternion
  60251. * @returns the current updated quaternion
  60252. */
  60253. normalize(): Quaternion;
  60254. /**
  60255. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60256. * @param order is a reserved parameter and is ignore for now
  60257. * @returns a new Vector3 containing the Euler angles
  60258. */
  60259. toEulerAngles(order?: string): Vector3;
  60260. /**
  60261. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60262. * @param result defines the vector which will be filled with the Euler angles
  60263. * @param order is a reserved parameter and is ignore for now
  60264. * @returns the current unchanged quaternion
  60265. */
  60266. toEulerAnglesToRef(result: Vector3): Quaternion;
  60267. /**
  60268. * Updates the given rotation matrix with the current quaternion values
  60269. * @param result defines the target matrix
  60270. * @returns the current unchanged quaternion
  60271. */
  60272. toRotationMatrix(result: Matrix): Quaternion;
  60273. /**
  60274. * Updates the current quaternion from the given rotation matrix values
  60275. * @param matrix defines the source matrix
  60276. * @returns the current updated quaternion
  60277. */
  60278. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60279. /**
  60280. * Creates a new quaternion from a rotation matrix
  60281. * @param matrix defines the source matrix
  60282. * @returns a new quaternion created from the given rotation matrix values
  60283. */
  60284. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60285. /**
  60286. * Updates the given quaternion with the given rotation matrix values
  60287. * @param matrix defines the source matrix
  60288. * @param result defines the target quaternion
  60289. */
  60290. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60291. /**
  60292. * Returns the dot product (float) between the quaternions "left" and "right"
  60293. * @param left defines the left operand
  60294. * @param right defines the right operand
  60295. * @returns the dot product
  60296. */
  60297. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60298. /**
  60299. * Checks if the two quaternions are close to each other
  60300. * @param quat0 defines the first quaternion to check
  60301. * @param quat1 defines the second quaternion to check
  60302. * @returns true if the two quaternions are close to each other
  60303. */
  60304. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60305. /**
  60306. * Creates an empty quaternion
  60307. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60308. */
  60309. static Zero(): Quaternion;
  60310. /**
  60311. * Inverse a given quaternion
  60312. * @param q defines the source quaternion
  60313. * @returns a new quaternion as the inverted current quaternion
  60314. */
  60315. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60316. /**
  60317. * Inverse a given quaternion
  60318. * @param q defines the source quaternion
  60319. * @param result the quaternion the result will be stored in
  60320. * @returns the result quaternion
  60321. */
  60322. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60323. /**
  60324. * Creates an identity quaternion
  60325. * @returns the identity quaternion
  60326. */
  60327. static Identity(): Quaternion;
  60328. /**
  60329. * Gets a boolean indicating if the given quaternion is identity
  60330. * @param quaternion defines the quaternion to check
  60331. * @returns true if the quaternion is identity
  60332. */
  60333. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60334. /**
  60335. * Creates a quaternion from a rotation around an axis
  60336. * @param axis defines the axis to use
  60337. * @param angle defines the angle to use
  60338. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60339. */
  60340. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60341. /**
  60342. * Creates a rotation around an axis and stores it into the given quaternion
  60343. * @param axis defines the axis to use
  60344. * @param angle defines the angle to use
  60345. * @param result defines the target quaternion
  60346. * @returns the target quaternion
  60347. */
  60348. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60349. /**
  60350. * Creates a new quaternion from data stored into an array
  60351. * @param array defines the data source
  60352. * @param offset defines the offset in the source array where the data starts
  60353. * @returns a new quaternion
  60354. */
  60355. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60356. /**
  60357. * Create a quaternion from Euler rotation angles
  60358. * @param x Pitch
  60359. * @param y Yaw
  60360. * @param z Roll
  60361. * @returns the new Quaternion
  60362. */
  60363. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60364. /**
  60365. * Updates a quaternion from Euler rotation angles
  60366. * @param x Pitch
  60367. * @param y Yaw
  60368. * @param z Roll
  60369. * @param result the quaternion to store the result
  60370. * @returns the updated quaternion
  60371. */
  60372. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60373. /**
  60374. * Create a quaternion from Euler rotation vector
  60375. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60376. * @returns the new Quaternion
  60377. */
  60378. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60379. /**
  60380. * Updates a quaternion from Euler rotation vector
  60381. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60382. * @param result the quaternion to store the result
  60383. * @returns the updated quaternion
  60384. */
  60385. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60386. /**
  60387. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60388. * @param yaw defines the rotation around Y axis
  60389. * @param pitch defines the rotation around X axis
  60390. * @param roll defines the rotation around Z axis
  60391. * @returns the new quaternion
  60392. */
  60393. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60394. /**
  60395. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60396. * @param yaw defines the rotation around Y axis
  60397. * @param pitch defines the rotation around X axis
  60398. * @param roll defines the rotation around Z axis
  60399. * @param result defines the target quaternion
  60400. */
  60401. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60402. /**
  60403. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60404. * @param alpha defines the rotation around first axis
  60405. * @param beta defines the rotation around second axis
  60406. * @param gamma defines the rotation around third axis
  60407. * @returns the new quaternion
  60408. */
  60409. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60410. /**
  60411. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60412. * @param alpha defines the rotation around first axis
  60413. * @param beta defines the rotation around second axis
  60414. * @param gamma defines the rotation around third axis
  60415. * @param result defines the target quaternion
  60416. */
  60417. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60418. /**
  60419. * 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)
  60420. * @param axis1 defines the first axis
  60421. * @param axis2 defines the second axis
  60422. * @param axis3 defines the third axis
  60423. * @returns the new quaternion
  60424. */
  60425. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60426. /**
  60427. * 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
  60428. * @param axis1 defines the first axis
  60429. * @param axis2 defines the second axis
  60430. * @param axis3 defines the third axis
  60431. * @param ref defines the target quaternion
  60432. */
  60433. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60434. /**
  60435. * Interpolates between two quaternions
  60436. * @param left defines first quaternion
  60437. * @param right defines second quaternion
  60438. * @param amount defines the gradient to use
  60439. * @returns the new interpolated quaternion
  60440. */
  60441. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60442. /**
  60443. * Interpolates between two quaternions and stores it into a target quaternion
  60444. * @param left defines first quaternion
  60445. * @param right defines second quaternion
  60446. * @param amount defines the gradient to use
  60447. * @param result defines the target quaternion
  60448. */
  60449. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60450. /**
  60451. * Interpolate between two quaternions using Hermite interpolation
  60452. * @param value1 defines first quaternion
  60453. * @param tangent1 defines the incoming tangent
  60454. * @param value2 defines second quaternion
  60455. * @param tangent2 defines the outgoing tangent
  60456. * @param amount defines the target quaternion
  60457. * @returns the new interpolated quaternion
  60458. */
  60459. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60460. }
  60461. /**
  60462. * Class used to store matrix data (4x4)
  60463. */
  60464. export class Matrix {
  60465. private static _updateFlagSeed;
  60466. private static _identityReadOnly;
  60467. private _isIdentity;
  60468. private _isIdentityDirty;
  60469. private _isIdentity3x2;
  60470. private _isIdentity3x2Dirty;
  60471. /**
  60472. * Gets the update flag of the matrix which is an unique number for the matrix.
  60473. * It will be incremented every time the matrix data change.
  60474. * You can use it to speed the comparison between two versions of the same matrix.
  60475. */
  60476. updateFlag: number;
  60477. private readonly _m;
  60478. /**
  60479. * Gets the internal data of the matrix
  60480. */
  60481. readonly m: DeepImmutable<Float32Array>;
  60482. /** @hidden */
  60483. _markAsUpdated(): void;
  60484. /** @hidden */
  60485. private _updateIdentityStatus;
  60486. /**
  60487. * Creates an empty matrix (filled with zeros)
  60488. */
  60489. constructor();
  60490. /**
  60491. * Check if the current matrix is identity
  60492. * @returns true is the matrix is the identity matrix
  60493. */
  60494. isIdentity(): boolean;
  60495. /**
  60496. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60497. * @returns true is the matrix is the identity matrix
  60498. */
  60499. isIdentityAs3x2(): boolean;
  60500. /**
  60501. * Gets the determinant of the matrix
  60502. * @returns the matrix determinant
  60503. */
  60504. determinant(): number;
  60505. /**
  60506. * Returns the matrix as a Float32Array
  60507. * @returns the matrix underlying array
  60508. */
  60509. toArray(): DeepImmutable<Float32Array>;
  60510. /**
  60511. * Returns the matrix as a Float32Array
  60512. * @returns the matrix underlying array.
  60513. */
  60514. asArray(): DeepImmutable<Float32Array>;
  60515. /**
  60516. * Inverts the current matrix in place
  60517. * @returns the current inverted matrix
  60518. */
  60519. invert(): Matrix;
  60520. /**
  60521. * Sets all the matrix elements to zero
  60522. * @returns the current matrix
  60523. */
  60524. reset(): Matrix;
  60525. /**
  60526. * Adds the current matrix with a second one
  60527. * @param other defines the matrix to add
  60528. * @returns a new matrix as the addition of the current matrix and the given one
  60529. */
  60530. add(other: DeepImmutable<Matrix>): Matrix;
  60531. /**
  60532. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60533. * @param other defines the matrix to add
  60534. * @param result defines the target matrix
  60535. * @returns the current matrix
  60536. */
  60537. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60538. /**
  60539. * Adds in place the given matrix to the current matrix
  60540. * @param other defines the second operand
  60541. * @returns the current updated matrix
  60542. */
  60543. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60544. /**
  60545. * Sets the given matrix to the current inverted Matrix
  60546. * @param other defines the target matrix
  60547. * @returns the unmodified current matrix
  60548. */
  60549. invertToRef(other: Matrix): Matrix;
  60550. /**
  60551. * add a value at the specified position in the current Matrix
  60552. * @param index the index of the value within the matrix. between 0 and 15.
  60553. * @param value the value to be added
  60554. * @returns the current updated matrix
  60555. */
  60556. addAtIndex(index: number, value: number): Matrix;
  60557. /**
  60558. * mutiply the specified position in the current Matrix by a value
  60559. * @param index the index of the value within the matrix. between 0 and 15.
  60560. * @param value the value to be added
  60561. * @returns the current updated matrix
  60562. */
  60563. multiplyAtIndex(index: number, value: number): Matrix;
  60564. /**
  60565. * Inserts the translation vector (using 3 floats) in the current matrix
  60566. * @param x defines the 1st component of the translation
  60567. * @param y defines the 2nd component of the translation
  60568. * @param z defines the 3rd component of the translation
  60569. * @returns the current updated matrix
  60570. */
  60571. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60572. /**
  60573. * Inserts the translation vector in the current matrix
  60574. * @param vector3 defines the translation to insert
  60575. * @returns the current updated matrix
  60576. */
  60577. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60578. /**
  60579. * Gets the translation value of the current matrix
  60580. * @returns a new Vector3 as the extracted translation from the matrix
  60581. */
  60582. getTranslation(): Vector3;
  60583. /**
  60584. * Fill a Vector3 with the extracted translation from the matrix
  60585. * @param result defines the Vector3 where to store the translation
  60586. * @returns the current matrix
  60587. */
  60588. getTranslationToRef(result: Vector3): Matrix;
  60589. /**
  60590. * Remove rotation and scaling part from the matrix
  60591. * @returns the updated matrix
  60592. */
  60593. removeRotationAndScaling(): Matrix;
  60594. /**
  60595. * Multiply two matrices
  60596. * @param other defines the second operand
  60597. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60598. */
  60599. multiply(other: DeepImmutable<Matrix>): Matrix;
  60600. /**
  60601. * Copy the current matrix from the given one
  60602. * @param other defines the source matrix
  60603. * @returns the current updated matrix
  60604. */
  60605. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60606. /**
  60607. * Populates the given array from the starting index with the current matrix values
  60608. * @param array defines the target array
  60609. * @param offset defines the offset in the target array where to start storing values
  60610. * @returns the current matrix
  60611. */
  60612. copyToArray(array: Float32Array, offset?: number): Matrix;
  60613. /**
  60614. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60615. * @param other defines the second operand
  60616. * @param result defines the matrix where to store the multiplication
  60617. * @returns the current matrix
  60618. */
  60619. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60620. /**
  60621. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60622. * @param other defines the second operand
  60623. * @param result defines the array where to store the multiplication
  60624. * @param offset defines the offset in the target array where to start storing values
  60625. * @returns the current matrix
  60626. */
  60627. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60628. /**
  60629. * Check equality between this matrix and a second one
  60630. * @param value defines the second matrix to compare
  60631. * @returns true is the current matrix and the given one values are strictly equal
  60632. */
  60633. equals(value: DeepImmutable<Matrix>): boolean;
  60634. /**
  60635. * Clone the current matrix
  60636. * @returns a new matrix from the current matrix
  60637. */
  60638. clone(): Matrix;
  60639. /**
  60640. * Returns the name of the current matrix class
  60641. * @returns the string "Matrix"
  60642. */
  60643. getClassName(): string;
  60644. /**
  60645. * Gets the hash code of the current matrix
  60646. * @returns the hash code
  60647. */
  60648. getHashCode(): number;
  60649. /**
  60650. * Decomposes the current Matrix into a translation, rotation and scaling components
  60651. * @param scale defines the scale vector3 given as a reference to update
  60652. * @param rotation defines the rotation quaternion given as a reference to update
  60653. * @param translation defines the translation vector3 given as a reference to update
  60654. * @returns true if operation was successful
  60655. */
  60656. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60657. /**
  60658. * Gets specific row of the matrix
  60659. * @param index defines the number of the row to get
  60660. * @returns the index-th row of the current matrix as a new Vector4
  60661. */
  60662. getRow(index: number): Nullable<Vector4>;
  60663. /**
  60664. * Sets the index-th row of the current matrix to the vector4 values
  60665. * @param index defines the number of the row to set
  60666. * @param row defines the target vector4
  60667. * @returns the updated current matrix
  60668. */
  60669. setRow(index: number, row: Vector4): Matrix;
  60670. /**
  60671. * Compute the transpose of the matrix
  60672. * @returns the new transposed matrix
  60673. */
  60674. transpose(): Matrix;
  60675. /**
  60676. * Compute the transpose of the matrix and store it in a given matrix
  60677. * @param result defines the target matrix
  60678. * @returns the current matrix
  60679. */
  60680. transposeToRef(result: Matrix): Matrix;
  60681. /**
  60682. * Sets the index-th row of the current matrix with the given 4 x float values
  60683. * @param index defines the row index
  60684. * @param x defines the x component to set
  60685. * @param y defines the y component to set
  60686. * @param z defines the z component to set
  60687. * @param w defines the w component to set
  60688. * @returns the updated current matrix
  60689. */
  60690. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60691. /**
  60692. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60693. * @param scale defines the scale factor
  60694. * @returns a new matrix
  60695. */
  60696. scale(scale: number): Matrix;
  60697. /**
  60698. * Scale the current matrix values by a factor to a given result matrix
  60699. * @param scale defines the scale factor
  60700. * @param result defines the matrix to store the result
  60701. * @returns the current matrix
  60702. */
  60703. scaleToRef(scale: number, result: Matrix): Matrix;
  60704. /**
  60705. * Scale the current matrix values by a factor and add the result to a given matrix
  60706. * @param scale defines the scale factor
  60707. * @param result defines the Matrix to store the result
  60708. * @returns the current matrix
  60709. */
  60710. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60711. /**
  60712. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60713. * @param ref matrix to store the result
  60714. */
  60715. toNormalMatrix(ref: Matrix): void;
  60716. /**
  60717. * Gets only rotation part of the current matrix
  60718. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60719. */
  60720. getRotationMatrix(): Matrix;
  60721. /**
  60722. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60723. * @param result defines the target matrix to store data to
  60724. * @returns the current matrix
  60725. */
  60726. getRotationMatrixToRef(result: Matrix): Matrix;
  60727. /**
  60728. * Toggles model matrix from being right handed to left handed in place and vice versa
  60729. */
  60730. toggleModelMatrixHandInPlace(): void;
  60731. /**
  60732. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60733. */
  60734. toggleProjectionMatrixHandInPlace(): void;
  60735. /**
  60736. * Creates a matrix from an array
  60737. * @param array defines the source array
  60738. * @param offset defines an offset in the source array
  60739. * @returns a new Matrix set from the starting index of the given array
  60740. */
  60741. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60742. /**
  60743. * Copy the content of an array into a given matrix
  60744. * @param array defines the source array
  60745. * @param offset defines an offset in the source array
  60746. * @param result defines the target matrix
  60747. */
  60748. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60749. /**
  60750. * Stores an array into a matrix after having multiplied each component by a given factor
  60751. * @param array defines the source array
  60752. * @param offset defines the offset in the source array
  60753. * @param scale defines the scaling factor
  60754. * @param result defines the target matrix
  60755. */
  60756. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60757. /**
  60758. * Gets an identity matrix that must not be updated
  60759. */
  60760. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60761. /**
  60762. * Stores a list of values (16) inside a given matrix
  60763. * @param initialM11 defines 1st value of 1st row
  60764. * @param initialM12 defines 2nd value of 1st row
  60765. * @param initialM13 defines 3rd value of 1st row
  60766. * @param initialM14 defines 4th value of 1st row
  60767. * @param initialM21 defines 1st value of 2nd row
  60768. * @param initialM22 defines 2nd value of 2nd row
  60769. * @param initialM23 defines 3rd value of 2nd row
  60770. * @param initialM24 defines 4th value of 2nd row
  60771. * @param initialM31 defines 1st value of 3rd row
  60772. * @param initialM32 defines 2nd value of 3rd row
  60773. * @param initialM33 defines 3rd value of 3rd row
  60774. * @param initialM34 defines 4th value of 3rd row
  60775. * @param initialM41 defines 1st value of 4th row
  60776. * @param initialM42 defines 2nd value of 4th row
  60777. * @param initialM43 defines 3rd value of 4th row
  60778. * @param initialM44 defines 4th value of 4th row
  60779. * @param result defines the target matrix
  60780. */
  60781. 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;
  60782. /**
  60783. * Creates new matrix from a list of values (16)
  60784. * @param initialM11 defines 1st value of 1st row
  60785. * @param initialM12 defines 2nd value of 1st row
  60786. * @param initialM13 defines 3rd value of 1st row
  60787. * @param initialM14 defines 4th value of 1st row
  60788. * @param initialM21 defines 1st value of 2nd row
  60789. * @param initialM22 defines 2nd value of 2nd row
  60790. * @param initialM23 defines 3rd value of 2nd row
  60791. * @param initialM24 defines 4th value of 2nd row
  60792. * @param initialM31 defines 1st value of 3rd row
  60793. * @param initialM32 defines 2nd value of 3rd row
  60794. * @param initialM33 defines 3rd value of 3rd row
  60795. * @param initialM34 defines 4th value of 3rd row
  60796. * @param initialM41 defines 1st value of 4th row
  60797. * @param initialM42 defines 2nd value of 4th row
  60798. * @param initialM43 defines 3rd value of 4th row
  60799. * @param initialM44 defines 4th value of 4th row
  60800. * @returns the new matrix
  60801. */
  60802. 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;
  60803. /**
  60804. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60805. * @param scale defines the scale vector3
  60806. * @param rotation defines the rotation quaternion
  60807. * @param translation defines the translation vector3
  60808. * @returns a new matrix
  60809. */
  60810. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60811. /**
  60812. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60813. * @param scale defines the scale vector3
  60814. * @param rotation defines the rotation quaternion
  60815. * @param translation defines the translation vector3
  60816. * @param result defines the target matrix
  60817. */
  60818. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60819. /**
  60820. * Creates a new identity matrix
  60821. * @returns a new identity matrix
  60822. */
  60823. static Identity(): Matrix;
  60824. /**
  60825. * Creates a new identity matrix and stores the result in a given matrix
  60826. * @param result defines the target matrix
  60827. */
  60828. static IdentityToRef(result: Matrix): void;
  60829. /**
  60830. * Creates a new zero matrix
  60831. * @returns a new zero matrix
  60832. */
  60833. static Zero(): Matrix;
  60834. /**
  60835. * Creates a new rotation matrix for "angle" radians around the X axis
  60836. * @param angle defines the angle (in radians) to use
  60837. * @return the new matrix
  60838. */
  60839. static RotationX(angle: number): Matrix;
  60840. /**
  60841. * Creates a new matrix as the invert of a given matrix
  60842. * @param source defines the source matrix
  60843. * @returns the new matrix
  60844. */
  60845. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60846. /**
  60847. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60848. * @param angle defines the angle (in radians) to use
  60849. * @param result defines the target matrix
  60850. */
  60851. static RotationXToRef(angle: number, result: Matrix): void;
  60852. /**
  60853. * Creates a new rotation matrix for "angle" radians around the Y axis
  60854. * @param angle defines the angle (in radians) to use
  60855. * @return the new matrix
  60856. */
  60857. static RotationY(angle: number): Matrix;
  60858. /**
  60859. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60860. * @param angle defines the angle (in radians) to use
  60861. * @param result defines the target matrix
  60862. */
  60863. static RotationYToRef(angle: number, result: Matrix): void;
  60864. /**
  60865. * Creates a new rotation matrix for "angle" radians around the Z axis
  60866. * @param angle defines the angle (in radians) to use
  60867. * @return the new matrix
  60868. */
  60869. static RotationZ(angle: number): Matrix;
  60870. /**
  60871. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60872. * @param angle defines the angle (in radians) to use
  60873. * @param result defines the target matrix
  60874. */
  60875. static RotationZToRef(angle: number, result: Matrix): void;
  60876. /**
  60877. * Creates a new rotation matrix for "angle" radians around the given axis
  60878. * @param axis defines the axis to use
  60879. * @param angle defines the angle (in radians) to use
  60880. * @return the new matrix
  60881. */
  60882. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60883. /**
  60884. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60885. * @param axis defines the axis to use
  60886. * @param angle defines the angle (in radians) to use
  60887. * @param result defines the target matrix
  60888. */
  60889. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60890. /**
  60891. * Creates a rotation matrix
  60892. * @param yaw defines the yaw angle in radians (Y axis)
  60893. * @param pitch defines the pitch angle in radians (X axis)
  60894. * @param roll defines the roll angle in radians (X axis)
  60895. * @returns the new rotation matrix
  60896. */
  60897. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60898. /**
  60899. * Creates a rotation matrix and stores it in a given matrix
  60900. * @param yaw defines the yaw angle in radians (Y axis)
  60901. * @param pitch defines the pitch angle in radians (X axis)
  60902. * @param roll defines the roll angle in radians (X axis)
  60903. * @param result defines the target matrix
  60904. */
  60905. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60906. /**
  60907. * Creates a scaling matrix
  60908. * @param x defines the scale factor on X axis
  60909. * @param y defines the scale factor on Y axis
  60910. * @param z defines the scale factor on Z axis
  60911. * @returns the new matrix
  60912. */
  60913. static Scaling(x: number, y: number, z: number): Matrix;
  60914. /**
  60915. * Creates a scaling matrix and stores it in a given matrix
  60916. * @param x defines the scale factor on X axis
  60917. * @param y defines the scale factor on Y axis
  60918. * @param z defines the scale factor on Z axis
  60919. * @param result defines the target matrix
  60920. */
  60921. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60922. /**
  60923. * Creates a translation matrix
  60924. * @param x defines the translation on X axis
  60925. * @param y defines the translation on Y axis
  60926. * @param z defines the translationon Z axis
  60927. * @returns the new matrix
  60928. */
  60929. static Translation(x: number, y: number, z: number): Matrix;
  60930. /**
  60931. * Creates a translation matrix and stores it in a given matrix
  60932. * @param x defines the translation on X axis
  60933. * @param y defines the translation on Y axis
  60934. * @param z defines the translationon Z axis
  60935. * @param result defines the target matrix
  60936. */
  60937. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60938. /**
  60939. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60940. * @param startValue defines the start value
  60941. * @param endValue defines the end value
  60942. * @param gradient defines the gradient factor
  60943. * @returns the new matrix
  60944. */
  60945. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60946. /**
  60947. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60948. * @param startValue defines the start value
  60949. * @param endValue defines the end value
  60950. * @param gradient defines the gradient factor
  60951. * @param result defines the Matrix object where to store data
  60952. */
  60953. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60954. /**
  60955. * Builds a new matrix whose values are computed by:
  60956. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60957. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60958. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60959. * @param startValue defines the first matrix
  60960. * @param endValue defines the second matrix
  60961. * @param gradient defines the gradient between the two matrices
  60962. * @returns the new matrix
  60963. */
  60964. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60965. /**
  60966. * Update a matrix to values which are computed by:
  60967. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60968. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60969. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60970. * @param startValue defines the first matrix
  60971. * @param endValue defines the second matrix
  60972. * @param gradient defines the gradient between the two matrices
  60973. * @param result defines the target matrix
  60974. */
  60975. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60976. /**
  60977. * 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"
  60978. * This function works in left handed mode
  60979. * @param eye defines the final position of the entity
  60980. * @param target defines where the entity should look at
  60981. * @param up defines the up vector for the entity
  60982. * @returns the new matrix
  60983. */
  60984. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60985. /**
  60986. * 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".
  60987. * This function works in left handed mode
  60988. * @param eye defines the final position of the entity
  60989. * @param target defines where the entity should look at
  60990. * @param up defines the up vector for the entity
  60991. * @param result defines the target matrix
  60992. */
  60993. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60994. /**
  60995. * 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"
  60996. * This function works in right handed mode
  60997. * @param eye defines the final position of the entity
  60998. * @param target defines where the entity should look at
  60999. * @param up defines the up vector for the entity
  61000. * @returns the new matrix
  61001. */
  61002. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61003. /**
  61004. * 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".
  61005. * This function works in right handed mode
  61006. * @param eye defines the final position of the entity
  61007. * @param target defines where the entity should look at
  61008. * @param up defines the up vector for the entity
  61009. * @param result defines the target matrix
  61010. */
  61011. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61012. /**
  61013. * Create a left-handed orthographic projection matrix
  61014. * @param width defines the viewport width
  61015. * @param height defines the viewport height
  61016. * @param znear defines the near clip plane
  61017. * @param zfar defines the far clip plane
  61018. * @returns a new matrix as a left-handed orthographic projection matrix
  61019. */
  61020. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61021. /**
  61022. * Store a left-handed orthographic projection to a given matrix
  61023. * @param width defines the viewport width
  61024. * @param height defines the viewport height
  61025. * @param znear defines the near clip plane
  61026. * @param zfar defines the far clip plane
  61027. * @param result defines the target matrix
  61028. */
  61029. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61030. /**
  61031. * Create a left-handed orthographic projection matrix
  61032. * @param left defines the viewport left coordinate
  61033. * @param right defines the viewport right coordinate
  61034. * @param bottom defines the viewport bottom coordinate
  61035. * @param top defines the viewport top coordinate
  61036. * @param znear defines the near clip plane
  61037. * @param zfar defines the far clip plane
  61038. * @returns a new matrix as a left-handed orthographic projection matrix
  61039. */
  61040. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61041. /**
  61042. * Stores a left-handed orthographic projection into a given matrix
  61043. * @param left defines the viewport left coordinate
  61044. * @param right defines the viewport right coordinate
  61045. * @param bottom defines the viewport bottom coordinate
  61046. * @param top defines the viewport top coordinate
  61047. * @param znear defines the near clip plane
  61048. * @param zfar defines the far clip plane
  61049. * @param result defines the target matrix
  61050. */
  61051. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61052. /**
  61053. * Creates a right-handed orthographic projection matrix
  61054. * @param left defines the viewport left coordinate
  61055. * @param right defines the viewport right coordinate
  61056. * @param bottom defines the viewport bottom coordinate
  61057. * @param top defines the viewport top coordinate
  61058. * @param znear defines the near clip plane
  61059. * @param zfar defines the far clip plane
  61060. * @returns a new matrix as a right-handed orthographic projection matrix
  61061. */
  61062. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61063. /**
  61064. * Stores a right-handed orthographic projection into a given matrix
  61065. * @param left defines the viewport left coordinate
  61066. * @param right defines the viewport right coordinate
  61067. * @param bottom defines the viewport bottom coordinate
  61068. * @param top defines the viewport top coordinate
  61069. * @param znear defines the near clip plane
  61070. * @param zfar defines the far clip plane
  61071. * @param result defines the target matrix
  61072. */
  61073. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61074. /**
  61075. * Creates a left-handed perspective projection matrix
  61076. * @param width defines the viewport width
  61077. * @param height defines the viewport height
  61078. * @param znear defines the near clip plane
  61079. * @param zfar defines the far clip plane
  61080. * @returns a new matrix as a left-handed perspective projection matrix
  61081. */
  61082. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61083. /**
  61084. * Creates a left-handed perspective projection matrix
  61085. * @param fov defines the horizontal field of view
  61086. * @param aspect defines the aspect ratio
  61087. * @param znear defines the near clip plane
  61088. * @param zfar defines the far clip plane
  61089. * @returns a new matrix as a left-handed perspective projection matrix
  61090. */
  61091. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61092. /**
  61093. * Stores a left-handed perspective projection into a given matrix
  61094. * @param fov defines the horizontal field of view
  61095. * @param aspect defines the aspect ratio
  61096. * @param znear defines the near clip plane
  61097. * @param zfar defines the far clip plane
  61098. * @param result defines the target matrix
  61099. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61100. */
  61101. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61102. /**
  61103. * Creates a right-handed perspective projection matrix
  61104. * @param fov defines the horizontal field of view
  61105. * @param aspect defines the aspect ratio
  61106. * @param znear defines the near clip plane
  61107. * @param zfar defines the far clip plane
  61108. * @returns a new matrix as a right-handed perspective projection matrix
  61109. */
  61110. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61111. /**
  61112. * Stores a right-handed perspective projection into a given matrix
  61113. * @param fov defines the horizontal field of view
  61114. * @param aspect defines the aspect ratio
  61115. * @param znear defines the near clip plane
  61116. * @param zfar defines the far clip plane
  61117. * @param result defines the target matrix
  61118. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61119. */
  61120. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61121. /**
  61122. * Stores a perspective projection for WebVR info a given matrix
  61123. * @param fov defines the field of view
  61124. * @param znear defines the near clip plane
  61125. * @param zfar defines the far clip plane
  61126. * @param result defines the target matrix
  61127. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61128. */
  61129. static PerspectiveFovWebVRToRef(fov: {
  61130. upDegrees: number;
  61131. downDegrees: number;
  61132. leftDegrees: number;
  61133. rightDegrees: number;
  61134. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61135. /**
  61136. * Computes a complete transformation matrix
  61137. * @param viewport defines the viewport to use
  61138. * @param world defines the world matrix
  61139. * @param view defines the view matrix
  61140. * @param projection defines the projection matrix
  61141. * @param zmin defines the near clip plane
  61142. * @param zmax defines the far clip plane
  61143. * @returns the transformation matrix
  61144. */
  61145. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61146. /**
  61147. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61148. * @param matrix defines the matrix to use
  61149. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61150. */
  61151. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61152. /**
  61153. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61154. * @param matrix defines the matrix to use
  61155. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61156. */
  61157. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61158. /**
  61159. * Compute the transpose of a given matrix
  61160. * @param matrix defines the matrix to transpose
  61161. * @returns the new matrix
  61162. */
  61163. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61164. /**
  61165. * Compute the transpose of a matrix and store it in a target matrix
  61166. * @param matrix defines the matrix to transpose
  61167. * @param result defines the target matrix
  61168. */
  61169. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61170. /**
  61171. * Computes a reflection matrix from a plane
  61172. * @param plane defines the reflection plane
  61173. * @returns a new matrix
  61174. */
  61175. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61176. /**
  61177. * Computes a reflection matrix from a plane
  61178. * @param plane defines the reflection plane
  61179. * @param result defines the target matrix
  61180. */
  61181. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61182. /**
  61183. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61184. * @param xaxis defines the value of the 1st axis
  61185. * @param yaxis defines the value of the 2nd axis
  61186. * @param zaxis defines the value of the 3rd axis
  61187. * @param result defines the target matrix
  61188. */
  61189. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61190. /**
  61191. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61192. * @param quat defines the quaternion to use
  61193. * @param result defines the target matrix
  61194. */
  61195. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61196. }
  61197. /**
  61198. * Represens a plane by the equation ax + by + cz + d = 0
  61199. */
  61200. export class Plane {
  61201. /**
  61202. * Normal of the plane (a,b,c)
  61203. */
  61204. normal: Vector3;
  61205. /**
  61206. * d component of the plane
  61207. */
  61208. d: number;
  61209. /**
  61210. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61211. * @param a a component of the plane
  61212. * @param b b component of the plane
  61213. * @param c c component of the plane
  61214. * @param d d component of the plane
  61215. */
  61216. constructor(a: number, b: number, c: number, d: number);
  61217. /**
  61218. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61219. */
  61220. asArray(): number[];
  61221. /**
  61222. * @returns a new plane copied from the current Plane.
  61223. */
  61224. clone(): Plane;
  61225. /**
  61226. * @returns the string "Plane".
  61227. */
  61228. getClassName(): string;
  61229. /**
  61230. * @returns the Plane hash code.
  61231. */
  61232. getHashCode(): number;
  61233. /**
  61234. * Normalize the current Plane in place.
  61235. * @returns the updated Plane.
  61236. */
  61237. normalize(): Plane;
  61238. /**
  61239. * Applies a transformation the plane and returns the result
  61240. * @param transformation the transformation matrix to be applied to the plane
  61241. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61242. */
  61243. transform(transformation: DeepImmutable<Matrix>): Plane;
  61244. /**
  61245. * Calcualtte the dot product between the point and the plane normal
  61246. * @param point point to calculate the dot product with
  61247. * @returns the dot product (float) of the point coordinates and the plane normal.
  61248. */
  61249. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61250. /**
  61251. * Updates the current Plane from the plane defined by the three given points.
  61252. * @param point1 one of the points used to contruct the plane
  61253. * @param point2 one of the points used to contruct the plane
  61254. * @param point3 one of the points used to contruct the plane
  61255. * @returns the updated Plane.
  61256. */
  61257. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61258. /**
  61259. * Checks if the plane is facing a given direction
  61260. * @param direction the direction to check if the plane is facing
  61261. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61262. * @returns True is the vector "direction" is the same side than the plane normal.
  61263. */
  61264. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61265. /**
  61266. * Calculates the distance to a point
  61267. * @param point point to calculate distance to
  61268. * @returns the signed distance (float) from the given point to the Plane.
  61269. */
  61270. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61271. /**
  61272. * Creates a plane from an array
  61273. * @param array the array to create a plane from
  61274. * @returns a new Plane from the given array.
  61275. */
  61276. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61277. /**
  61278. * Creates a plane from three points
  61279. * @param point1 point used to create the plane
  61280. * @param point2 point used to create the plane
  61281. * @param point3 point used to create the plane
  61282. * @returns a new Plane defined by the three given points.
  61283. */
  61284. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61285. /**
  61286. * Creates a plane from an origin point and a normal
  61287. * @param origin origin of the plane to be constructed
  61288. * @param normal normal of the plane to be constructed
  61289. * @returns a new Plane the normal vector to this plane at the given origin point.
  61290. * Note : the vector "normal" is updated because normalized.
  61291. */
  61292. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61293. /**
  61294. * Calculates the distance from a plane and a point
  61295. * @param origin origin of the plane to be constructed
  61296. * @param normal normal of the plane to be constructed
  61297. * @param point point to calculate distance to
  61298. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61299. */
  61300. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61301. }
  61302. /**
  61303. * Class used to represent a viewport on screen
  61304. */
  61305. export class Viewport {
  61306. /** viewport left coordinate */
  61307. x: number;
  61308. /** viewport top coordinate */
  61309. y: number;
  61310. /**viewport width */
  61311. width: number;
  61312. /** viewport height */
  61313. height: number;
  61314. /**
  61315. * Creates a Viewport object located at (x, y) and sized (width, height)
  61316. * @param x defines viewport left coordinate
  61317. * @param y defines viewport top coordinate
  61318. * @param width defines the viewport width
  61319. * @param height defines the viewport height
  61320. */
  61321. constructor(
  61322. /** viewport left coordinate */
  61323. x: number,
  61324. /** viewport top coordinate */
  61325. y: number,
  61326. /**viewport width */
  61327. width: number,
  61328. /** viewport height */
  61329. height: number);
  61330. /**
  61331. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61332. * @param renderWidth defines the rendering width
  61333. * @param renderHeight defines the rendering height
  61334. * @returns a new Viewport
  61335. */
  61336. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61337. /**
  61338. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61339. * @param renderWidth defines the rendering width
  61340. * @param renderHeight defines the rendering height
  61341. * @param ref defines the target viewport
  61342. * @returns the current viewport
  61343. */
  61344. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61345. /**
  61346. * Returns a new Viewport copied from the current one
  61347. * @returns a new Viewport
  61348. */
  61349. clone(): Viewport;
  61350. }
  61351. /**
  61352. * Reprasents a camera frustum
  61353. */
  61354. export class Frustum {
  61355. /**
  61356. * Gets the planes representing the frustum
  61357. * @param transform matrix to be applied to the returned planes
  61358. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61359. */
  61360. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61361. /**
  61362. * Gets the near frustum plane transformed by the transform matrix
  61363. * @param transform transformation matrix to be applied to the resulting frustum plane
  61364. * @param frustumPlane the resuling frustum plane
  61365. */
  61366. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61367. /**
  61368. * Gets the far frustum plane transformed by the transform matrix
  61369. * @param transform transformation matrix to be applied to the resulting frustum plane
  61370. * @param frustumPlane the resuling frustum plane
  61371. */
  61372. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61373. /**
  61374. * Gets the left frustum plane transformed by the transform matrix
  61375. * @param transform transformation matrix to be applied to the resulting frustum plane
  61376. * @param frustumPlane the resuling frustum plane
  61377. */
  61378. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61379. /**
  61380. * Gets the right frustum plane transformed by the transform matrix
  61381. * @param transform transformation matrix to be applied to the resulting frustum plane
  61382. * @param frustumPlane the resuling frustum plane
  61383. */
  61384. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61385. /**
  61386. * Gets the top frustum plane transformed by the transform matrix
  61387. * @param transform transformation matrix to be applied to the resulting frustum plane
  61388. * @param frustumPlane the resuling frustum plane
  61389. */
  61390. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61391. /**
  61392. * Gets the bottom frustum plane transformed by the transform matrix
  61393. * @param transform transformation matrix to be applied to the resulting frustum plane
  61394. * @param frustumPlane the resuling frustum plane
  61395. */
  61396. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61397. /**
  61398. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61399. * @param transform transformation matrix to be applied to the resulting frustum planes
  61400. * @param frustumPlanes the resuling frustum planes
  61401. */
  61402. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61403. }
  61404. /** Defines supported spaces */
  61405. export enum Space {
  61406. /** Local (object) space */
  61407. LOCAL = 0,
  61408. /** World space */
  61409. WORLD = 1,
  61410. /** Bone space */
  61411. BONE = 2
  61412. }
  61413. /** Defines the 3 main axes */
  61414. export class Axis {
  61415. /** X axis */
  61416. static X: Vector3;
  61417. /** Y axis */
  61418. static Y: Vector3;
  61419. /** Z axis */
  61420. static Z: Vector3;
  61421. }
  61422. /** Class used to represent a Bezier curve */
  61423. export class BezierCurve {
  61424. /**
  61425. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61426. * @param t defines the time
  61427. * @param x1 defines the left coordinate on X axis
  61428. * @param y1 defines the left coordinate on Y axis
  61429. * @param x2 defines the right coordinate on X axis
  61430. * @param y2 defines the right coordinate on Y axis
  61431. * @returns the interpolated value
  61432. */
  61433. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61434. }
  61435. /**
  61436. * Defines potential orientation for back face culling
  61437. */
  61438. export enum Orientation {
  61439. /**
  61440. * Clockwise
  61441. */
  61442. CW = 0,
  61443. /** Counter clockwise */
  61444. CCW = 1
  61445. }
  61446. /**
  61447. * Defines angle representation
  61448. */
  61449. export class Angle {
  61450. private _radians;
  61451. /**
  61452. * Creates an Angle object of "radians" radians (float).
  61453. * @param radians the angle in radians
  61454. */
  61455. constructor(radians: number);
  61456. /**
  61457. * Get value in degrees
  61458. * @returns the Angle value in degrees (float)
  61459. */
  61460. degrees(): number;
  61461. /**
  61462. * Get value in radians
  61463. * @returns the Angle value in radians (float)
  61464. */
  61465. radians(): number;
  61466. /**
  61467. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61468. * @param a defines first vector
  61469. * @param b defines second vector
  61470. * @returns a new Angle
  61471. */
  61472. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61473. /**
  61474. * Gets a new Angle object from the given float in radians
  61475. * @param radians defines the angle value in radians
  61476. * @returns a new Angle
  61477. */
  61478. static FromRadians(radians: number): Angle;
  61479. /**
  61480. * Gets a new Angle object from the given float in degrees
  61481. * @param degrees defines the angle value in degrees
  61482. * @returns a new Angle
  61483. */
  61484. static FromDegrees(degrees: number): Angle;
  61485. }
  61486. /**
  61487. * This represents an arc in a 2d space.
  61488. */
  61489. export class Arc2 {
  61490. /** Defines the start point of the arc */
  61491. startPoint: Vector2;
  61492. /** Defines the mid point of the arc */
  61493. midPoint: Vector2;
  61494. /** Defines the end point of the arc */
  61495. endPoint: Vector2;
  61496. /**
  61497. * Defines the center point of the arc.
  61498. */
  61499. centerPoint: Vector2;
  61500. /**
  61501. * Defines the radius of the arc.
  61502. */
  61503. radius: number;
  61504. /**
  61505. * Defines the angle of the arc (from mid point to end point).
  61506. */
  61507. angle: Angle;
  61508. /**
  61509. * Defines the start angle of the arc (from start point to middle point).
  61510. */
  61511. startAngle: Angle;
  61512. /**
  61513. * Defines the orientation of the arc (clock wise/counter clock wise).
  61514. */
  61515. orientation: Orientation;
  61516. /**
  61517. * Creates an Arc object from the three given points : start, middle and end.
  61518. * @param startPoint Defines the start point of the arc
  61519. * @param midPoint Defines the midlle point of the arc
  61520. * @param endPoint Defines the end point of the arc
  61521. */
  61522. constructor(
  61523. /** Defines the start point of the arc */
  61524. startPoint: Vector2,
  61525. /** Defines the mid point of the arc */
  61526. midPoint: Vector2,
  61527. /** Defines the end point of the arc */
  61528. endPoint: Vector2);
  61529. }
  61530. /**
  61531. * Represents a 2D path made up of multiple 2D points
  61532. */
  61533. export class Path2 {
  61534. private _points;
  61535. private _length;
  61536. /**
  61537. * If the path start and end point are the same
  61538. */
  61539. closed: boolean;
  61540. /**
  61541. * Creates a Path2 object from the starting 2D coordinates x and y.
  61542. * @param x the starting points x value
  61543. * @param y the starting points y value
  61544. */
  61545. constructor(x: number, y: number);
  61546. /**
  61547. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61548. * @param x the added points x value
  61549. * @param y the added points y value
  61550. * @returns the updated Path2.
  61551. */
  61552. addLineTo(x: number, y: number): Path2;
  61553. /**
  61554. * 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.
  61555. * @param midX middle point x value
  61556. * @param midY middle point y value
  61557. * @param endX end point x value
  61558. * @param endY end point y value
  61559. * @param numberOfSegments (default: 36)
  61560. * @returns the updated Path2.
  61561. */
  61562. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61563. /**
  61564. * Closes the Path2.
  61565. * @returns the Path2.
  61566. */
  61567. close(): Path2;
  61568. /**
  61569. * Gets the sum of the distance between each sequential point in the path
  61570. * @returns the Path2 total length (float).
  61571. */
  61572. length(): number;
  61573. /**
  61574. * Gets the points which construct the path
  61575. * @returns the Path2 internal array of points.
  61576. */
  61577. getPoints(): Vector2[];
  61578. /**
  61579. * Retreives the point at the distance aways from the starting point
  61580. * @param normalizedLengthPosition the length along the path to retreive the point from
  61581. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61582. */
  61583. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61584. /**
  61585. * Creates a new path starting from an x and y position
  61586. * @param x starting x value
  61587. * @param y starting y value
  61588. * @returns a new Path2 starting at the coordinates (x, y).
  61589. */
  61590. static StartingAt(x: number, y: number): Path2;
  61591. }
  61592. /**
  61593. * Represents a 3D path made up of multiple 3D points
  61594. */
  61595. export class Path3D {
  61596. /**
  61597. * an array of Vector3, the curve axis of the Path3D
  61598. */
  61599. path: Vector3[];
  61600. private _curve;
  61601. private _distances;
  61602. private _tangents;
  61603. private _normals;
  61604. private _binormals;
  61605. private _raw;
  61606. /**
  61607. * new Path3D(path, normal, raw)
  61608. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61609. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61610. * @param path an array of Vector3, the curve axis of the Path3D
  61611. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61612. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61613. */
  61614. constructor(
  61615. /**
  61616. * an array of Vector3, the curve axis of the Path3D
  61617. */
  61618. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61619. /**
  61620. * Returns the Path3D array of successive Vector3 designing its curve.
  61621. * @returns the Path3D array of successive Vector3 designing its curve.
  61622. */
  61623. getCurve(): Vector3[];
  61624. /**
  61625. * Returns an array populated with tangent vectors on each Path3D curve point.
  61626. * @returns an array populated with tangent vectors on each Path3D curve point.
  61627. */
  61628. getTangents(): Vector3[];
  61629. /**
  61630. * Returns an array populated with normal vectors on each Path3D curve point.
  61631. * @returns an array populated with normal vectors on each Path3D curve point.
  61632. */
  61633. getNormals(): Vector3[];
  61634. /**
  61635. * Returns an array populated with binormal vectors on each Path3D curve point.
  61636. * @returns an array populated with binormal vectors on each Path3D curve point.
  61637. */
  61638. getBinormals(): Vector3[];
  61639. /**
  61640. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61641. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61642. */
  61643. getDistances(): number[];
  61644. /**
  61645. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61646. * @param path path which all values are copied into the curves points
  61647. * @param firstNormal which should be projected onto the curve
  61648. * @returns the same object updated.
  61649. */
  61650. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61651. private _compute;
  61652. private _getFirstNonNullVector;
  61653. private _getLastNonNullVector;
  61654. private _normalVector;
  61655. }
  61656. /**
  61657. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61658. * A Curve3 is designed from a series of successive Vector3.
  61659. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61660. */
  61661. export class Curve3 {
  61662. private _points;
  61663. private _length;
  61664. /**
  61665. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61666. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61667. * @param v1 (Vector3) the control point
  61668. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61669. * @param nbPoints (integer) the wanted number of points in the curve
  61670. * @returns the created Curve3
  61671. */
  61672. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61673. /**
  61674. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61675. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61676. * @param v1 (Vector3) the first control point
  61677. * @param v2 (Vector3) the second control point
  61678. * @param v3 (Vector3) the end point of the Cubic Bezier
  61679. * @param nbPoints (integer) the wanted number of points in the curve
  61680. * @returns the created Curve3
  61681. */
  61682. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61683. /**
  61684. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61685. * @param p1 (Vector3) the origin point of the Hermite Spline
  61686. * @param t1 (Vector3) the tangent vector at the origin point
  61687. * @param p2 (Vector3) the end point of the Hermite Spline
  61688. * @param t2 (Vector3) the tangent vector at the end point
  61689. * @param nbPoints (integer) the wanted number of points in the curve
  61690. * @returns the created Curve3
  61691. */
  61692. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61693. /**
  61694. * Returns a Curve3 object along a CatmullRom Spline curve :
  61695. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61696. * @param nbPoints (integer) the wanted number of points between each curve control points
  61697. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61698. * @returns the created Curve3
  61699. */
  61700. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61701. /**
  61702. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61703. * A Curve3 is designed from a series of successive Vector3.
  61704. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61705. * @param points points which make up the curve
  61706. */
  61707. constructor(points: Vector3[]);
  61708. /**
  61709. * @returns the Curve3 stored array of successive Vector3
  61710. */
  61711. getPoints(): Vector3[];
  61712. /**
  61713. * @returns the computed length (float) of the curve.
  61714. */
  61715. length(): number;
  61716. /**
  61717. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61718. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61719. * curveA and curveB keep unchanged.
  61720. * @param curve the curve to continue from this curve
  61721. * @returns the newly constructed curve
  61722. */
  61723. continue(curve: DeepImmutable<Curve3>): Curve3;
  61724. private _computeLength;
  61725. }
  61726. /**
  61727. * Contains position and normal vectors for a vertex
  61728. */
  61729. export class PositionNormalVertex {
  61730. /** the position of the vertex (defaut: 0,0,0) */
  61731. position: Vector3;
  61732. /** the normal of the vertex (defaut: 0,1,0) */
  61733. normal: Vector3;
  61734. /**
  61735. * Creates a PositionNormalVertex
  61736. * @param position the position of the vertex (defaut: 0,0,0)
  61737. * @param normal the normal of the vertex (defaut: 0,1,0)
  61738. */
  61739. constructor(
  61740. /** the position of the vertex (defaut: 0,0,0) */
  61741. position?: Vector3,
  61742. /** the normal of the vertex (defaut: 0,1,0) */
  61743. normal?: Vector3);
  61744. /**
  61745. * Clones the PositionNormalVertex
  61746. * @returns the cloned PositionNormalVertex
  61747. */
  61748. clone(): PositionNormalVertex;
  61749. }
  61750. /**
  61751. * Contains position, normal and uv vectors for a vertex
  61752. */
  61753. export class PositionNormalTextureVertex {
  61754. /** the position of the vertex (defaut: 0,0,0) */
  61755. position: Vector3;
  61756. /** the normal of the vertex (defaut: 0,1,0) */
  61757. normal: Vector3;
  61758. /** the uv of the vertex (default: 0,0) */
  61759. uv: Vector2;
  61760. /**
  61761. * Creates a PositionNormalTextureVertex
  61762. * @param position the position of the vertex (defaut: 0,0,0)
  61763. * @param normal the normal of the vertex (defaut: 0,1,0)
  61764. * @param uv the uv of the vertex (default: 0,0)
  61765. */
  61766. constructor(
  61767. /** the position of the vertex (defaut: 0,0,0) */
  61768. position?: Vector3,
  61769. /** the normal of the vertex (defaut: 0,1,0) */
  61770. normal?: Vector3,
  61771. /** the uv of the vertex (default: 0,0) */
  61772. uv?: Vector2);
  61773. /**
  61774. * Clones the PositionNormalTextureVertex
  61775. * @returns the cloned PositionNormalTextureVertex
  61776. */
  61777. clone(): PositionNormalTextureVertex;
  61778. }
  61779. /**
  61780. * @hidden
  61781. */
  61782. export class Tmp {
  61783. static Color3: Color3[];
  61784. static Color4: Color4[];
  61785. static Vector2: Vector2[];
  61786. static Vector3: Vector3[];
  61787. static Vector4: Vector4[];
  61788. static Quaternion: Quaternion[];
  61789. static Matrix: Matrix[];
  61790. }
  61791. }
  61792. declare module BABYLON {
  61793. /**
  61794. * Class used to enable access to offline support
  61795. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61796. */
  61797. export interface IOfflineProvider {
  61798. /**
  61799. * Gets a boolean indicating if scene must be saved in the database
  61800. */
  61801. enableSceneOffline: boolean;
  61802. /**
  61803. * Gets a boolean indicating if textures must be saved in the database
  61804. */
  61805. enableTexturesOffline: boolean;
  61806. /**
  61807. * Open the offline support and make it available
  61808. * @param successCallback defines the callback to call on success
  61809. * @param errorCallback defines the callback to call on error
  61810. */
  61811. open(successCallback: () => void, errorCallback: () => void): void;
  61812. /**
  61813. * Loads an image from the offline support
  61814. * @param url defines the url to load from
  61815. * @param image defines the target DOM image
  61816. */
  61817. loadImage(url: string, image: HTMLImageElement): void;
  61818. /**
  61819. * Loads a file from offline support
  61820. * @param url defines the URL to load from
  61821. * @param sceneLoaded defines a callback to call on success
  61822. * @param progressCallBack defines a callback to call when progress changed
  61823. * @param errorCallback defines a callback to call on error
  61824. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61825. */
  61826. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61827. }
  61828. }
  61829. declare module BABYLON {
  61830. /**
  61831. * A class serves as a medium between the observable and its observers
  61832. */
  61833. export class EventState {
  61834. /**
  61835. * Create a new EventState
  61836. * @param mask defines the mask associated with this state
  61837. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61838. * @param target defines the original target of the state
  61839. * @param currentTarget defines the current target of the state
  61840. */
  61841. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61842. /**
  61843. * Initialize the current event state
  61844. * @param mask defines the mask associated with this state
  61845. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61846. * @param target defines the original target of the state
  61847. * @param currentTarget defines the current target of the state
  61848. * @returns the current event state
  61849. */
  61850. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61851. /**
  61852. * An Observer can set this property to true to prevent subsequent observers of being notified
  61853. */
  61854. skipNextObservers: boolean;
  61855. /**
  61856. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61857. */
  61858. mask: number;
  61859. /**
  61860. * The object that originally notified the event
  61861. */
  61862. target?: any;
  61863. /**
  61864. * The current object in the bubbling phase
  61865. */
  61866. currentTarget?: any;
  61867. /**
  61868. * This will be populated with the return value of the last function that was executed.
  61869. * If it is the first function in the callback chain it will be the event data.
  61870. */
  61871. lastReturnValue?: any;
  61872. }
  61873. /**
  61874. * Represent an Observer registered to a given Observable object.
  61875. */
  61876. export class Observer<T> {
  61877. /**
  61878. * Defines the callback to call when the observer is notified
  61879. */
  61880. callback: (eventData: T, eventState: EventState) => void;
  61881. /**
  61882. * Defines the mask of the observer (used to filter notifications)
  61883. */
  61884. mask: number;
  61885. /**
  61886. * Defines the current scope used to restore the JS context
  61887. */
  61888. scope: any;
  61889. /** @hidden */
  61890. _willBeUnregistered: boolean;
  61891. /**
  61892. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61893. */
  61894. unregisterOnNextCall: boolean;
  61895. /**
  61896. * Creates a new observer
  61897. * @param callback defines the callback to call when the observer is notified
  61898. * @param mask defines the mask of the observer (used to filter notifications)
  61899. * @param scope defines the current scope used to restore the JS context
  61900. */
  61901. constructor(
  61902. /**
  61903. * Defines the callback to call when the observer is notified
  61904. */
  61905. callback: (eventData: T, eventState: EventState) => void,
  61906. /**
  61907. * Defines the mask of the observer (used to filter notifications)
  61908. */
  61909. mask: number,
  61910. /**
  61911. * Defines the current scope used to restore the JS context
  61912. */
  61913. scope?: any);
  61914. }
  61915. /**
  61916. * Represent a list of observers registered to multiple Observables object.
  61917. */
  61918. export class MultiObserver<T> {
  61919. private _observers;
  61920. private _observables;
  61921. /**
  61922. * Release associated resources
  61923. */
  61924. dispose(): void;
  61925. /**
  61926. * Raise a callback when one of the observable will notify
  61927. * @param observables defines a list of observables to watch
  61928. * @param callback defines the callback to call on notification
  61929. * @param mask defines the mask used to filter notifications
  61930. * @param scope defines the current scope used to restore the JS context
  61931. * @returns the new MultiObserver
  61932. */
  61933. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61934. }
  61935. /**
  61936. * The Observable class is a simple implementation of the Observable pattern.
  61937. *
  61938. * 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.
  61939. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61940. * 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).
  61941. * 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.
  61942. */
  61943. export class Observable<T> {
  61944. private _observers;
  61945. private _eventState;
  61946. private _onObserverAdded;
  61947. /**
  61948. * Creates a new observable
  61949. * @param onObserverAdded defines a callback to call when a new observer is added
  61950. */
  61951. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61952. /**
  61953. * Create a new Observer with the specified callback
  61954. * @param callback the callback that will be executed for that Observer
  61955. * @param mask the mask used to filter observers
  61956. * @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.
  61957. * @param scope optional scope for the callback to be called from
  61958. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61959. * @returns the new observer created for the callback
  61960. */
  61961. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61962. /**
  61963. * Create a new Observer with the specified callback and unregisters after the next notification
  61964. * @param callback the callback that will be executed for that Observer
  61965. * @returns the new observer created for the callback
  61966. */
  61967. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61968. /**
  61969. * Remove an Observer from the Observable object
  61970. * @param observer the instance of the Observer to remove
  61971. * @returns false if it doesn't belong to this Observable
  61972. */
  61973. remove(observer: Nullable<Observer<T>>): boolean;
  61974. /**
  61975. * Remove a callback from the Observable object
  61976. * @param callback the callback to remove
  61977. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61978. * @returns false if it doesn't belong to this Observable
  61979. */
  61980. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61981. private _deferUnregister;
  61982. private _remove;
  61983. /**
  61984. * Notify all Observers by calling their respective callback with the given data
  61985. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61986. * @param eventData defines the data to send to all observers
  61987. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61988. * @param target defines the original target of the state
  61989. * @param currentTarget defines the current target of the state
  61990. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61991. */
  61992. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61993. /**
  61994. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61995. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61996. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61997. * and it is crucial that all callbacks will be executed.
  61998. * The order of the callbacks is kept, callbacks are not executed parallel.
  61999. *
  62000. * @param eventData The data to be sent to each callback
  62001. * @param mask is used to filter observers defaults to -1
  62002. * @param target defines the callback target (see EventState)
  62003. * @param currentTarget defines he current object in the bubbling phase
  62004. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62005. */
  62006. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62007. /**
  62008. * Notify a specific observer
  62009. * @param observer defines the observer to notify
  62010. * @param eventData defines the data to be sent to each callback
  62011. * @param mask is used to filter observers defaults to -1
  62012. */
  62013. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62014. /**
  62015. * Gets a boolean indicating if the observable has at least one observer
  62016. * @returns true is the Observable has at least one Observer registered
  62017. */
  62018. hasObservers(): boolean;
  62019. /**
  62020. * Clear the list of observers
  62021. */
  62022. clear(): void;
  62023. /**
  62024. * Clone the current observable
  62025. * @returns a new observable
  62026. */
  62027. clone(): Observable<T>;
  62028. /**
  62029. * Does this observable handles observer registered with a given mask
  62030. * @param mask defines the mask to be tested
  62031. * @return whether or not one observer registered with the given mask is handeled
  62032. **/
  62033. hasSpecificMask(mask?: number): boolean;
  62034. }
  62035. }
  62036. declare module BABYLON {
  62037. /**
  62038. * Class used to help managing file picking and drag'n'drop
  62039. * File Storage
  62040. */
  62041. export class FilesInputStore {
  62042. /**
  62043. * List of files ready to be loaded
  62044. */
  62045. static FilesToLoad: {
  62046. [key: string]: File;
  62047. };
  62048. }
  62049. }
  62050. declare module BABYLON {
  62051. /** Defines the cross module used constants to avoid circular dependncies */
  62052. export class Constants {
  62053. /** Defines that alpha blending is disabled */
  62054. static readonly ALPHA_DISABLE: number;
  62055. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62056. static readonly ALPHA_ADD: number;
  62057. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62058. static readonly ALPHA_COMBINE: number;
  62059. /** Defines that alpha blending to DEST - SRC * DEST */
  62060. static readonly ALPHA_SUBTRACT: number;
  62061. /** Defines that alpha blending to SRC * DEST */
  62062. static readonly ALPHA_MULTIPLY: number;
  62063. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62064. static readonly ALPHA_MAXIMIZED: number;
  62065. /** Defines that alpha blending to SRC + DEST */
  62066. static readonly ALPHA_ONEONE: number;
  62067. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62068. static readonly ALPHA_PREMULTIPLIED: number;
  62069. /**
  62070. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62071. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62072. */
  62073. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62074. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62075. static readonly ALPHA_INTERPOLATE: number;
  62076. /**
  62077. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62078. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62079. */
  62080. static readonly ALPHA_SCREENMODE: number;
  62081. /** Defines that the ressource is not delayed*/
  62082. static readonly DELAYLOADSTATE_NONE: number;
  62083. /** Defines that the ressource was successfully delay loaded */
  62084. static readonly DELAYLOADSTATE_LOADED: number;
  62085. /** Defines that the ressource is currently delay loading */
  62086. static readonly DELAYLOADSTATE_LOADING: number;
  62087. /** Defines that the ressource is delayed and has not started loading */
  62088. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62090. static readonly NEVER: number;
  62091. /** 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 */
  62092. static readonly ALWAYS: number;
  62093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62094. static readonly LESS: number;
  62095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62096. static readonly EQUAL: number;
  62097. /** 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 */
  62098. static readonly LEQUAL: number;
  62099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62100. static readonly GREATER: number;
  62101. /** 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 */
  62102. static readonly GEQUAL: number;
  62103. /** 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 */
  62104. static readonly NOTEQUAL: number;
  62105. /** Passed to stencilOperation to specify that stencil value must be kept */
  62106. static readonly KEEP: number;
  62107. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62108. static readonly REPLACE: number;
  62109. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62110. static readonly INCR: number;
  62111. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62112. static readonly DECR: number;
  62113. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62114. static readonly INVERT: number;
  62115. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62116. static readonly INCR_WRAP: number;
  62117. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62118. static readonly DECR_WRAP: number;
  62119. /** Texture is not repeating outside of 0..1 UVs */
  62120. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62121. /** Texture is repeating outside of 0..1 UVs */
  62122. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62123. /** Texture is repeating and mirrored */
  62124. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62125. /** ALPHA */
  62126. static readonly TEXTUREFORMAT_ALPHA: number;
  62127. /** LUMINANCE */
  62128. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62129. /** LUMINANCE_ALPHA */
  62130. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62131. /** RGB */
  62132. static readonly TEXTUREFORMAT_RGB: number;
  62133. /** RGBA */
  62134. static readonly TEXTUREFORMAT_RGBA: number;
  62135. /** RED */
  62136. static readonly TEXTUREFORMAT_RED: number;
  62137. /** RED (2nd reference) */
  62138. static readonly TEXTUREFORMAT_R: number;
  62139. /** RG */
  62140. static readonly TEXTUREFORMAT_RG: number;
  62141. /** RED_INTEGER */
  62142. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62143. /** RED_INTEGER (2nd reference) */
  62144. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62145. /** RG_INTEGER */
  62146. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62147. /** RGB_INTEGER */
  62148. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62149. /** RGBA_INTEGER */
  62150. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62151. /** UNSIGNED_BYTE */
  62152. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62153. /** UNSIGNED_BYTE (2nd reference) */
  62154. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62155. /** FLOAT */
  62156. static readonly TEXTURETYPE_FLOAT: number;
  62157. /** HALF_FLOAT */
  62158. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62159. /** BYTE */
  62160. static readonly TEXTURETYPE_BYTE: number;
  62161. /** SHORT */
  62162. static readonly TEXTURETYPE_SHORT: number;
  62163. /** UNSIGNED_SHORT */
  62164. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62165. /** INT */
  62166. static readonly TEXTURETYPE_INT: number;
  62167. /** UNSIGNED_INT */
  62168. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62169. /** UNSIGNED_SHORT_4_4_4_4 */
  62170. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62171. /** UNSIGNED_SHORT_5_5_5_1 */
  62172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62173. /** UNSIGNED_SHORT_5_6_5 */
  62174. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62175. /** UNSIGNED_INT_2_10_10_10_REV */
  62176. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62177. /** UNSIGNED_INT_24_8 */
  62178. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62179. /** UNSIGNED_INT_10F_11F_11F_REV */
  62180. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62181. /** UNSIGNED_INT_5_9_9_9_REV */
  62182. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62183. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62184. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62185. /** nearest is mag = nearest and min = nearest and mip = linear */
  62186. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62187. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62188. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62189. /** Trilinear is mag = linear and min = linear and mip = linear */
  62190. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62191. /** nearest is mag = nearest and min = nearest and mip = linear */
  62192. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62193. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62194. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62195. /** Trilinear is mag = linear and min = linear and mip = linear */
  62196. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62197. /** mag = nearest and min = nearest and mip = nearest */
  62198. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62199. /** mag = nearest and min = linear and mip = nearest */
  62200. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62201. /** mag = nearest and min = linear and mip = linear */
  62202. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62203. /** mag = nearest and min = linear and mip = none */
  62204. static readonly TEXTURE_NEAREST_LINEAR: number;
  62205. /** mag = nearest and min = nearest and mip = none */
  62206. static readonly TEXTURE_NEAREST_NEAREST: number;
  62207. /** mag = linear and min = nearest and mip = nearest */
  62208. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62209. /** mag = linear and min = nearest and mip = linear */
  62210. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62211. /** mag = linear and min = linear and mip = none */
  62212. static readonly TEXTURE_LINEAR_LINEAR: number;
  62213. /** mag = linear and min = nearest and mip = none */
  62214. static readonly TEXTURE_LINEAR_NEAREST: number;
  62215. /** Explicit coordinates mode */
  62216. static readonly TEXTURE_EXPLICIT_MODE: number;
  62217. /** Spherical coordinates mode */
  62218. static readonly TEXTURE_SPHERICAL_MODE: number;
  62219. /** Planar coordinates mode */
  62220. static readonly TEXTURE_PLANAR_MODE: number;
  62221. /** Cubic coordinates mode */
  62222. static readonly TEXTURE_CUBIC_MODE: number;
  62223. /** Projection coordinates mode */
  62224. static readonly TEXTURE_PROJECTION_MODE: number;
  62225. /** Skybox coordinates mode */
  62226. static readonly TEXTURE_SKYBOX_MODE: number;
  62227. /** Inverse Cubic coordinates mode */
  62228. static readonly TEXTURE_INVCUBIC_MODE: number;
  62229. /** Equirectangular coordinates mode */
  62230. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62231. /** Equirectangular Fixed coordinates mode */
  62232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62233. /** Equirectangular Fixed Mirrored coordinates mode */
  62234. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62235. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62236. static readonly SCALEMODE_FLOOR: number;
  62237. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62238. static readonly SCALEMODE_NEAREST: number;
  62239. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62240. static readonly SCALEMODE_CEILING: number;
  62241. /**
  62242. * The dirty texture flag value
  62243. */
  62244. static readonly MATERIAL_TextureDirtyFlag: number;
  62245. /**
  62246. * The dirty light flag value
  62247. */
  62248. static readonly MATERIAL_LightDirtyFlag: number;
  62249. /**
  62250. * The dirty fresnel flag value
  62251. */
  62252. static readonly MATERIAL_FresnelDirtyFlag: number;
  62253. /**
  62254. * The dirty attribute flag value
  62255. */
  62256. static readonly MATERIAL_AttributesDirtyFlag: number;
  62257. /**
  62258. * The dirty misc flag value
  62259. */
  62260. static readonly MATERIAL_MiscDirtyFlag: number;
  62261. /**
  62262. * The all dirty flag value
  62263. */
  62264. static readonly MATERIAL_AllDirtyFlag: number;
  62265. /**
  62266. * Returns the triangle fill mode
  62267. */
  62268. static readonly MATERIAL_TriangleFillMode: number;
  62269. /**
  62270. * Returns the wireframe mode
  62271. */
  62272. static readonly MATERIAL_WireFrameFillMode: number;
  62273. /**
  62274. * Returns the point fill mode
  62275. */
  62276. static readonly MATERIAL_PointFillMode: number;
  62277. /**
  62278. * Returns the point list draw mode
  62279. */
  62280. static readonly MATERIAL_PointListDrawMode: number;
  62281. /**
  62282. * Returns the line list draw mode
  62283. */
  62284. static readonly MATERIAL_LineListDrawMode: number;
  62285. /**
  62286. * Returns the line loop draw mode
  62287. */
  62288. static readonly MATERIAL_LineLoopDrawMode: number;
  62289. /**
  62290. * Returns the line strip draw mode
  62291. */
  62292. static readonly MATERIAL_LineStripDrawMode: number;
  62293. /**
  62294. * Returns the triangle strip draw mode
  62295. */
  62296. static readonly MATERIAL_TriangleStripDrawMode: number;
  62297. /**
  62298. * Returns the triangle fan draw mode
  62299. */
  62300. static readonly MATERIAL_TriangleFanDrawMode: number;
  62301. /**
  62302. * Stores the clock-wise side orientation
  62303. */
  62304. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62305. /**
  62306. * Stores the counter clock-wise side orientation
  62307. */
  62308. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62309. /**
  62310. * Nothing
  62311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62312. */
  62313. static readonly ACTION_NothingTrigger: number;
  62314. /**
  62315. * On pick
  62316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62317. */
  62318. static readonly ACTION_OnPickTrigger: number;
  62319. /**
  62320. * On left pick
  62321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62322. */
  62323. static readonly ACTION_OnLeftPickTrigger: number;
  62324. /**
  62325. * On right pick
  62326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62327. */
  62328. static readonly ACTION_OnRightPickTrigger: number;
  62329. /**
  62330. * On center pick
  62331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62332. */
  62333. static readonly ACTION_OnCenterPickTrigger: number;
  62334. /**
  62335. * On pick down
  62336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62337. */
  62338. static readonly ACTION_OnPickDownTrigger: number;
  62339. /**
  62340. * On double pick
  62341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62342. */
  62343. static readonly ACTION_OnDoublePickTrigger: number;
  62344. /**
  62345. * On pick up
  62346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62347. */
  62348. static readonly ACTION_OnPickUpTrigger: number;
  62349. /**
  62350. * On pick out.
  62351. * This trigger will only be raised if you also declared a OnPickDown
  62352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62353. */
  62354. static readonly ACTION_OnPickOutTrigger: number;
  62355. /**
  62356. * On long press
  62357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62358. */
  62359. static readonly ACTION_OnLongPressTrigger: number;
  62360. /**
  62361. * On pointer over
  62362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62363. */
  62364. static readonly ACTION_OnPointerOverTrigger: number;
  62365. /**
  62366. * On pointer out
  62367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62368. */
  62369. static readonly ACTION_OnPointerOutTrigger: number;
  62370. /**
  62371. * On every frame
  62372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62373. */
  62374. static readonly ACTION_OnEveryFrameTrigger: number;
  62375. /**
  62376. * On intersection enter
  62377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62378. */
  62379. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62380. /**
  62381. * On intersection exit
  62382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62383. */
  62384. static readonly ACTION_OnIntersectionExitTrigger: number;
  62385. /**
  62386. * On key down
  62387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62388. */
  62389. static readonly ACTION_OnKeyDownTrigger: number;
  62390. /**
  62391. * On key up
  62392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62393. */
  62394. static readonly ACTION_OnKeyUpTrigger: number;
  62395. /**
  62396. * Billboard mode will only apply to Y axis
  62397. */
  62398. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62399. /**
  62400. * Billboard mode will apply to all axes
  62401. */
  62402. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62403. /**
  62404. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62405. */
  62406. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62407. /**
  62408. * Gets or sets base Assets URL
  62409. */
  62410. static readonly PARTICLES_BaseAssetsUrl: string;
  62411. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62412. * Test order :
  62413. * Is the bounding sphere outside the frustum ?
  62414. * If not, are the bounding box vertices outside the frustum ?
  62415. * It not, then the cullable object is in the frustum.
  62416. */
  62417. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62418. /** Culling strategy : Bounding Sphere Only.
  62419. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62420. * It's also less accurate than the standard because some not visible objects can still be selected.
  62421. * Test : is the bounding sphere outside the frustum ?
  62422. * If not, then the cullable object is in the frustum.
  62423. */
  62424. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62425. /** Culling strategy : Optimistic Inclusion.
  62426. * This in an inclusion test first, then the standard exclusion test.
  62427. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62428. * 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.
  62429. * Anyway, it's as accurate as the standard strategy.
  62430. * Test :
  62431. * Is the cullable object bounding sphere center in the frustum ?
  62432. * If not, apply the default culling strategy.
  62433. */
  62434. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62435. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62436. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62437. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62438. * 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.
  62439. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62440. * Test :
  62441. * Is the cullable object bounding sphere center in the frustum ?
  62442. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62443. */
  62444. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62445. /**
  62446. * No logging while loading
  62447. */
  62448. static readonly SCENELOADER_NO_LOGGING: number;
  62449. /**
  62450. * Minimal logging while loading
  62451. */
  62452. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62453. /**
  62454. * Summary logging while loading
  62455. */
  62456. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62457. /**
  62458. * Detailled logging while loading
  62459. */
  62460. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62461. }
  62462. }
  62463. declare module BABYLON {
  62464. /**
  62465. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62466. * Babylon.js
  62467. */
  62468. export class DomManagement {
  62469. /**
  62470. * Checks if the window object exists
  62471. * @returns true if the window object exists
  62472. */
  62473. static IsWindowObjectExist(): boolean;
  62474. /**
  62475. * Extracts text content from a DOM element hierarchy
  62476. * @param element defines the root element
  62477. * @returns a string
  62478. */
  62479. static GetDOMTextContent(element: HTMLElement): string;
  62480. }
  62481. }
  62482. declare module BABYLON {
  62483. /**
  62484. * Logger used througouht the application to allow configuration of
  62485. * the log level required for the messages.
  62486. */
  62487. export class Logger {
  62488. /**
  62489. * No log
  62490. */
  62491. static readonly NoneLogLevel: number;
  62492. /**
  62493. * Only message logs
  62494. */
  62495. static readonly MessageLogLevel: number;
  62496. /**
  62497. * Only warning logs
  62498. */
  62499. static readonly WarningLogLevel: number;
  62500. /**
  62501. * Only error logs
  62502. */
  62503. static readonly ErrorLogLevel: number;
  62504. /**
  62505. * All logs
  62506. */
  62507. static readonly AllLogLevel: number;
  62508. private static _LogCache;
  62509. /**
  62510. * Gets a value indicating the number of loading errors
  62511. * @ignorenaming
  62512. */
  62513. static errorsCount: number;
  62514. /**
  62515. * Callback called when a new log is added
  62516. */
  62517. static OnNewCacheEntry: (entry: string) => void;
  62518. private static _AddLogEntry;
  62519. private static _FormatMessage;
  62520. private static _LogDisabled;
  62521. private static _LogEnabled;
  62522. private static _WarnDisabled;
  62523. private static _WarnEnabled;
  62524. private static _ErrorDisabled;
  62525. private static _ErrorEnabled;
  62526. /**
  62527. * Log a message to the console
  62528. */
  62529. static Log: (message: string) => void;
  62530. /**
  62531. * Write a warning message to the console
  62532. */
  62533. static Warn: (message: string) => void;
  62534. /**
  62535. * Write an error message to the console
  62536. */
  62537. static Error: (message: string) => void;
  62538. /**
  62539. * Gets current log cache (list of logs)
  62540. */
  62541. static readonly LogCache: string;
  62542. /**
  62543. * Clears the log cache
  62544. */
  62545. static ClearLogCache(): void;
  62546. /**
  62547. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62548. */
  62549. static LogLevels: number;
  62550. }
  62551. }
  62552. declare module BABYLON {
  62553. /** @hidden */
  62554. export class _TypeStore {
  62555. /** @hidden */
  62556. static RegisteredTypes: {
  62557. [key: string]: Object;
  62558. };
  62559. /** @hidden */
  62560. static GetClass(fqdn: string): any;
  62561. }
  62562. }
  62563. declare module BABYLON {
  62564. /**
  62565. * Class containing a set of static utilities functions for deep copy.
  62566. */
  62567. export class DeepCopier {
  62568. /**
  62569. * Tries to copy an object by duplicating every property
  62570. * @param source defines the source object
  62571. * @param destination defines the target object
  62572. * @param doNotCopyList defines a list of properties to avoid
  62573. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62574. */
  62575. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62576. }
  62577. }
  62578. declare module BABYLON {
  62579. /**
  62580. * Class containing a set of static utilities functions for precision date
  62581. */
  62582. export class PrecisionDate {
  62583. /**
  62584. * Gets either window.performance.now() if supported or Date.now() else
  62585. */
  62586. static readonly Now: number;
  62587. }
  62588. }
  62589. declare module BABYLON {
  62590. /** @hidden */
  62591. export class _DevTools {
  62592. static WarnImport(name: string): string;
  62593. }
  62594. }
  62595. declare module BABYLON {
  62596. /**
  62597. * Class used to evalaute queries containing `and` and `or` operators
  62598. */
  62599. export class AndOrNotEvaluator {
  62600. /**
  62601. * Evaluate a query
  62602. * @param query defines the query to evaluate
  62603. * @param evaluateCallback defines the callback used to filter result
  62604. * @returns true if the query matches
  62605. */
  62606. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62607. private static _HandleParenthesisContent;
  62608. private static _SimplifyNegation;
  62609. }
  62610. }
  62611. declare module BABYLON {
  62612. /**
  62613. * Class used to store custom tags
  62614. */
  62615. export class Tags {
  62616. /**
  62617. * Adds support for tags on the given object
  62618. * @param obj defines the object to use
  62619. */
  62620. static EnableFor(obj: any): void;
  62621. /**
  62622. * Removes tags support
  62623. * @param obj defines the object to use
  62624. */
  62625. static DisableFor(obj: any): void;
  62626. /**
  62627. * Gets a boolean indicating if the given object has tags
  62628. * @param obj defines the object to use
  62629. * @returns a boolean
  62630. */
  62631. static HasTags(obj: any): boolean;
  62632. /**
  62633. * Gets the tags available on a given object
  62634. * @param obj defines the object to use
  62635. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62636. * @returns the tags
  62637. */
  62638. static GetTags(obj: any, asString?: boolean): any;
  62639. /**
  62640. * Adds tags to an object
  62641. * @param obj defines the object to use
  62642. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62643. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62644. */
  62645. static AddTagsTo(obj: any, tagsString: string): void;
  62646. /**
  62647. * @hidden
  62648. */
  62649. static _AddTagTo(obj: any, tag: string): void;
  62650. /**
  62651. * Removes specific tags from a specific object
  62652. * @param obj defines the object to use
  62653. * @param tagsString defines the tags to remove
  62654. */
  62655. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62656. /**
  62657. * @hidden
  62658. */
  62659. static _RemoveTagFrom(obj: any, tag: string): void;
  62660. /**
  62661. * Defines if tags hosted on an object match a given query
  62662. * @param obj defines the object to use
  62663. * @param tagsQuery defines the tag query
  62664. * @returns a boolean
  62665. */
  62666. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62667. }
  62668. }
  62669. declare module BABYLON {
  62670. /**
  62671. * Manages the defines for the Material
  62672. */
  62673. export class MaterialDefines {
  62674. private _keys;
  62675. private _isDirty;
  62676. /** @hidden */
  62677. _renderId: number;
  62678. /** @hidden */
  62679. _areLightsDirty: boolean;
  62680. /** @hidden */
  62681. _areAttributesDirty: boolean;
  62682. /** @hidden */
  62683. _areTexturesDirty: boolean;
  62684. /** @hidden */
  62685. _areFresnelDirty: boolean;
  62686. /** @hidden */
  62687. _areMiscDirty: boolean;
  62688. /** @hidden */
  62689. _areImageProcessingDirty: boolean;
  62690. /** @hidden */
  62691. _normals: boolean;
  62692. /** @hidden */
  62693. _uvs: boolean;
  62694. /** @hidden */
  62695. _needNormals: boolean;
  62696. /** @hidden */
  62697. _needUVs: boolean;
  62698. /**
  62699. * Specifies if the material needs to be re-calculated
  62700. */
  62701. readonly isDirty: boolean;
  62702. /**
  62703. * Marks the material to indicate that it has been re-calculated
  62704. */
  62705. markAsProcessed(): void;
  62706. /**
  62707. * Marks the material to indicate that it needs to be re-calculated
  62708. */
  62709. markAsUnprocessed(): void;
  62710. /**
  62711. * Marks the material to indicate all of its defines need to be re-calculated
  62712. */
  62713. markAllAsDirty(): void;
  62714. /**
  62715. * Marks the material to indicate that image processing needs to be re-calculated
  62716. */
  62717. markAsImageProcessingDirty(): void;
  62718. /**
  62719. * Marks the material to indicate the lights need to be re-calculated
  62720. */
  62721. markAsLightDirty(): void;
  62722. /**
  62723. * Marks the attribute state as changed
  62724. */
  62725. markAsAttributesDirty(): void;
  62726. /**
  62727. * Marks the texture state as changed
  62728. */
  62729. markAsTexturesDirty(): void;
  62730. /**
  62731. * Marks the fresnel state as changed
  62732. */
  62733. markAsFresnelDirty(): void;
  62734. /**
  62735. * Marks the misc state as changed
  62736. */
  62737. markAsMiscDirty(): void;
  62738. /**
  62739. * Rebuilds the material defines
  62740. */
  62741. rebuild(): void;
  62742. /**
  62743. * Specifies if two material defines are equal
  62744. * @param other - A material define instance to compare to
  62745. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62746. */
  62747. isEqual(other: MaterialDefines): boolean;
  62748. /**
  62749. * Clones this instance's defines to another instance
  62750. * @param other - material defines to clone values to
  62751. */
  62752. cloneTo(other: MaterialDefines): void;
  62753. /**
  62754. * Resets the material define values
  62755. */
  62756. reset(): void;
  62757. /**
  62758. * Converts the material define values to a string
  62759. * @returns - String of material define information
  62760. */
  62761. toString(): string;
  62762. }
  62763. }
  62764. declare module BABYLON {
  62765. /**
  62766. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62767. */
  62768. export class PerformanceMonitor {
  62769. private _enabled;
  62770. private _rollingFrameTime;
  62771. private _lastFrameTimeMs;
  62772. /**
  62773. * constructor
  62774. * @param frameSampleSize The number of samples required to saturate the sliding window
  62775. */
  62776. constructor(frameSampleSize?: number);
  62777. /**
  62778. * Samples current frame
  62779. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62780. */
  62781. sampleFrame(timeMs?: number): void;
  62782. /**
  62783. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62784. */
  62785. readonly averageFrameTime: number;
  62786. /**
  62787. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62788. */
  62789. readonly averageFrameTimeVariance: number;
  62790. /**
  62791. * Returns the frame time of the most recent frame
  62792. */
  62793. readonly instantaneousFrameTime: number;
  62794. /**
  62795. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62796. */
  62797. readonly averageFPS: number;
  62798. /**
  62799. * Returns the average framerate in frames per second using the most recent frame time
  62800. */
  62801. readonly instantaneousFPS: number;
  62802. /**
  62803. * Returns true if enough samples have been taken to completely fill the sliding window
  62804. */
  62805. readonly isSaturated: boolean;
  62806. /**
  62807. * Enables contributions to the sliding window sample set
  62808. */
  62809. enable(): void;
  62810. /**
  62811. * Disables contributions to the sliding window sample set
  62812. * Samples will not be interpolated over the disabled period
  62813. */
  62814. disable(): void;
  62815. /**
  62816. * Returns true if sampling is enabled
  62817. */
  62818. readonly isEnabled: boolean;
  62819. /**
  62820. * Resets performance monitor
  62821. */
  62822. reset(): void;
  62823. }
  62824. /**
  62825. * RollingAverage
  62826. *
  62827. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62828. */
  62829. export class RollingAverage {
  62830. /**
  62831. * Current average
  62832. */
  62833. average: number;
  62834. /**
  62835. * Current variance
  62836. */
  62837. variance: number;
  62838. protected _samples: Array<number>;
  62839. protected _sampleCount: number;
  62840. protected _pos: number;
  62841. protected _m2: number;
  62842. /**
  62843. * constructor
  62844. * @param length The number of samples required to saturate the sliding window
  62845. */
  62846. constructor(length: number);
  62847. /**
  62848. * Adds a sample to the sample set
  62849. * @param v The sample value
  62850. */
  62851. add(v: number): void;
  62852. /**
  62853. * Returns previously added values or null if outside of history or outside the sliding window domain
  62854. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62855. * @return Value previously recorded with add() or null if outside of range
  62856. */
  62857. history(i: number): number;
  62858. /**
  62859. * Returns true if enough samples have been taken to completely fill the sliding window
  62860. * @return true if sample-set saturated
  62861. */
  62862. isSaturated(): boolean;
  62863. /**
  62864. * Resets the rolling average (equivalent to 0 samples taken so far)
  62865. */
  62866. reset(): void;
  62867. /**
  62868. * Wraps a value around the sample range boundaries
  62869. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62870. * @return Wrapped position in sample range
  62871. */
  62872. protected _wrapPosition(i: number): number;
  62873. }
  62874. }
  62875. declare module BABYLON {
  62876. /**
  62877. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62878. * The underlying implementation relies on an associative array to ensure the best performances.
  62879. * The value can be anything including 'null' but except 'undefined'
  62880. */
  62881. export class StringDictionary<T> {
  62882. /**
  62883. * This will clear this dictionary and copy the content from the 'source' one.
  62884. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62885. * @param source the dictionary to take the content from and copy to this dictionary
  62886. */
  62887. copyFrom(source: StringDictionary<T>): void;
  62888. /**
  62889. * Get a value based from its key
  62890. * @param key the given key to get the matching value from
  62891. * @return the value if found, otherwise undefined is returned
  62892. */
  62893. get(key: string): T | undefined;
  62894. /**
  62895. * Get a value from its key or add it if it doesn't exist.
  62896. * This method will ensure you that a given key/data will be present in the dictionary.
  62897. * @param key the given key to get the matching value from
  62898. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62899. * The factory will only be invoked if there's no data for the given key.
  62900. * @return the value corresponding to the key.
  62901. */
  62902. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62903. /**
  62904. * Get a value from its key if present in the dictionary otherwise add it
  62905. * @param key the key to get the value from
  62906. * @param val if there's no such key/value pair in the dictionary add it with this value
  62907. * @return the value corresponding to the key
  62908. */
  62909. getOrAdd(key: string, val: T): T;
  62910. /**
  62911. * Check if there's a given key in the dictionary
  62912. * @param key the key to check for
  62913. * @return true if the key is present, false otherwise
  62914. */
  62915. contains(key: string): boolean;
  62916. /**
  62917. * Add a new key and its corresponding value
  62918. * @param key the key to add
  62919. * @param value the value corresponding to the key
  62920. * @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
  62921. */
  62922. add(key: string, value: T): boolean;
  62923. /**
  62924. * Update a specific value associated to a key
  62925. * @param key defines the key to use
  62926. * @param value defines the value to store
  62927. * @returns true if the value was updated (or false if the key was not found)
  62928. */
  62929. set(key: string, value: T): boolean;
  62930. /**
  62931. * Get the element of the given key and remove it from the dictionary
  62932. * @param key defines the key to search
  62933. * @returns the value associated with the key or null if not found
  62934. */
  62935. getAndRemove(key: string): Nullable<T>;
  62936. /**
  62937. * Remove a key/value from the dictionary.
  62938. * @param key the key to remove
  62939. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62940. */
  62941. remove(key: string): boolean;
  62942. /**
  62943. * Clear the whole content of the dictionary
  62944. */
  62945. clear(): void;
  62946. /**
  62947. * Gets the current count
  62948. */
  62949. readonly count: number;
  62950. /**
  62951. * Execute a callback on each key/val of the dictionary.
  62952. * Note that you can remove any element in this dictionary in the callback implementation
  62953. * @param callback the callback to execute on a given key/value pair
  62954. */
  62955. forEach(callback: (key: string, val: T) => void): void;
  62956. /**
  62957. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62958. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62959. * Note that you can remove any element in this dictionary in the callback implementation
  62960. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62961. * @returns the first item
  62962. */
  62963. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62964. private _count;
  62965. private _data;
  62966. }
  62967. }
  62968. declare module BABYLON {
  62969. /**
  62970. * Helper class that provides a small promise polyfill
  62971. */
  62972. export class PromisePolyfill {
  62973. /**
  62974. * Static function used to check if the polyfill is required
  62975. * If this is the case then the function will inject the polyfill to window.Promise
  62976. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62977. */
  62978. static Apply(force?: boolean): void;
  62979. }
  62980. }
  62981. declare module BABYLON {
  62982. /**
  62983. * Class used to store data that will be store in GPU memory
  62984. */
  62985. export class Buffer {
  62986. private _engine;
  62987. private _buffer;
  62988. /** @hidden */
  62989. _data: Nullable<DataArray>;
  62990. private _updatable;
  62991. private _instanced;
  62992. /**
  62993. * Gets the byte stride.
  62994. */
  62995. readonly byteStride: number;
  62996. /**
  62997. * Constructor
  62998. * @param engine the engine
  62999. * @param data the data to use for this buffer
  63000. * @param updatable whether the data is updatable
  63001. * @param stride the stride (optional)
  63002. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63003. * @param instanced whether the buffer is instanced (optional)
  63004. * @param useBytes set to true if the stride in in bytes (optional)
  63005. */
  63006. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63007. /**
  63008. * Create a new VertexBuffer based on the current buffer
  63009. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63010. * @param offset defines offset in the buffer (0 by default)
  63011. * @param size defines the size in floats of attributes (position is 3 for instance)
  63012. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63013. * @param instanced defines if the vertex buffer contains indexed data
  63014. * @param useBytes defines if the offset and stride are in bytes
  63015. * @returns the new vertex buffer
  63016. */
  63017. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63018. /**
  63019. * Gets a boolean indicating if the Buffer is updatable?
  63020. * @returns true if the buffer is updatable
  63021. */
  63022. isUpdatable(): boolean;
  63023. /**
  63024. * Gets current buffer's data
  63025. * @returns a DataArray or null
  63026. */
  63027. getData(): Nullable<DataArray>;
  63028. /**
  63029. * Gets underlying native buffer
  63030. * @returns underlying native buffer
  63031. */
  63032. getBuffer(): Nullable<WebGLBuffer>;
  63033. /**
  63034. * Gets the stride in float32 units (i.e. byte stride / 4).
  63035. * May not be an integer if the byte stride is not divisible by 4.
  63036. * DEPRECATED. Use byteStride instead.
  63037. * @returns the stride in float32 units
  63038. */
  63039. getStrideSize(): number;
  63040. /**
  63041. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63042. * @param data defines the data to store
  63043. */
  63044. create(data?: Nullable<DataArray>): void;
  63045. /** @hidden */
  63046. _rebuild(): void;
  63047. /**
  63048. * Update current buffer data
  63049. * @param data defines the data to store
  63050. */
  63051. update(data: DataArray): void;
  63052. /**
  63053. * Updates the data directly.
  63054. * @param data the new data
  63055. * @param offset the new offset
  63056. * @param vertexCount the vertex count (optional)
  63057. * @param useBytes set to true if the offset is in bytes
  63058. */
  63059. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63060. /**
  63061. * Release all resources
  63062. */
  63063. dispose(): void;
  63064. }
  63065. /**
  63066. * Specialized buffer used to store vertex data
  63067. */
  63068. export class VertexBuffer {
  63069. /** @hidden */
  63070. _buffer: Buffer;
  63071. private _kind;
  63072. private _size;
  63073. private _ownsBuffer;
  63074. private _instanced;
  63075. private _instanceDivisor;
  63076. /**
  63077. * The byte type.
  63078. */
  63079. static readonly BYTE: number;
  63080. /**
  63081. * The unsigned byte type.
  63082. */
  63083. static readonly UNSIGNED_BYTE: number;
  63084. /**
  63085. * The short type.
  63086. */
  63087. static readonly SHORT: number;
  63088. /**
  63089. * The unsigned short type.
  63090. */
  63091. static readonly UNSIGNED_SHORT: number;
  63092. /**
  63093. * The integer type.
  63094. */
  63095. static readonly INT: number;
  63096. /**
  63097. * The unsigned integer type.
  63098. */
  63099. static readonly UNSIGNED_INT: number;
  63100. /**
  63101. * The float type.
  63102. */
  63103. static readonly FLOAT: number;
  63104. /**
  63105. * Gets or sets the instance divisor when in instanced mode
  63106. */
  63107. instanceDivisor: number;
  63108. /**
  63109. * Gets the byte stride.
  63110. */
  63111. readonly byteStride: number;
  63112. /**
  63113. * Gets the byte offset.
  63114. */
  63115. readonly byteOffset: number;
  63116. /**
  63117. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63118. */
  63119. readonly normalized: boolean;
  63120. /**
  63121. * Gets the data type of each component in the array.
  63122. */
  63123. readonly type: number;
  63124. /**
  63125. * Constructor
  63126. * @param engine the engine
  63127. * @param data the data to use for this vertex buffer
  63128. * @param kind the vertex buffer kind
  63129. * @param updatable whether the data is updatable
  63130. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63131. * @param stride the stride (optional)
  63132. * @param instanced whether the buffer is instanced (optional)
  63133. * @param offset the offset of the data (optional)
  63134. * @param size the number of components (optional)
  63135. * @param type the type of the component (optional)
  63136. * @param normalized whether the data contains normalized data (optional)
  63137. * @param useBytes set to true if stride and offset are in bytes (optional)
  63138. */
  63139. 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);
  63140. /** @hidden */
  63141. _rebuild(): void;
  63142. /**
  63143. * Returns the kind of the VertexBuffer (string)
  63144. * @returns a string
  63145. */
  63146. getKind(): string;
  63147. /**
  63148. * Gets a boolean indicating if the VertexBuffer is updatable?
  63149. * @returns true if the buffer is updatable
  63150. */
  63151. isUpdatable(): boolean;
  63152. /**
  63153. * Gets current buffer's data
  63154. * @returns a DataArray or null
  63155. */
  63156. getData(): Nullable<DataArray>;
  63157. /**
  63158. * Gets underlying native buffer
  63159. * @returns underlying native buffer
  63160. */
  63161. getBuffer(): Nullable<WebGLBuffer>;
  63162. /**
  63163. * Gets the stride in float32 units (i.e. byte stride / 4).
  63164. * May not be an integer if the byte stride is not divisible by 4.
  63165. * DEPRECATED. Use byteStride instead.
  63166. * @returns the stride in float32 units
  63167. */
  63168. getStrideSize(): number;
  63169. /**
  63170. * Returns the offset as a multiple of the type byte length.
  63171. * DEPRECATED. Use byteOffset instead.
  63172. * @returns the offset in bytes
  63173. */
  63174. getOffset(): number;
  63175. /**
  63176. * Returns the number of components per vertex attribute (integer)
  63177. * @returns the size in float
  63178. */
  63179. getSize(): number;
  63180. /**
  63181. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63182. * @returns true if this buffer is instanced
  63183. */
  63184. getIsInstanced(): boolean;
  63185. /**
  63186. * Returns the instancing divisor, zero for non-instanced (integer).
  63187. * @returns a number
  63188. */
  63189. getInstanceDivisor(): number;
  63190. /**
  63191. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63192. * @param data defines the data to store
  63193. */
  63194. create(data?: DataArray): void;
  63195. /**
  63196. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  63197. * This function will create a new buffer if the current one is not updatable
  63198. * @param data defines the data to store
  63199. */
  63200. update(data: DataArray): void;
  63201. /**
  63202. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  63203. * Returns the directly updated WebGLBuffer.
  63204. * @param data the new data
  63205. * @param offset the new offset
  63206. * @param useBytes set to true if the offset is in bytes
  63207. */
  63208. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  63209. /**
  63210. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  63211. */
  63212. dispose(): void;
  63213. /**
  63214. * Enumerates each value of this vertex buffer as numbers.
  63215. * @param count the number of values to enumerate
  63216. * @param callback the callback function called for each value
  63217. */
  63218. forEach(count: number, callback: (value: number, index: number) => void): void;
  63219. /**
  63220. * Positions
  63221. */
  63222. static readonly PositionKind: string;
  63223. /**
  63224. * Normals
  63225. */
  63226. static readonly NormalKind: string;
  63227. /**
  63228. * Tangents
  63229. */
  63230. static readonly TangentKind: string;
  63231. /**
  63232. * Texture coordinates
  63233. */
  63234. static readonly UVKind: string;
  63235. /**
  63236. * Texture coordinates 2
  63237. */
  63238. static readonly UV2Kind: string;
  63239. /**
  63240. * Texture coordinates 3
  63241. */
  63242. static readonly UV3Kind: string;
  63243. /**
  63244. * Texture coordinates 4
  63245. */
  63246. static readonly UV4Kind: string;
  63247. /**
  63248. * Texture coordinates 5
  63249. */
  63250. static readonly UV5Kind: string;
  63251. /**
  63252. * Texture coordinates 6
  63253. */
  63254. static readonly UV6Kind: string;
  63255. /**
  63256. * Colors
  63257. */
  63258. static readonly ColorKind: string;
  63259. /**
  63260. * Matrix indices (for bones)
  63261. */
  63262. static readonly MatricesIndicesKind: string;
  63263. /**
  63264. * Matrix weights (for bones)
  63265. */
  63266. static readonly MatricesWeightsKind: string;
  63267. /**
  63268. * Additional matrix indices (for bones)
  63269. */
  63270. static readonly MatricesIndicesExtraKind: string;
  63271. /**
  63272. * Additional matrix weights (for bones)
  63273. */
  63274. static readonly MatricesWeightsExtraKind: string;
  63275. /**
  63276. * Deduces the stride given a kind.
  63277. * @param kind The kind string to deduce
  63278. * @returns The deduced stride
  63279. */
  63280. static DeduceStride(kind: string): number;
  63281. /**
  63282. * Gets the byte length of the given type.
  63283. * @param type the type
  63284. * @returns the number of bytes
  63285. */
  63286. static GetTypeByteLength(type: number): number;
  63287. /**
  63288. * Enumerates each value of the given parameters as numbers.
  63289. * @param data the data to enumerate
  63290. * @param byteOffset the byte offset of the data
  63291. * @param byteStride the byte stride of the data
  63292. * @param componentCount the number of components per element
  63293. * @param componentType the type of the component
  63294. * @param count the total number of components
  63295. * @param normalized whether the data is normalized
  63296. * @param callback the callback function called for each value
  63297. */
  63298. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63299. private static _GetFloatValue;
  63300. }
  63301. }
  63302. declare module BABYLON {
  63303. /**
  63304. * Class representing spherical polynomial coefficients to the 3rd degree
  63305. */
  63306. export class SphericalPolynomial {
  63307. /**
  63308. * The x coefficients of the spherical polynomial
  63309. */
  63310. x: Vector3;
  63311. /**
  63312. * The y coefficients of the spherical polynomial
  63313. */
  63314. y: Vector3;
  63315. /**
  63316. * The z coefficients of the spherical polynomial
  63317. */
  63318. z: Vector3;
  63319. /**
  63320. * The xx coefficients of the spherical polynomial
  63321. */
  63322. xx: Vector3;
  63323. /**
  63324. * The yy coefficients of the spherical polynomial
  63325. */
  63326. yy: Vector3;
  63327. /**
  63328. * The zz coefficients of the spherical polynomial
  63329. */
  63330. zz: Vector3;
  63331. /**
  63332. * The xy coefficients of the spherical polynomial
  63333. */
  63334. xy: Vector3;
  63335. /**
  63336. * The yz coefficients of the spherical polynomial
  63337. */
  63338. yz: Vector3;
  63339. /**
  63340. * The zx coefficients of the spherical polynomial
  63341. */
  63342. zx: Vector3;
  63343. /**
  63344. * Adds an ambient color to the spherical polynomial
  63345. * @param color the color to add
  63346. */
  63347. addAmbient(color: Color3): void;
  63348. /**
  63349. * Scales the spherical polynomial by the given amount
  63350. * @param scale the amount to scale
  63351. */
  63352. scale(scale: number): void;
  63353. /**
  63354. * Gets the spherical polynomial from harmonics
  63355. * @param harmonics the spherical harmonics
  63356. * @returns the spherical polynomial
  63357. */
  63358. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63359. /**
  63360. * Constructs a spherical polynomial from an array.
  63361. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63362. * @returns the spherical polynomial
  63363. */
  63364. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63365. }
  63366. /**
  63367. * Class representing spherical harmonics coefficients to the 3rd degree
  63368. */
  63369. export class SphericalHarmonics {
  63370. /**
  63371. * The l0,0 coefficients of the spherical harmonics
  63372. */
  63373. l00: Vector3;
  63374. /**
  63375. * The l1,-1 coefficients of the spherical harmonics
  63376. */
  63377. l1_1: Vector3;
  63378. /**
  63379. * The l1,0 coefficients of the spherical harmonics
  63380. */
  63381. l10: Vector3;
  63382. /**
  63383. * The l1,1 coefficients of the spherical harmonics
  63384. */
  63385. l11: Vector3;
  63386. /**
  63387. * The l2,-2 coefficients of the spherical harmonics
  63388. */
  63389. l2_2: Vector3;
  63390. /**
  63391. * The l2,-1 coefficients of the spherical harmonics
  63392. */
  63393. l2_1: Vector3;
  63394. /**
  63395. * The l2,0 coefficients of the spherical harmonics
  63396. */
  63397. l20: Vector3;
  63398. /**
  63399. * The l2,1 coefficients of the spherical harmonics
  63400. */
  63401. l21: Vector3;
  63402. /**
  63403. * The l2,2 coefficients of the spherical harmonics
  63404. */
  63405. lL22: Vector3;
  63406. /**
  63407. * Adds a light to the spherical harmonics
  63408. * @param direction the direction of the light
  63409. * @param color the color of the light
  63410. * @param deltaSolidAngle the delta solid angle of the light
  63411. */
  63412. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63413. /**
  63414. * Scales the spherical harmonics by the given amount
  63415. * @param scale the amount to scale
  63416. */
  63417. scale(scale: number): void;
  63418. /**
  63419. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63420. *
  63421. * ```
  63422. * E_lm = A_l * L_lm
  63423. * ```
  63424. *
  63425. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63426. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63427. * the scaling factors are given in equation 9.
  63428. */
  63429. convertIncidentRadianceToIrradiance(): void;
  63430. /**
  63431. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63432. *
  63433. * ```
  63434. * L = (1/pi) * E * rho
  63435. * ```
  63436. *
  63437. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63438. */
  63439. convertIrradianceToLambertianRadiance(): void;
  63440. /**
  63441. * Gets the spherical harmonics from polynomial
  63442. * @param polynomial the spherical polynomial
  63443. * @returns the spherical harmonics
  63444. */
  63445. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63446. /**
  63447. * Constructs a spherical harmonics from an array.
  63448. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63449. * @returns the spherical harmonics
  63450. */
  63451. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63452. }
  63453. }
  63454. declare module BABYLON {
  63455. /**
  63456. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63457. */
  63458. export interface CubeMapInfo {
  63459. /**
  63460. * The pixel array for the front face.
  63461. * This is stored in format, left to right, up to down format.
  63462. */
  63463. front: Nullable<ArrayBufferView>;
  63464. /**
  63465. * The pixel array for the back face.
  63466. * This is stored in format, left to right, up to down format.
  63467. */
  63468. back: Nullable<ArrayBufferView>;
  63469. /**
  63470. * The pixel array for the left face.
  63471. * This is stored in format, left to right, up to down format.
  63472. */
  63473. left: Nullable<ArrayBufferView>;
  63474. /**
  63475. * The pixel array for the right face.
  63476. * This is stored in format, left to right, up to down format.
  63477. */
  63478. right: Nullable<ArrayBufferView>;
  63479. /**
  63480. * The pixel array for the up face.
  63481. * This is stored in format, left to right, up to down format.
  63482. */
  63483. up: Nullable<ArrayBufferView>;
  63484. /**
  63485. * The pixel array for the down face.
  63486. * This is stored in format, left to right, up to down format.
  63487. */
  63488. down: Nullable<ArrayBufferView>;
  63489. /**
  63490. * The size of the cubemap stored.
  63491. *
  63492. * Each faces will be size * size pixels.
  63493. */
  63494. size: number;
  63495. /**
  63496. * The format of the texture.
  63497. *
  63498. * RGBA, RGB.
  63499. */
  63500. format: number;
  63501. /**
  63502. * The type of the texture data.
  63503. *
  63504. * UNSIGNED_INT, FLOAT.
  63505. */
  63506. type: number;
  63507. /**
  63508. * Specifies whether the texture is in gamma space.
  63509. */
  63510. gammaSpace: boolean;
  63511. }
  63512. /**
  63513. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63514. */
  63515. export class PanoramaToCubeMapTools {
  63516. private static FACE_FRONT;
  63517. private static FACE_BACK;
  63518. private static FACE_RIGHT;
  63519. private static FACE_LEFT;
  63520. private static FACE_DOWN;
  63521. private static FACE_UP;
  63522. /**
  63523. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63524. *
  63525. * @param float32Array The source data.
  63526. * @param inputWidth The width of the input panorama.
  63527. * @param inputHeight The height of the input panorama.
  63528. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63529. * @return The cubemap data
  63530. */
  63531. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63532. private static CreateCubemapTexture;
  63533. private static CalcProjectionSpherical;
  63534. }
  63535. }
  63536. declare module BABYLON {
  63537. /**
  63538. * Helper class dealing with the extraction of spherical polynomial dataArray
  63539. * from a cube map.
  63540. */
  63541. export class CubeMapToSphericalPolynomialTools {
  63542. private static FileFaces;
  63543. /**
  63544. * Converts a texture to the according Spherical Polynomial data.
  63545. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63546. *
  63547. * @param texture The texture to extract the information from.
  63548. * @return The Spherical Polynomial data.
  63549. */
  63550. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63551. /**
  63552. * Converts a cubemap to the according Spherical Polynomial data.
  63553. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63554. *
  63555. * @param cubeInfo The Cube map to extract the information from.
  63556. * @return The Spherical Polynomial data.
  63557. */
  63558. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63559. }
  63560. }
  63561. declare module BABYLON {
  63562. /**
  63563. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63564. * during the life time of the application.
  63565. */
  63566. export class EngineStore {
  63567. /** Gets the list of created engines */
  63568. static Instances: Engine[];
  63569. /**
  63570. * Gets the latest created engine
  63571. */
  63572. static readonly LastCreatedEngine: Nullable<Engine>;
  63573. /**
  63574. * Gets the latest created scene
  63575. */
  63576. static readonly LastCreatedScene: Nullable<Scene>;
  63577. }
  63578. }
  63579. declare module BABYLON {
  63580. /**
  63581. * Define options used to create a render target texture
  63582. */
  63583. export class RenderTargetCreationOptions {
  63584. /**
  63585. * Specifies is mipmaps must be generated
  63586. */
  63587. generateMipMaps?: boolean;
  63588. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63589. generateDepthBuffer?: boolean;
  63590. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63591. generateStencilBuffer?: boolean;
  63592. /** Defines texture type (int by default) */
  63593. type?: number;
  63594. /** Defines sampling mode (trilinear by default) */
  63595. samplingMode?: number;
  63596. /** Defines format (RGBA by default) */
  63597. format?: number;
  63598. }
  63599. }
  63600. declare module BABYLON {
  63601. /**
  63602. * @hidden
  63603. **/
  63604. export class _AlphaState {
  63605. private _isAlphaBlendDirty;
  63606. private _isBlendFunctionParametersDirty;
  63607. private _isBlendEquationParametersDirty;
  63608. private _isBlendConstantsDirty;
  63609. private _alphaBlend;
  63610. private _blendFunctionParameters;
  63611. private _blendEquationParameters;
  63612. private _blendConstants;
  63613. /**
  63614. * Initializes the state.
  63615. */
  63616. constructor();
  63617. readonly isDirty: boolean;
  63618. alphaBlend: boolean;
  63619. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63620. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63621. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63622. reset(): void;
  63623. apply(gl: WebGLRenderingContext): void;
  63624. }
  63625. }
  63626. declare module BABYLON {
  63627. /**
  63628. * @hidden
  63629. **/
  63630. export class _DepthCullingState {
  63631. private _isDepthTestDirty;
  63632. private _isDepthMaskDirty;
  63633. private _isDepthFuncDirty;
  63634. private _isCullFaceDirty;
  63635. private _isCullDirty;
  63636. private _isZOffsetDirty;
  63637. private _isFrontFaceDirty;
  63638. private _depthTest;
  63639. private _depthMask;
  63640. private _depthFunc;
  63641. private _cull;
  63642. private _cullFace;
  63643. private _zOffset;
  63644. private _frontFace;
  63645. /**
  63646. * Initializes the state.
  63647. */
  63648. constructor();
  63649. readonly isDirty: boolean;
  63650. zOffset: number;
  63651. cullFace: Nullable<number>;
  63652. cull: Nullable<boolean>;
  63653. depthFunc: Nullable<number>;
  63654. depthMask: boolean;
  63655. depthTest: boolean;
  63656. frontFace: Nullable<number>;
  63657. reset(): void;
  63658. apply(gl: WebGLRenderingContext): void;
  63659. }
  63660. }
  63661. declare module BABYLON {
  63662. /**
  63663. * @hidden
  63664. **/
  63665. export class _StencilState {
  63666. /** 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 */
  63667. static readonly ALWAYS: number;
  63668. /** Passed to stencilOperation to specify that stencil value must be kept */
  63669. static readonly KEEP: number;
  63670. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63671. static readonly REPLACE: number;
  63672. private _isStencilTestDirty;
  63673. private _isStencilMaskDirty;
  63674. private _isStencilFuncDirty;
  63675. private _isStencilOpDirty;
  63676. private _stencilTest;
  63677. private _stencilMask;
  63678. private _stencilFunc;
  63679. private _stencilFuncRef;
  63680. private _stencilFuncMask;
  63681. private _stencilOpStencilFail;
  63682. private _stencilOpDepthFail;
  63683. private _stencilOpStencilDepthPass;
  63684. readonly isDirty: boolean;
  63685. stencilFunc: number;
  63686. stencilFuncRef: number;
  63687. stencilFuncMask: number;
  63688. stencilOpStencilFail: number;
  63689. stencilOpDepthFail: number;
  63690. stencilOpStencilDepthPass: number;
  63691. stencilMask: number;
  63692. stencilTest: boolean;
  63693. constructor();
  63694. reset(): void;
  63695. apply(gl: WebGLRenderingContext): void;
  63696. }
  63697. }
  63698. declare module BABYLON {
  63699. /**
  63700. * @hidden
  63701. **/
  63702. export class _TimeToken {
  63703. _startTimeQuery: Nullable<WebGLQuery>;
  63704. _endTimeQuery: Nullable<WebGLQuery>;
  63705. _timeElapsedQuery: Nullable<WebGLQuery>;
  63706. _timeElapsedQueryEnded: boolean;
  63707. }
  63708. }
  63709. declare module BABYLON {
  63710. /**
  63711. * Internal interface used to track InternalTexture already bound to the GL context
  63712. */
  63713. export interface IInternalTextureTracker {
  63714. /**
  63715. * Gets or set the previous tracker in the list
  63716. */
  63717. previous: Nullable<IInternalTextureTracker>;
  63718. /**
  63719. * Gets or set the next tracker in the list
  63720. */
  63721. next: Nullable<IInternalTextureTracker>;
  63722. }
  63723. /**
  63724. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63725. */
  63726. export class DummyInternalTextureTracker {
  63727. /**
  63728. * Gets or set the previous tracker in the list
  63729. */
  63730. previous: Nullable<IInternalTextureTracker>;
  63731. /**
  63732. * Gets or set the next tracker in the list
  63733. */
  63734. next: Nullable<IInternalTextureTracker>;
  63735. }
  63736. }
  63737. declare module BABYLON {
  63738. /**
  63739. * Class used to store data associated with WebGL texture data for the engine
  63740. * This class should not be used directly
  63741. */
  63742. export class InternalTexture implements IInternalTextureTracker {
  63743. /** hidden */
  63744. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63745. /**
  63746. * The source of the texture data is unknown
  63747. */
  63748. static DATASOURCE_UNKNOWN: number;
  63749. /**
  63750. * Texture data comes from an URL
  63751. */
  63752. static DATASOURCE_URL: number;
  63753. /**
  63754. * Texture data is only used for temporary storage
  63755. */
  63756. static DATASOURCE_TEMP: number;
  63757. /**
  63758. * Texture data comes from raw data (ArrayBuffer)
  63759. */
  63760. static DATASOURCE_RAW: number;
  63761. /**
  63762. * Texture content is dynamic (video or dynamic texture)
  63763. */
  63764. static DATASOURCE_DYNAMIC: number;
  63765. /**
  63766. * Texture content is generated by rendering to it
  63767. */
  63768. static DATASOURCE_RENDERTARGET: number;
  63769. /**
  63770. * Texture content is part of a multi render target process
  63771. */
  63772. static DATASOURCE_MULTIRENDERTARGET: number;
  63773. /**
  63774. * Texture data comes from a cube data file
  63775. */
  63776. static DATASOURCE_CUBE: number;
  63777. /**
  63778. * Texture data comes from a raw cube data
  63779. */
  63780. static DATASOURCE_CUBERAW: number;
  63781. /**
  63782. * Texture data come from a prefiltered cube data file
  63783. */
  63784. static DATASOURCE_CUBEPREFILTERED: number;
  63785. /**
  63786. * Texture content is raw 3D data
  63787. */
  63788. static DATASOURCE_RAW3D: number;
  63789. /**
  63790. * Texture content is a depth texture
  63791. */
  63792. static DATASOURCE_DEPTHTEXTURE: number;
  63793. /**
  63794. * Texture data comes from a raw cube data encoded with RGBD
  63795. */
  63796. static DATASOURCE_CUBERAW_RGBD: number;
  63797. /**
  63798. * Defines if the texture is ready
  63799. */
  63800. isReady: boolean;
  63801. /**
  63802. * Defines if the texture is a cube texture
  63803. */
  63804. isCube: boolean;
  63805. /**
  63806. * Defines if the texture contains 3D data
  63807. */
  63808. is3D: boolean;
  63809. /**
  63810. * Gets the URL used to load this texture
  63811. */
  63812. url: string;
  63813. /**
  63814. * Gets the sampling mode of the texture
  63815. */
  63816. samplingMode: number;
  63817. /**
  63818. * Gets a boolean indicating if the texture needs mipmaps generation
  63819. */
  63820. generateMipMaps: boolean;
  63821. /**
  63822. * Gets the number of samples used by the texture (WebGL2+ only)
  63823. */
  63824. samples: number;
  63825. /**
  63826. * Gets the type of the texture (int, float...)
  63827. */
  63828. type: number;
  63829. /**
  63830. * Gets the format of the texture (RGB, RGBA...)
  63831. */
  63832. format: number;
  63833. /**
  63834. * Observable called when the texture is loaded
  63835. */
  63836. onLoadedObservable: Observable<InternalTexture>;
  63837. /**
  63838. * Gets the width of the texture
  63839. */
  63840. width: number;
  63841. /**
  63842. * Gets the height of the texture
  63843. */
  63844. height: number;
  63845. /**
  63846. * Gets the depth of the texture
  63847. */
  63848. depth: number;
  63849. /**
  63850. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63851. */
  63852. baseWidth: number;
  63853. /**
  63854. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63855. */
  63856. baseHeight: number;
  63857. /**
  63858. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63859. */
  63860. baseDepth: number;
  63861. /**
  63862. * Gets a boolean indicating if the texture is inverted on Y axis
  63863. */
  63864. invertY: boolean;
  63865. /**
  63866. * Gets or set the previous tracker in the list
  63867. */
  63868. previous: Nullable<IInternalTextureTracker>;
  63869. /**
  63870. * Gets or set the next tracker in the list
  63871. */
  63872. next: Nullable<IInternalTextureTracker>;
  63873. /** @hidden */
  63874. _invertVScale: boolean;
  63875. /** @hidden */
  63876. _initialSlot: number;
  63877. /** @hidden */
  63878. _designatedSlot: number;
  63879. /** @hidden */
  63880. _dataSource: number;
  63881. /** @hidden */
  63882. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63883. /** @hidden */
  63884. _bufferView: Nullable<ArrayBufferView>;
  63885. /** @hidden */
  63886. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63887. /** @hidden */
  63888. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63889. /** @hidden */
  63890. _size: number;
  63891. /** @hidden */
  63892. _extension: string;
  63893. /** @hidden */
  63894. _files: Nullable<string[]>;
  63895. /** @hidden */
  63896. _workingCanvas: HTMLCanvasElement;
  63897. /** @hidden */
  63898. _workingContext: CanvasRenderingContext2D;
  63899. /** @hidden */
  63900. _framebuffer: Nullable<WebGLFramebuffer>;
  63901. /** @hidden */
  63902. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63903. /** @hidden */
  63904. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63905. /** @hidden */
  63906. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63907. /** @hidden */
  63908. _attachments: Nullable<number[]>;
  63909. /** @hidden */
  63910. _cachedCoordinatesMode: Nullable<number>;
  63911. /** @hidden */
  63912. _cachedWrapU: Nullable<number>;
  63913. /** @hidden */
  63914. _cachedWrapV: Nullable<number>;
  63915. /** @hidden */
  63916. _cachedWrapR: Nullable<number>;
  63917. /** @hidden */
  63918. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63919. /** @hidden */
  63920. _isDisabled: boolean;
  63921. /** @hidden */
  63922. _compression: Nullable<string>;
  63923. /** @hidden */
  63924. _generateStencilBuffer: boolean;
  63925. /** @hidden */
  63926. _generateDepthBuffer: boolean;
  63927. /** @hidden */
  63928. _comparisonFunction: number;
  63929. /** @hidden */
  63930. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63931. /** @hidden */
  63932. _lodGenerationScale: number;
  63933. /** @hidden */
  63934. _lodGenerationOffset: number;
  63935. /** @hidden */
  63936. _lodTextureHigh: BaseTexture;
  63937. /** @hidden */
  63938. _lodTextureMid: BaseTexture;
  63939. /** @hidden */
  63940. _lodTextureLow: BaseTexture;
  63941. /** @hidden */
  63942. _isRGBD: boolean;
  63943. /** @hidden */
  63944. _webGLTexture: Nullable<WebGLTexture>;
  63945. /** @hidden */
  63946. _references: number;
  63947. private _engine;
  63948. /**
  63949. * Gets the Engine the texture belongs to.
  63950. * @returns The babylon engine
  63951. */
  63952. getEngine(): Engine;
  63953. /**
  63954. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63955. */
  63956. readonly dataSource: number;
  63957. /**
  63958. * Creates a new InternalTexture
  63959. * @param engine defines the engine to use
  63960. * @param dataSource defines the type of data that will be used
  63961. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63962. */
  63963. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63964. /**
  63965. * Increments the number of references (ie. the number of Texture that point to it)
  63966. */
  63967. incrementReferences(): void;
  63968. /**
  63969. * Change the size of the texture (not the size of the content)
  63970. * @param width defines the new width
  63971. * @param height defines the new height
  63972. * @param depth defines the new depth (1 by default)
  63973. */
  63974. updateSize(width: int, height: int, depth?: int): void;
  63975. /** @hidden */
  63976. _rebuild(): void;
  63977. /** @hidden */
  63978. _swapAndDie(target: InternalTexture): void;
  63979. /**
  63980. * Dispose the current allocated resources
  63981. */
  63982. dispose(): void;
  63983. }
  63984. }
  63985. declare module BABYLON {
  63986. /**
  63987. * This represents the main contract an easing function should follow.
  63988. * Easing functions are used throughout the animation system.
  63989. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63990. */
  63991. export interface IEasingFunction {
  63992. /**
  63993. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63994. * of the easing function.
  63995. * The link below provides some of the most common examples of easing functions.
  63996. * @see https://easings.net/
  63997. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63998. * @returns the corresponding value on the curve defined by the easing function
  63999. */
  64000. ease(gradient: number): number;
  64001. }
  64002. /**
  64003. * Base class used for every default easing function.
  64004. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64005. */
  64006. export class EasingFunction implements IEasingFunction {
  64007. /**
  64008. * Interpolation follows the mathematical formula associated with the easing function.
  64009. */
  64010. static readonly EASINGMODE_EASEIN: number;
  64011. /**
  64012. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64013. */
  64014. static readonly EASINGMODE_EASEOUT: number;
  64015. /**
  64016. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64017. */
  64018. static readonly EASINGMODE_EASEINOUT: number;
  64019. private _easingMode;
  64020. /**
  64021. * Sets the easing mode of the current function.
  64022. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64023. */
  64024. setEasingMode(easingMode: number): void;
  64025. /**
  64026. * Gets the current easing mode.
  64027. * @returns the easing mode
  64028. */
  64029. getEasingMode(): number;
  64030. /**
  64031. * @hidden
  64032. */
  64033. easeInCore(gradient: number): number;
  64034. /**
  64035. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64036. * of the easing function.
  64037. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64038. * @returns the corresponding value on the curve defined by the easing function
  64039. */
  64040. ease(gradient: number): number;
  64041. }
  64042. /**
  64043. * Easing function with a circle shape (see link below).
  64044. * @see https://easings.net/#easeInCirc
  64045. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64046. */
  64047. export class CircleEase extends EasingFunction implements IEasingFunction {
  64048. /** @hidden */
  64049. easeInCore(gradient: number): number;
  64050. }
  64051. /**
  64052. * Easing function with a ease back shape (see link below).
  64053. * @see https://easings.net/#easeInBack
  64054. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64055. */
  64056. export class BackEase extends EasingFunction implements IEasingFunction {
  64057. /** Defines the amplitude of the function */
  64058. amplitude: number;
  64059. /**
  64060. * Instantiates a back ease easing
  64061. * @see https://easings.net/#easeInBack
  64062. * @param amplitude Defines the amplitude of the function
  64063. */
  64064. constructor(
  64065. /** Defines the amplitude of the function */
  64066. amplitude?: number);
  64067. /** @hidden */
  64068. easeInCore(gradient: number): number;
  64069. }
  64070. /**
  64071. * Easing function with a bouncing shape (see link below).
  64072. * @see https://easings.net/#easeInBounce
  64073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64074. */
  64075. export class BounceEase extends EasingFunction implements IEasingFunction {
  64076. /** Defines the number of bounces */
  64077. bounces: number;
  64078. /** Defines the amplitude of the bounce */
  64079. bounciness: number;
  64080. /**
  64081. * Instantiates a bounce easing
  64082. * @see https://easings.net/#easeInBounce
  64083. * @param bounces Defines the number of bounces
  64084. * @param bounciness Defines the amplitude of the bounce
  64085. */
  64086. constructor(
  64087. /** Defines the number of bounces */
  64088. bounces?: number,
  64089. /** Defines the amplitude of the bounce */
  64090. bounciness?: number);
  64091. /** @hidden */
  64092. easeInCore(gradient: number): number;
  64093. }
  64094. /**
  64095. * Easing function with a power of 3 shape (see link below).
  64096. * @see https://easings.net/#easeInCubic
  64097. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64098. */
  64099. export class CubicEase extends EasingFunction implements IEasingFunction {
  64100. /** @hidden */
  64101. easeInCore(gradient: number): number;
  64102. }
  64103. /**
  64104. * Easing function with an elastic shape (see link below).
  64105. * @see https://easings.net/#easeInElastic
  64106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64107. */
  64108. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64109. /** Defines the number of oscillations*/
  64110. oscillations: number;
  64111. /** Defines the amplitude of the oscillations*/
  64112. springiness: number;
  64113. /**
  64114. * Instantiates an elastic easing function
  64115. * @see https://easings.net/#easeInElastic
  64116. * @param oscillations Defines the number of oscillations
  64117. * @param springiness Defines the amplitude of the oscillations
  64118. */
  64119. constructor(
  64120. /** Defines the number of oscillations*/
  64121. oscillations?: number,
  64122. /** Defines the amplitude of the oscillations*/
  64123. springiness?: number);
  64124. /** @hidden */
  64125. easeInCore(gradient: number): number;
  64126. }
  64127. /**
  64128. * Easing function with an exponential shape (see link below).
  64129. * @see https://easings.net/#easeInExpo
  64130. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64131. */
  64132. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64133. /** Defines the exponent of the function */
  64134. exponent: number;
  64135. /**
  64136. * Instantiates an exponential easing function
  64137. * @see https://easings.net/#easeInExpo
  64138. * @param exponent Defines the exponent of the function
  64139. */
  64140. constructor(
  64141. /** Defines the exponent of the function */
  64142. exponent?: number);
  64143. /** @hidden */
  64144. easeInCore(gradient: number): number;
  64145. }
  64146. /**
  64147. * Easing function with a power shape (see link below).
  64148. * @see https://easings.net/#easeInQuad
  64149. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64150. */
  64151. export class PowerEase extends EasingFunction implements IEasingFunction {
  64152. /** Defines the power of the function */
  64153. power: number;
  64154. /**
  64155. * Instantiates an power base easing function
  64156. * @see https://easings.net/#easeInQuad
  64157. * @param power Defines the power of the function
  64158. */
  64159. constructor(
  64160. /** Defines the power of the function */
  64161. power?: number);
  64162. /** @hidden */
  64163. easeInCore(gradient: number): number;
  64164. }
  64165. /**
  64166. * Easing function with a power of 2 shape (see link below).
  64167. * @see https://easings.net/#easeInQuad
  64168. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64169. */
  64170. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64171. /** @hidden */
  64172. easeInCore(gradient: number): number;
  64173. }
  64174. /**
  64175. * Easing function with a power of 4 shape (see link below).
  64176. * @see https://easings.net/#easeInQuart
  64177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64178. */
  64179. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64180. /** @hidden */
  64181. easeInCore(gradient: number): number;
  64182. }
  64183. /**
  64184. * Easing function with a power of 5 shape (see link below).
  64185. * @see https://easings.net/#easeInQuint
  64186. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64187. */
  64188. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64189. /** @hidden */
  64190. easeInCore(gradient: number): number;
  64191. }
  64192. /**
  64193. * Easing function with a sin shape (see link below).
  64194. * @see https://easings.net/#easeInSine
  64195. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64196. */
  64197. export class SineEase extends EasingFunction implements IEasingFunction {
  64198. /** @hidden */
  64199. easeInCore(gradient: number): number;
  64200. }
  64201. /**
  64202. * Easing function with a bezier shape (see link below).
  64203. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64205. */
  64206. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  64207. /** Defines the x component of the start tangent in the bezier curve */
  64208. x1: number;
  64209. /** Defines the y component of the start tangent in the bezier curve */
  64210. y1: number;
  64211. /** Defines the x component of the end tangent in the bezier curve */
  64212. x2: number;
  64213. /** Defines the y component of the end tangent in the bezier curve */
  64214. y2: number;
  64215. /**
  64216. * Instantiates a bezier function
  64217. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64218. * @param x1 Defines the x component of the start tangent in the bezier curve
  64219. * @param y1 Defines the y component of the start tangent in the bezier curve
  64220. * @param x2 Defines the x component of the end tangent in the bezier curve
  64221. * @param y2 Defines the y component of the end tangent in the bezier curve
  64222. */
  64223. constructor(
  64224. /** Defines the x component of the start tangent in the bezier curve */
  64225. x1?: number,
  64226. /** Defines the y component of the start tangent in the bezier curve */
  64227. y1?: number,
  64228. /** Defines the x component of the end tangent in the bezier curve */
  64229. x2?: number,
  64230. /** Defines the y component of the end tangent in the bezier curve */
  64231. y2?: number);
  64232. /** @hidden */
  64233. easeInCore(gradient: number): number;
  64234. }
  64235. }
  64236. declare module BABYLON {
  64237. /**
  64238. * Defines an interface which represents an animation key frame
  64239. */
  64240. export interface IAnimationKey {
  64241. /**
  64242. * Frame of the key frame
  64243. */
  64244. frame: number;
  64245. /**
  64246. * Value at the specifies key frame
  64247. */
  64248. value: any;
  64249. /**
  64250. * The input tangent for the cubic hermite spline
  64251. */
  64252. inTangent?: any;
  64253. /**
  64254. * The output tangent for the cubic hermite spline
  64255. */
  64256. outTangent?: any;
  64257. /**
  64258. * The animation interpolation type
  64259. */
  64260. interpolation?: AnimationKeyInterpolation;
  64261. }
  64262. /**
  64263. * Enum for the animation key frame interpolation type
  64264. */
  64265. export enum AnimationKeyInterpolation {
  64266. /**
  64267. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64268. */
  64269. STEP = 1
  64270. }
  64271. }
  64272. declare module BABYLON {
  64273. /**
  64274. * Represents the range of an animation
  64275. */
  64276. export class AnimationRange {
  64277. /**The name of the animation range**/
  64278. name: string;
  64279. /**The starting frame of the animation */
  64280. from: number;
  64281. /**The ending frame of the animation*/
  64282. to: number;
  64283. /**
  64284. * Initializes the range of an animation
  64285. * @param name The name of the animation range
  64286. * @param from The starting frame of the animation
  64287. * @param to The ending frame of the animation
  64288. */
  64289. constructor(
  64290. /**The name of the animation range**/
  64291. name: string,
  64292. /**The starting frame of the animation */
  64293. from: number,
  64294. /**The ending frame of the animation*/
  64295. to: number);
  64296. /**
  64297. * Makes a copy of the animation range
  64298. * @returns A copy of the animation range
  64299. */
  64300. clone(): AnimationRange;
  64301. }
  64302. }
  64303. declare module BABYLON {
  64304. /**
  64305. * Composed of a frame, and an action function
  64306. */
  64307. export class AnimationEvent {
  64308. /** The frame for which the event is triggered **/
  64309. frame: number;
  64310. /** The event to perform when triggered **/
  64311. action: (currentFrame: number) => void;
  64312. /** Specifies if the event should be triggered only once**/
  64313. onlyOnce?: boolean | undefined;
  64314. /**
  64315. * Specifies if the animation event is done
  64316. */
  64317. isDone: boolean;
  64318. /**
  64319. * Initializes the animation event
  64320. * @param frame The frame for which the event is triggered
  64321. * @param action The event to perform when triggered
  64322. * @param onlyOnce Specifies if the event should be triggered only once
  64323. */
  64324. constructor(
  64325. /** The frame for which the event is triggered **/
  64326. frame: number,
  64327. /** The event to perform when triggered **/
  64328. action: (currentFrame: number) => void,
  64329. /** Specifies if the event should be triggered only once**/
  64330. onlyOnce?: boolean | undefined);
  64331. /** @hidden */
  64332. _clone(): AnimationEvent;
  64333. }
  64334. }
  64335. declare module BABYLON {
  64336. /**
  64337. * Interface used to define a behavior
  64338. */
  64339. export interface Behavior<T> {
  64340. /** gets or sets behavior's name */
  64341. name: string;
  64342. /**
  64343. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64344. */
  64345. init(): void;
  64346. /**
  64347. * Called when the behavior is attached to a target
  64348. * @param target defines the target where the behavior is attached to
  64349. */
  64350. attach(target: T): void;
  64351. /**
  64352. * Called when the behavior is detached from its target
  64353. */
  64354. detach(): void;
  64355. }
  64356. /**
  64357. * Interface implemented by classes supporting behaviors
  64358. */
  64359. export interface IBehaviorAware<T> {
  64360. /**
  64361. * Attach a behavior
  64362. * @param behavior defines the behavior to attach
  64363. * @returns the current host
  64364. */
  64365. addBehavior(behavior: Behavior<T>): T;
  64366. /**
  64367. * Remove a behavior from the current object
  64368. * @param behavior defines the behavior to detach
  64369. * @returns the current host
  64370. */
  64371. removeBehavior(behavior: Behavior<T>): T;
  64372. /**
  64373. * Gets a behavior using its name to search
  64374. * @param name defines the name to search
  64375. * @returns the behavior or null if not found
  64376. */
  64377. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64378. }
  64379. }
  64380. declare module BABYLON {
  64381. /**
  64382. * @hidden
  64383. */
  64384. export class IntersectionInfo {
  64385. bu: Nullable<number>;
  64386. bv: Nullable<number>;
  64387. distance: number;
  64388. faceId: number;
  64389. subMeshId: number;
  64390. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64391. }
  64392. }
  64393. declare module BABYLON {
  64394. /**
  64395. * Class used to store bounding sphere information
  64396. */
  64397. export class BoundingSphere {
  64398. /**
  64399. * Gets the center of the bounding sphere in local space
  64400. */
  64401. readonly center: Vector3;
  64402. /**
  64403. * Radius of the bounding sphere in local space
  64404. */
  64405. radius: number;
  64406. /**
  64407. * Gets the center of the bounding sphere in world space
  64408. */
  64409. readonly centerWorld: Vector3;
  64410. /**
  64411. * Radius of the bounding sphere in world space
  64412. */
  64413. radiusWorld: number;
  64414. /**
  64415. * Gets the minimum vector in local space
  64416. */
  64417. readonly minimum: Vector3;
  64418. /**
  64419. * Gets the maximum vector in local space
  64420. */
  64421. readonly maximum: Vector3;
  64422. private _worldMatrix;
  64423. private static readonly TmpVector3;
  64424. /**
  64425. * Creates a new bounding sphere
  64426. * @param min defines the minimum vector (in local space)
  64427. * @param max defines the maximum vector (in local space)
  64428. * @param worldMatrix defines the new world matrix
  64429. */
  64430. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64431. /**
  64432. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64433. * @param min defines the new minimum vector (in local space)
  64434. * @param max defines the new maximum vector (in local space)
  64435. * @param worldMatrix defines the new world matrix
  64436. */
  64437. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64438. /**
  64439. * Scale the current bounding sphere by applying a scale factor
  64440. * @param factor defines the scale factor to apply
  64441. * @returns the current bounding box
  64442. */
  64443. scale(factor: number): BoundingSphere;
  64444. /**
  64445. * Gets the world matrix of the bounding box
  64446. * @returns a matrix
  64447. */
  64448. getWorldMatrix(): DeepImmutable<Matrix>;
  64449. /** @hidden */
  64450. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64451. /**
  64452. * Tests if the bounding sphere is intersecting the frustum planes
  64453. * @param frustumPlanes defines the frustum planes to test
  64454. * @returns true if there is an intersection
  64455. */
  64456. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64457. /**
  64458. * Tests if the bounding sphere center is in between the frustum planes.
  64459. * Used for optimistic fast inclusion.
  64460. * @param frustumPlanes defines the frustum planes to test
  64461. * @returns true if the sphere center is in between the frustum planes
  64462. */
  64463. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64464. /**
  64465. * Tests if a point is inside the bounding sphere
  64466. * @param point defines the point to test
  64467. * @returns true if the point is inside the bounding sphere
  64468. */
  64469. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64470. /**
  64471. * Checks if two sphere intersct
  64472. * @param sphere0 sphere 0
  64473. * @param sphere1 sphere 1
  64474. * @returns true if the speres intersect
  64475. */
  64476. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64477. }
  64478. }
  64479. declare module BABYLON {
  64480. /**
  64481. * Class used to store bounding box information
  64482. */
  64483. export class BoundingBox implements ICullable {
  64484. /**
  64485. * Gets the 8 vectors representing the bounding box in local space
  64486. */
  64487. readonly vectors: Vector3[];
  64488. /**
  64489. * Gets the center of the bounding box in local space
  64490. */
  64491. readonly center: Vector3;
  64492. /**
  64493. * Gets the center of the bounding box in world space
  64494. */
  64495. readonly centerWorld: Vector3;
  64496. /**
  64497. * Gets the extend size in local space
  64498. */
  64499. readonly extendSize: Vector3;
  64500. /**
  64501. * Gets the extend size in world space
  64502. */
  64503. readonly extendSizeWorld: Vector3;
  64504. /**
  64505. * Gets the OBB (object bounding box) directions
  64506. */
  64507. readonly directions: Vector3[];
  64508. /**
  64509. * Gets the 8 vectors representing the bounding box in world space
  64510. */
  64511. readonly vectorsWorld: Vector3[];
  64512. /**
  64513. * Gets the minimum vector in world space
  64514. */
  64515. readonly minimumWorld: Vector3;
  64516. /**
  64517. * Gets the maximum vector in world space
  64518. */
  64519. readonly maximumWorld: Vector3;
  64520. /**
  64521. * Gets the minimum vector in local space
  64522. */
  64523. readonly minimum: Vector3;
  64524. /**
  64525. * Gets the maximum vector in local space
  64526. */
  64527. readonly maximum: Vector3;
  64528. private _worldMatrix;
  64529. private static readonly TmpVector3;
  64530. /**
  64531. * @hidden
  64532. */
  64533. _tag: number;
  64534. /**
  64535. * Creates a new bounding box
  64536. * @param min defines the minimum vector (in local space)
  64537. * @param max defines the maximum vector (in local space)
  64538. * @param worldMatrix defines the new world matrix
  64539. */
  64540. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64541. /**
  64542. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64543. * @param min defines the new minimum vector (in local space)
  64544. * @param max defines the new maximum vector (in local space)
  64545. * @param worldMatrix defines the new world matrix
  64546. */
  64547. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64548. /**
  64549. * Scale the current bounding box by applying a scale factor
  64550. * @param factor defines the scale factor to apply
  64551. * @returns the current bounding box
  64552. */
  64553. scale(factor: number): BoundingBox;
  64554. /**
  64555. * Gets the world matrix of the bounding box
  64556. * @returns a matrix
  64557. */
  64558. getWorldMatrix(): DeepImmutable<Matrix>;
  64559. /** @hidden */
  64560. _update(world: DeepImmutable<Matrix>): void;
  64561. /**
  64562. * Tests if the bounding box is intersecting the frustum planes
  64563. * @param frustumPlanes defines the frustum planes to test
  64564. * @returns true if there is an intersection
  64565. */
  64566. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64567. /**
  64568. * Tests if the bounding box is entirely inside the frustum planes
  64569. * @param frustumPlanes defines the frustum planes to test
  64570. * @returns true if there is an inclusion
  64571. */
  64572. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64573. /**
  64574. * Tests if a point is inside the bounding box
  64575. * @param point defines the point to test
  64576. * @returns true if the point is inside the bounding box
  64577. */
  64578. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64579. /**
  64580. * Tests if the bounding box intersects with a bounding sphere
  64581. * @param sphere defines the sphere to test
  64582. * @returns true if there is an intersection
  64583. */
  64584. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64585. /**
  64586. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64587. * @param min defines the min vector to use
  64588. * @param max defines the max vector to use
  64589. * @returns true if there is an intersection
  64590. */
  64591. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64592. /**
  64593. * Tests if two bounding boxes are intersections
  64594. * @param box0 defines the first box to test
  64595. * @param box1 defines the second box to test
  64596. * @returns true if there is an intersection
  64597. */
  64598. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64599. /**
  64600. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64601. * @param minPoint defines the minimum vector of the bounding box
  64602. * @param maxPoint defines the maximum vector of the bounding box
  64603. * @param sphereCenter defines the sphere center
  64604. * @param sphereRadius defines the sphere radius
  64605. * @returns true if there is an intersection
  64606. */
  64607. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64608. /**
  64609. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64610. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64611. * @param frustumPlanes defines the frustum planes to test
  64612. * @return true if there is an inclusion
  64613. */
  64614. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64615. /**
  64616. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64617. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64618. * @param frustumPlanes defines the frustum planes to test
  64619. * @return true if there is an intersection
  64620. */
  64621. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64622. }
  64623. }
  64624. declare module BABYLON {
  64625. /** @hidden */
  64626. export class Collider {
  64627. /** Define if a collision was found */
  64628. collisionFound: boolean;
  64629. /**
  64630. * Define last intersection point in local space
  64631. */
  64632. intersectionPoint: Vector3;
  64633. /**
  64634. * Define last collided mesh
  64635. */
  64636. collidedMesh: Nullable<AbstractMesh>;
  64637. private _collisionPoint;
  64638. private _planeIntersectionPoint;
  64639. private _tempVector;
  64640. private _tempVector2;
  64641. private _tempVector3;
  64642. private _tempVector4;
  64643. private _edge;
  64644. private _baseToVertex;
  64645. private _destinationPoint;
  64646. private _slidePlaneNormal;
  64647. private _displacementVector;
  64648. /** @hidden */
  64649. _radius: Vector3;
  64650. /** @hidden */
  64651. _retry: number;
  64652. private _velocity;
  64653. private _basePoint;
  64654. private _epsilon;
  64655. /** @hidden */
  64656. _velocityWorldLength: number;
  64657. /** @hidden */
  64658. _basePointWorld: Vector3;
  64659. private _velocityWorld;
  64660. private _normalizedVelocity;
  64661. /** @hidden */
  64662. _initialVelocity: Vector3;
  64663. /** @hidden */
  64664. _initialPosition: Vector3;
  64665. private _nearestDistance;
  64666. private _collisionMask;
  64667. collisionMask: number;
  64668. /**
  64669. * Gets the plane normal used to compute the sliding response (in local space)
  64670. */
  64671. readonly slidePlaneNormal: Vector3;
  64672. /** @hidden */
  64673. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64674. /** @hidden */
  64675. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64676. /** @hidden */
  64677. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64678. /** @hidden */
  64679. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64680. /** @hidden */
  64681. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64682. /** @hidden */
  64683. _getResponse(pos: Vector3, vel: Vector3): void;
  64684. }
  64685. }
  64686. declare module BABYLON {
  64687. /**
  64688. * Interface for cullable objects
  64689. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64690. */
  64691. export interface ICullable {
  64692. /**
  64693. * Checks if the object or part of the object is in the frustum
  64694. * @param frustumPlanes Camera near/planes
  64695. * @returns true if the object is in frustum otherwise false
  64696. */
  64697. isInFrustum(frustumPlanes: Plane[]): boolean;
  64698. /**
  64699. * Checks if a cullable object (mesh...) is in the camera frustum
  64700. * Unlike isInFrustum this cheks the full bounding box
  64701. * @param frustumPlanes Camera near/planes
  64702. * @returns true if the object is in frustum otherwise false
  64703. */
  64704. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64705. }
  64706. /**
  64707. * Info for a bounding data of a mesh
  64708. */
  64709. export class BoundingInfo implements ICullable {
  64710. /**
  64711. * Bounding box for the mesh
  64712. */
  64713. readonly boundingBox: BoundingBox;
  64714. /**
  64715. * Bounding sphere for the mesh
  64716. */
  64717. readonly boundingSphere: BoundingSphere;
  64718. private _isLocked;
  64719. private static readonly TmpVector3;
  64720. /**
  64721. * Constructs bounding info
  64722. * @param minimum min vector of the bounding box/sphere
  64723. * @param maximum max vector of the bounding box/sphere
  64724. * @param worldMatrix defines the new world matrix
  64725. */
  64726. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64727. /**
  64728. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64729. * @param min defines the new minimum vector (in local space)
  64730. * @param max defines the new maximum vector (in local space)
  64731. * @param worldMatrix defines the new world matrix
  64732. */
  64733. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64734. /**
  64735. * min vector of the bounding box/sphere
  64736. */
  64737. readonly minimum: Vector3;
  64738. /**
  64739. * max vector of the bounding box/sphere
  64740. */
  64741. readonly maximum: Vector3;
  64742. /**
  64743. * If the info is locked and won't be updated to avoid perf overhead
  64744. */
  64745. isLocked: boolean;
  64746. /**
  64747. * Updates the bounding sphere and box
  64748. * @param world world matrix to be used to update
  64749. */
  64750. update(world: DeepImmutable<Matrix>): void;
  64751. /**
  64752. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64753. * @param center New center of the bounding info
  64754. * @param extend New extend of the bounding info
  64755. * @returns the current bounding info
  64756. */
  64757. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64758. /**
  64759. * Scale the current bounding info by applying a scale factor
  64760. * @param factor defines the scale factor to apply
  64761. * @returns the current bounding info
  64762. */
  64763. scale(factor: number): BoundingInfo;
  64764. /**
  64765. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64766. * @param frustumPlanes defines the frustum to test
  64767. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64768. * @returns true if the bounding info is in the frustum planes
  64769. */
  64770. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64771. /**
  64772. * Gets the world distance between the min and max points of the bounding box
  64773. */
  64774. readonly diagonalLength: number;
  64775. /**
  64776. * Checks if a cullable object (mesh...) is in the camera frustum
  64777. * Unlike isInFrustum this cheks the full bounding box
  64778. * @param frustumPlanes Camera near/planes
  64779. * @returns true if the object is in frustum otherwise false
  64780. */
  64781. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64782. /** @hidden */
  64783. _checkCollision(collider: Collider): boolean;
  64784. /**
  64785. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64786. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64787. * @param point the point to check intersection with
  64788. * @returns if the point intersects
  64789. */
  64790. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64791. /**
  64792. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64793. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64794. * @param boundingInfo the bounding info to check intersection with
  64795. * @param precise if the intersection should be done using OBB
  64796. * @returns if the bounding info intersects
  64797. */
  64798. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64799. }
  64800. }
  64801. declare module BABYLON {
  64802. /**
  64803. * Defines an array and its length.
  64804. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64805. */
  64806. export interface ISmartArrayLike<T> {
  64807. /**
  64808. * The data of the array.
  64809. */
  64810. data: Array<T>;
  64811. /**
  64812. * The active length of the array.
  64813. */
  64814. length: number;
  64815. }
  64816. /**
  64817. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64818. */
  64819. export class SmartArray<T> implements ISmartArrayLike<T> {
  64820. /**
  64821. * The full set of data from the array.
  64822. */
  64823. data: Array<T>;
  64824. /**
  64825. * The active length of the array.
  64826. */
  64827. length: number;
  64828. protected _id: number;
  64829. /**
  64830. * Instantiates a Smart Array.
  64831. * @param capacity defines the default capacity of the array.
  64832. */
  64833. constructor(capacity: number);
  64834. /**
  64835. * Pushes a value at the end of the active data.
  64836. * @param value defines the object to push in the array.
  64837. */
  64838. push(value: T): void;
  64839. /**
  64840. * Iterates over the active data and apply the lambda to them.
  64841. * @param func defines the action to apply on each value.
  64842. */
  64843. forEach(func: (content: T) => void): void;
  64844. /**
  64845. * Sorts the full sets of data.
  64846. * @param compareFn defines the comparison function to apply.
  64847. */
  64848. sort(compareFn: (a: T, b: T) => number): void;
  64849. /**
  64850. * Resets the active data to an empty array.
  64851. */
  64852. reset(): void;
  64853. /**
  64854. * Releases all the data from the array as well as the array.
  64855. */
  64856. dispose(): void;
  64857. /**
  64858. * Concats the active data with a given array.
  64859. * @param array defines the data to concatenate with.
  64860. */
  64861. concat(array: any): void;
  64862. /**
  64863. * Returns the position of a value in the active data.
  64864. * @param value defines the value to find the index for
  64865. * @returns the index if found in the active data otherwise -1
  64866. */
  64867. indexOf(value: T): number;
  64868. /**
  64869. * Returns whether an element is part of the active data.
  64870. * @param value defines the value to look for
  64871. * @returns true if found in the active data otherwise false
  64872. */
  64873. contains(value: T): boolean;
  64874. private static _GlobalId;
  64875. }
  64876. /**
  64877. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64878. * The data in this array can only be present once
  64879. */
  64880. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64881. private _duplicateId;
  64882. /**
  64883. * Pushes a value at the end of the active data.
  64884. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64885. * @param value defines the object to push in the array.
  64886. */
  64887. push(value: T): void;
  64888. /**
  64889. * Pushes a value at the end of the active data.
  64890. * If the data is already present, it won t be added again
  64891. * @param value defines the object to push in the array.
  64892. * @returns true if added false if it was already present
  64893. */
  64894. pushNoDuplicate(value: T): boolean;
  64895. /**
  64896. * Resets the active data to an empty array.
  64897. */
  64898. reset(): void;
  64899. /**
  64900. * Concats the active data with a given array.
  64901. * This ensures no dupplicate will be present in the result.
  64902. * @param array defines the data to concatenate with.
  64903. */
  64904. concatWithNoDuplicate(array: any): void;
  64905. }
  64906. }
  64907. declare module BABYLON {
  64908. /**
  64909. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64910. * separate meshes. This can be use to improve performances.
  64911. * @see http://doc.babylonjs.com/how_to/multi_materials
  64912. */
  64913. export class MultiMaterial extends Material {
  64914. private _subMaterials;
  64915. /**
  64916. * Gets or Sets the list of Materials used within the multi material.
  64917. * They need to be ordered according to the submeshes order in the associated mesh
  64918. */
  64919. subMaterials: Nullable<Material>[];
  64920. /**
  64921. * Function used to align with Node.getChildren()
  64922. * @returns the list of Materials used within the multi material
  64923. */
  64924. getChildren(): Nullable<Material>[];
  64925. /**
  64926. * Instantiates a new Multi Material
  64927. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64928. * separate meshes. This can be use to improve performances.
  64929. * @see http://doc.babylonjs.com/how_to/multi_materials
  64930. * @param name Define the name in the scene
  64931. * @param scene Define the scene the material belongs to
  64932. */
  64933. constructor(name: string, scene: Scene);
  64934. private _hookArray;
  64935. /**
  64936. * Get one of the submaterial by its index in the submaterials array
  64937. * @param index The index to look the sub material at
  64938. * @returns The Material if the index has been defined
  64939. */
  64940. getSubMaterial(index: number): Nullable<Material>;
  64941. /**
  64942. * Get the list of active textures for the whole sub materials list.
  64943. * @returns All the textures that will be used during the rendering
  64944. */
  64945. getActiveTextures(): BaseTexture[];
  64946. /**
  64947. * Gets the current class name of the material e.g. "MultiMaterial"
  64948. * Mainly use in serialization.
  64949. * @returns the class name
  64950. */
  64951. getClassName(): string;
  64952. /**
  64953. * Checks if the material is ready to render the requested sub mesh
  64954. * @param mesh Define the mesh the submesh belongs to
  64955. * @param subMesh Define the sub mesh to look readyness for
  64956. * @param useInstances Define whether or not the material is used with instances
  64957. * @returns true if ready, otherwise false
  64958. */
  64959. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64960. /**
  64961. * Clones the current material and its related sub materials
  64962. * @param name Define the name of the newly cloned material
  64963. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64964. * @returns the cloned material
  64965. */
  64966. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64967. /**
  64968. * Serializes the materials into a JSON representation.
  64969. * @returns the JSON representation
  64970. */
  64971. serialize(): any;
  64972. /**
  64973. * Dispose the material and release its associated resources
  64974. * @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)
  64975. * @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)
  64976. * @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)
  64977. */
  64978. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64979. /**
  64980. * Creates a MultiMaterial from parsed MultiMaterial data.
  64981. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64982. * @param scene defines the hosting scene
  64983. * @returns a new MultiMaterial
  64984. */
  64985. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64986. }
  64987. }
  64988. declare module BABYLON {
  64989. /**
  64990. * Class used to represent data loading progression
  64991. */
  64992. export class SceneLoaderFlags {
  64993. private static _ForceFullSceneLoadingForIncremental;
  64994. private static _ShowLoadingScreen;
  64995. private static _CleanBoneMatrixWeights;
  64996. private static _loggingLevel;
  64997. /**
  64998. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64999. */
  65000. static ForceFullSceneLoadingForIncremental: boolean;
  65001. /**
  65002. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65003. */
  65004. static ShowLoadingScreen: boolean;
  65005. /**
  65006. * Defines the current logging level (while loading the scene)
  65007. * @ignorenaming
  65008. */
  65009. static loggingLevel: number;
  65010. /**
  65011. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65012. */
  65013. static CleanBoneMatrixWeights: boolean;
  65014. }
  65015. }
  65016. declare module BABYLON {
  65017. /**
  65018. * 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.
  65019. * @see https://doc.babylonjs.com/how_to/transformnode
  65020. */
  65021. export class TransformNode extends Node {
  65022. /**
  65023. * Object will not rotate to face the camera
  65024. */
  65025. static BILLBOARDMODE_NONE: number;
  65026. /**
  65027. * Object will rotate to face the camera but only on the x axis
  65028. */
  65029. static BILLBOARDMODE_X: number;
  65030. /**
  65031. * Object will rotate to face the camera but only on the y axis
  65032. */
  65033. static BILLBOARDMODE_Y: number;
  65034. /**
  65035. * Object will rotate to face the camera but only on the z axis
  65036. */
  65037. static BILLBOARDMODE_Z: number;
  65038. /**
  65039. * Object will rotate to face the camera
  65040. */
  65041. static BILLBOARDMODE_ALL: number;
  65042. private _forward;
  65043. private _forwardInverted;
  65044. private _up;
  65045. private _right;
  65046. private _rightInverted;
  65047. private _position;
  65048. private _rotation;
  65049. private _rotationQuaternion;
  65050. protected _scaling: Vector3;
  65051. protected _isDirty: boolean;
  65052. private _transformToBoneReferal;
  65053. /**
  65054. * Set the billboard mode. Default is 0.
  65055. *
  65056. * | Value | Type | Description |
  65057. * | --- | --- | --- |
  65058. * | 0 | BILLBOARDMODE_NONE | |
  65059. * | 1 | BILLBOARDMODE_X | |
  65060. * | 2 | BILLBOARDMODE_Y | |
  65061. * | 4 | BILLBOARDMODE_Z | |
  65062. * | 7 | BILLBOARDMODE_ALL | |
  65063. *
  65064. */
  65065. billboardMode: number;
  65066. /**
  65067. * 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
  65068. */
  65069. scalingDeterminant: number;
  65070. /**
  65071. * Sets the distance of the object to max, often used by skybox
  65072. */
  65073. infiniteDistance: boolean;
  65074. /**
  65075. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65076. * By default the system will update normals to compensate
  65077. */
  65078. ignoreNonUniformScaling: boolean;
  65079. /** @hidden */
  65080. _poseMatrix: Matrix;
  65081. /** @hidden */
  65082. _localMatrix: Matrix;
  65083. private _absolutePosition;
  65084. private _pivotMatrix;
  65085. private _pivotMatrixInverse;
  65086. protected _postMultiplyPivotMatrix: boolean;
  65087. private _tempMatrix;
  65088. private _tempMatrix2;
  65089. protected _isWorldMatrixFrozen: boolean;
  65090. /** @hidden */
  65091. _indexInSceneTransformNodesArray: number;
  65092. /**
  65093. * An event triggered after the world matrix is updated
  65094. */
  65095. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65096. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65097. /**
  65098. * Gets a string identifying the name of the class
  65099. * @returns "TransformNode" string
  65100. */
  65101. getClassName(): string;
  65102. /**
  65103. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65104. */
  65105. position: Vector3;
  65106. /**
  65107. * 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)).
  65108. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65109. */
  65110. rotation: Vector3;
  65111. /**
  65112. * 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)).
  65113. */
  65114. scaling: Vector3;
  65115. /**
  65116. * 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).
  65117. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65118. */
  65119. rotationQuaternion: Nullable<Quaternion>;
  65120. /**
  65121. * The forward direction of that transform in world space.
  65122. */
  65123. readonly forward: Vector3;
  65124. /**
  65125. * The up direction of that transform in world space.
  65126. */
  65127. readonly up: Vector3;
  65128. /**
  65129. * The right direction of that transform in world space.
  65130. */
  65131. readonly right: Vector3;
  65132. /**
  65133. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65134. * @param matrix the matrix to copy the pose from
  65135. * @returns this TransformNode.
  65136. */
  65137. updatePoseMatrix(matrix: Matrix): TransformNode;
  65138. /**
  65139. * Returns the mesh Pose matrix.
  65140. * @returns the pose matrix
  65141. */
  65142. getPoseMatrix(): Matrix;
  65143. /** @hidden */
  65144. _isSynchronized(): boolean;
  65145. /** @hidden */
  65146. _initCache(): void;
  65147. /**
  65148. * Flag the transform node as dirty (Forcing it to update everything)
  65149. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65150. * @returns this transform node
  65151. */
  65152. markAsDirty(property: string): TransformNode;
  65153. /**
  65154. * Returns the current mesh absolute position.
  65155. * Returns a Vector3.
  65156. */
  65157. readonly absolutePosition: Vector3;
  65158. /**
  65159. * Sets a new matrix to apply before all other transformation
  65160. * @param matrix defines the transform matrix
  65161. * @returns the current TransformNode
  65162. */
  65163. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65164. /**
  65165. * Sets a new pivot matrix to the current node
  65166. * @param matrix defines the new pivot matrix to use
  65167. * @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
  65168. * @returns the current TransformNode
  65169. */
  65170. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65171. /**
  65172. * Returns the mesh pivot matrix.
  65173. * Default : Identity.
  65174. * @returns the matrix
  65175. */
  65176. getPivotMatrix(): Matrix;
  65177. /**
  65178. * Prevents the World matrix to be computed any longer.
  65179. * @returns the TransformNode.
  65180. */
  65181. freezeWorldMatrix(): TransformNode;
  65182. /**
  65183. * Allows back the World matrix computation.
  65184. * @returns the TransformNode.
  65185. */
  65186. unfreezeWorldMatrix(): this;
  65187. /**
  65188. * True if the World matrix has been frozen.
  65189. */
  65190. readonly isWorldMatrixFrozen: boolean;
  65191. /**
  65192. * Retuns the mesh absolute position in the World.
  65193. * @returns a Vector3.
  65194. */
  65195. getAbsolutePosition(): Vector3;
  65196. /**
  65197. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65198. * @param absolutePosition the absolute position to set
  65199. * @returns the TransformNode.
  65200. */
  65201. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65202. /**
  65203. * Sets the mesh position in its local space.
  65204. * @param vector3 the position to set in localspace
  65205. * @returns the TransformNode.
  65206. */
  65207. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65208. /**
  65209. * Returns the mesh position in the local space from the current World matrix values.
  65210. * @returns a new Vector3.
  65211. */
  65212. getPositionExpressedInLocalSpace(): Vector3;
  65213. /**
  65214. * Translates the mesh along the passed Vector3 in its local space.
  65215. * @param vector3 the distance to translate in localspace
  65216. * @returns the TransformNode.
  65217. */
  65218. locallyTranslate(vector3: Vector3): TransformNode;
  65219. private static _lookAtVectorCache;
  65220. /**
  65221. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65222. * @param targetPoint the position (must be in same space as current mesh) to look at
  65223. * @param yawCor optional yaw (y-axis) correction in radians
  65224. * @param pitchCor optional pitch (x-axis) correction in radians
  65225. * @param rollCor optional roll (z-axis) correction in radians
  65226. * @param space the choosen space of the target
  65227. * @returns the TransformNode.
  65228. */
  65229. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65230. /**
  65231. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65232. * This Vector3 is expressed in the World space.
  65233. * @param localAxis axis to rotate
  65234. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65235. */
  65236. getDirection(localAxis: Vector3): Vector3;
  65237. /**
  65238. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65239. * localAxis is expressed in the mesh local space.
  65240. * result is computed in the Wordl space from the mesh World matrix.
  65241. * @param localAxis axis to rotate
  65242. * @param result the resulting transformnode
  65243. * @returns this TransformNode.
  65244. */
  65245. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65246. /**
  65247. * Sets this transform node rotation to the given local axis.
  65248. * @param localAxis the axis in local space
  65249. * @param yawCor optional yaw (y-axis) correction in radians
  65250. * @param pitchCor optional pitch (x-axis) correction in radians
  65251. * @param rollCor optional roll (z-axis) correction in radians
  65252. * @returns this TransformNode
  65253. */
  65254. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65255. /**
  65256. * Sets a new pivot point to the current node
  65257. * @param point defines the new pivot point to use
  65258. * @param space defines if the point is in world or local space (local by default)
  65259. * @returns the current TransformNode
  65260. */
  65261. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65262. /**
  65263. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65264. * @returns the pivot point
  65265. */
  65266. getPivotPoint(): Vector3;
  65267. /**
  65268. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65269. * @param result the vector3 to store the result
  65270. * @returns this TransformNode.
  65271. */
  65272. getPivotPointToRef(result: Vector3): TransformNode;
  65273. /**
  65274. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65275. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65276. */
  65277. getAbsolutePivotPoint(): Vector3;
  65278. /**
  65279. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65280. * @param result vector3 to store the result
  65281. * @returns this TransformNode.
  65282. */
  65283. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65284. /**
  65285. * Defines the passed node as the parent of the current node.
  65286. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65287. * @param node the node ot set as the parent
  65288. * @returns this TransformNode.
  65289. */
  65290. setParent(node: Nullable<Node>): TransformNode;
  65291. private _nonUniformScaling;
  65292. /**
  65293. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65294. */
  65295. readonly nonUniformScaling: boolean;
  65296. /** @hidden */
  65297. _updateNonUniformScalingState(value: boolean): boolean;
  65298. /**
  65299. * Attach the current TransformNode to another TransformNode associated with a bone
  65300. * @param bone Bone affecting the TransformNode
  65301. * @param affectedTransformNode TransformNode associated with the bone
  65302. * @returns this object
  65303. */
  65304. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65305. /**
  65306. * Detach the transform node if its associated with a bone
  65307. * @returns this object
  65308. */
  65309. detachFromBone(): TransformNode;
  65310. private static _rotationAxisCache;
  65311. /**
  65312. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65313. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65314. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65315. * The passed axis is also normalized.
  65316. * @param axis the axis to rotate around
  65317. * @param amount the amount to rotate in radians
  65318. * @param space Space to rotate in (Default: local)
  65319. * @returns the TransformNode.
  65320. */
  65321. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65322. /**
  65323. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65324. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65325. * The passed axis is also normalized. .
  65326. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65327. * @param point the point to rotate around
  65328. * @param axis the axis to rotate around
  65329. * @param amount the amount to rotate in radians
  65330. * @returns the TransformNode
  65331. */
  65332. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65333. /**
  65334. * Translates the mesh along the axis vector for the passed distance in the given space.
  65335. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65336. * @param axis the axis to translate in
  65337. * @param distance the distance to translate
  65338. * @param space Space to rotate in (Default: local)
  65339. * @returns the TransformNode.
  65340. */
  65341. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65342. /**
  65343. * Adds a rotation step to the mesh current rotation.
  65344. * x, y, z are Euler angles expressed in radians.
  65345. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65346. * This means this rotation is made in the mesh local space only.
  65347. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65348. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65349. * ```javascript
  65350. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65351. * ```
  65352. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65353. * 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.
  65354. * @param x Rotation to add
  65355. * @param y Rotation to add
  65356. * @param z Rotation to add
  65357. * @returns the TransformNode.
  65358. */
  65359. addRotation(x: number, y: number, z: number): TransformNode;
  65360. /**
  65361. * Computes the world matrix of the node
  65362. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65363. * @returns the world matrix
  65364. */
  65365. computeWorldMatrix(force?: boolean): Matrix;
  65366. protected _afterComputeWorldMatrix(): void;
  65367. /**
  65368. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65369. * @param func callback function to add
  65370. *
  65371. * @returns the TransformNode.
  65372. */
  65373. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65374. /**
  65375. * Removes a registered callback function.
  65376. * @param func callback function to remove
  65377. * @returns the TransformNode.
  65378. */
  65379. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65380. /**
  65381. * Gets the position of the current mesh in camera space
  65382. * @param camera defines the camera to use
  65383. * @returns a position
  65384. */
  65385. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65386. /**
  65387. * Returns the distance from the mesh to the active camera
  65388. * @param camera defines the camera to use
  65389. * @returns the distance
  65390. */
  65391. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65392. /**
  65393. * Clone the current transform node
  65394. * @param name Name of the new clone
  65395. * @param newParent New parent for the clone
  65396. * @param doNotCloneChildren Do not clone children hierarchy
  65397. * @returns the new transform node
  65398. */
  65399. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65400. /**
  65401. * Serializes the objects information.
  65402. * @param currentSerializationObject defines the object to serialize in
  65403. * @returns the serialized object
  65404. */
  65405. serialize(currentSerializationObject?: any): any;
  65406. /**
  65407. * Returns a new TransformNode object parsed from the source provided.
  65408. * @param parsedTransformNode is the source.
  65409. * @param scene the scne the object belongs to
  65410. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65411. * @returns a new TransformNode object parsed from the source provided.
  65412. */
  65413. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65414. /**
  65415. * Get all child-transformNodes of this node
  65416. * @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
  65417. * @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
  65418. * @returns an array of TransformNode
  65419. */
  65420. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65421. /**
  65422. * Releases resources associated with this transform node.
  65423. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65424. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65425. */
  65426. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65427. }
  65428. }
  65429. declare module BABYLON {
  65430. /**
  65431. * Class used to override all child animations of a given target
  65432. */
  65433. export class AnimationPropertiesOverride {
  65434. /**
  65435. * Gets or sets a value indicating if animation blending must be used
  65436. */
  65437. enableBlending: boolean;
  65438. /**
  65439. * Gets or sets the blending speed to use when enableBlending is true
  65440. */
  65441. blendingSpeed: number;
  65442. /**
  65443. * Gets or sets the default loop mode to use
  65444. */
  65445. loopMode: number;
  65446. }
  65447. }
  65448. declare module BABYLON {
  65449. /**
  65450. * Class used to store bone information
  65451. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65452. */
  65453. export class Bone extends Node {
  65454. /**
  65455. * defines the bone name
  65456. */
  65457. name: string;
  65458. private static _tmpVecs;
  65459. private static _tmpQuat;
  65460. private static _tmpMats;
  65461. /**
  65462. * Gets the list of child bones
  65463. */
  65464. children: Bone[];
  65465. /** Gets the animations associated with this bone */
  65466. animations: Animation[];
  65467. /**
  65468. * Gets or sets bone length
  65469. */
  65470. length: number;
  65471. /**
  65472. * @hidden Internal only
  65473. * Set this value to map this bone to a different index in the transform matrices
  65474. * Set this value to -1 to exclude the bone from the transform matrices
  65475. */
  65476. _index: Nullable<number>;
  65477. private _skeleton;
  65478. private _localMatrix;
  65479. private _restPose;
  65480. private _baseMatrix;
  65481. private _absoluteTransform;
  65482. private _invertedAbsoluteTransform;
  65483. private _parent;
  65484. private _scalingDeterminant;
  65485. private _worldTransform;
  65486. private _localScaling;
  65487. private _localRotation;
  65488. private _localPosition;
  65489. private _needToDecompose;
  65490. private _needToCompose;
  65491. /** @hidden */
  65492. _linkedTransformNode: Nullable<TransformNode>;
  65493. /** @hidden */
  65494. /** @hidden */
  65495. _matrix: Matrix;
  65496. /**
  65497. * Create a new bone
  65498. * @param name defines the bone name
  65499. * @param skeleton defines the parent skeleton
  65500. * @param parentBone defines the parent (can be null if the bone is the root)
  65501. * @param localMatrix defines the local matrix
  65502. * @param restPose defines the rest pose matrix
  65503. * @param baseMatrix defines the base matrix
  65504. * @param index defines index of the bone in the hiearchy
  65505. */
  65506. constructor(
  65507. /**
  65508. * defines the bone name
  65509. */
  65510. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65511. /**
  65512. * Gets the current object class name.
  65513. * @return the class name
  65514. */
  65515. getClassName(): string;
  65516. /**
  65517. * Gets the parent skeleton
  65518. * @returns a skeleton
  65519. */
  65520. getSkeleton(): Skeleton;
  65521. /**
  65522. * Gets parent bone
  65523. * @returns a bone or null if the bone is the root of the bone hierarchy
  65524. */
  65525. getParent(): Nullable<Bone>;
  65526. /**
  65527. * Returns an array containing the root bones
  65528. * @returns an array containing the root bones
  65529. */
  65530. getChildren(): Array<Bone>;
  65531. /**
  65532. * Sets the parent bone
  65533. * @param parent defines the parent (can be null if the bone is the root)
  65534. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65535. */
  65536. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65537. /**
  65538. * Gets the local matrix
  65539. * @returns a matrix
  65540. */
  65541. getLocalMatrix(): Matrix;
  65542. /**
  65543. * Gets the base matrix (initial matrix which remains unchanged)
  65544. * @returns a matrix
  65545. */
  65546. getBaseMatrix(): Matrix;
  65547. /**
  65548. * Gets the rest pose matrix
  65549. * @returns a matrix
  65550. */
  65551. getRestPose(): Matrix;
  65552. /**
  65553. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65554. */
  65555. getWorldMatrix(): Matrix;
  65556. /**
  65557. * Sets the local matrix to rest pose matrix
  65558. */
  65559. returnToRest(): void;
  65560. /**
  65561. * Gets the inverse of the absolute transform matrix.
  65562. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65563. * @returns a matrix
  65564. */
  65565. getInvertedAbsoluteTransform(): Matrix;
  65566. /**
  65567. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65568. * @returns a matrix
  65569. */
  65570. getAbsoluteTransform(): Matrix;
  65571. /**
  65572. * Links with the given transform node.
  65573. * The local matrix of this bone is copied from the transform node every frame.
  65574. * @param transformNode defines the transform node to link to
  65575. */
  65576. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65577. /** Gets or sets current position (in local space) */
  65578. position: Vector3;
  65579. /** Gets or sets current rotation (in local space) */
  65580. rotation: Vector3;
  65581. /** Gets or sets current rotation quaternion (in local space) */
  65582. rotationQuaternion: Quaternion;
  65583. /** Gets or sets current scaling (in local space) */
  65584. scaling: Vector3;
  65585. /**
  65586. * Gets the animation properties override
  65587. */
  65588. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65589. private _decompose;
  65590. private _compose;
  65591. /**
  65592. * Update the base and local matrices
  65593. * @param matrix defines the new base or local matrix
  65594. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65595. * @param updateLocalMatrix defines if the local matrix should be updated
  65596. */
  65597. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65598. /** @hidden */
  65599. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65600. /**
  65601. * Flag the bone as dirty (Forcing it to update everything)
  65602. */
  65603. markAsDirty(): void;
  65604. private _markAsDirtyAndCompose;
  65605. private _markAsDirtyAndDecompose;
  65606. /**
  65607. * Translate the bone in local or world space
  65608. * @param vec The amount to translate the bone
  65609. * @param space The space that the translation is in
  65610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65611. */
  65612. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65613. /**
  65614. * Set the postion of the bone in local or world space
  65615. * @param position The position to set the bone
  65616. * @param space The space that the position is in
  65617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65618. */
  65619. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65620. /**
  65621. * Set the absolute position of the bone (world space)
  65622. * @param position The position to set the bone
  65623. * @param mesh The mesh that this bone is attached to
  65624. */
  65625. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65626. /**
  65627. * Scale the bone on the x, y and z axes (in local space)
  65628. * @param x The amount to scale the bone on the x axis
  65629. * @param y The amount to scale the bone on the y axis
  65630. * @param z The amount to scale the bone on the z axis
  65631. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65632. */
  65633. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65634. /**
  65635. * Set the bone scaling in local space
  65636. * @param scale defines the scaling vector
  65637. */
  65638. setScale(scale: Vector3): void;
  65639. /**
  65640. * Gets the current scaling in local space
  65641. * @returns the current scaling vector
  65642. */
  65643. getScale(): Vector3;
  65644. /**
  65645. * Gets the current scaling in local space and stores it in a target vector
  65646. * @param result defines the target vector
  65647. */
  65648. getScaleToRef(result: Vector3): void;
  65649. /**
  65650. * Set the yaw, pitch, and roll of the bone in local or world space
  65651. * @param yaw The rotation of the bone on the y axis
  65652. * @param pitch The rotation of the bone on the x axis
  65653. * @param roll The rotation of the bone on the z axis
  65654. * @param space The space that the axes of rotation are in
  65655. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65656. */
  65657. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65658. /**
  65659. * Add a rotation to the bone on an axis in local or world space
  65660. * @param axis The axis to rotate the bone on
  65661. * @param amount The amount to rotate the bone
  65662. * @param space The space that the axis is in
  65663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65664. */
  65665. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65666. /**
  65667. * Set the rotation of the bone to a particular axis angle in local or world space
  65668. * @param axis The axis to rotate the bone on
  65669. * @param angle The angle that the bone should be rotated to
  65670. * @param space The space that the axis is in
  65671. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65672. */
  65673. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65674. /**
  65675. * Set the euler rotation of the bone in local of world space
  65676. * @param rotation The euler rotation that the bone should be set to
  65677. * @param space The space that the rotation is in
  65678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65679. */
  65680. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65681. /**
  65682. * Set the quaternion rotation of the bone in local of world space
  65683. * @param quat The quaternion rotation that the bone should be set to
  65684. * @param space The space that the rotation is in
  65685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65686. */
  65687. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65688. /**
  65689. * Set the rotation matrix of the bone in local of world space
  65690. * @param rotMat The rotation matrix that the bone should be set to
  65691. * @param space The space that the rotation is in
  65692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65693. */
  65694. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65695. private _rotateWithMatrix;
  65696. private _getNegativeRotationToRef;
  65697. /**
  65698. * Get the position of the bone in local or world space
  65699. * @param space The space that the returned position is in
  65700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65701. * @returns The position of the bone
  65702. */
  65703. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65704. /**
  65705. * Copy the position of the bone to a vector3 in local or world space
  65706. * @param space The space that the returned position is in
  65707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65708. * @param result The vector3 to copy the position to
  65709. */
  65710. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65711. /**
  65712. * Get the absolute position of the bone (world space)
  65713. * @param mesh The mesh that this bone is attached to
  65714. * @returns The absolute position of the bone
  65715. */
  65716. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65717. /**
  65718. * Copy the absolute position of the bone (world space) to the result param
  65719. * @param mesh The mesh that this bone is attached to
  65720. * @param result The vector3 to copy the absolute position to
  65721. */
  65722. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65723. /**
  65724. * Compute the absolute transforms of this bone and its children
  65725. */
  65726. computeAbsoluteTransforms(): void;
  65727. /**
  65728. * Get the world direction from an axis that is in the local space of the bone
  65729. * @param localAxis The local direction that is used to compute the world direction
  65730. * @param mesh The mesh that this bone is attached to
  65731. * @returns The world direction
  65732. */
  65733. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65734. /**
  65735. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65736. * @param localAxis The local direction that is used to compute the world direction
  65737. * @param mesh The mesh that this bone is attached to
  65738. * @param result The vector3 that the world direction will be copied to
  65739. */
  65740. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65741. /**
  65742. * Get the euler rotation of the bone in local or world space
  65743. * @param space The space that the rotation should be in
  65744. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65745. * @returns The euler rotation
  65746. */
  65747. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65748. /**
  65749. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65750. * @param space The space that the rotation should be in
  65751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65752. * @param result The vector3 that the rotation should be copied to
  65753. */
  65754. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65755. /**
  65756. * Get the quaternion rotation of the bone in either local or world space
  65757. * @param space The space that the rotation should be in
  65758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65759. * @returns The quaternion rotation
  65760. */
  65761. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65762. /**
  65763. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65764. * @param space The space that the rotation should be in
  65765. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65766. * @param result The quaternion that the rotation should be copied to
  65767. */
  65768. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65769. /**
  65770. * Get the rotation matrix of the bone in local or world space
  65771. * @param space The space that the rotation should be in
  65772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65773. * @returns The rotation matrix
  65774. */
  65775. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65776. /**
  65777. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65778. * @param space The space that the rotation should be in
  65779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65780. * @param result The quaternion that the rotation should be copied to
  65781. */
  65782. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65783. /**
  65784. * Get the world position of a point that is in the local space of the bone
  65785. * @param position The local position
  65786. * @param mesh The mesh that this bone is attached to
  65787. * @returns The world position
  65788. */
  65789. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65790. /**
  65791. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65792. * @param position The local position
  65793. * @param mesh The mesh that this bone is attached to
  65794. * @param result The vector3 that the world position should be copied to
  65795. */
  65796. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65797. /**
  65798. * Get the local position of a point that is in world space
  65799. * @param position The world position
  65800. * @param mesh The mesh that this bone is attached to
  65801. * @returns The local position
  65802. */
  65803. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65804. /**
  65805. * Get the local position of a point that is in world space and copy it to the result param
  65806. * @param position The world position
  65807. * @param mesh The mesh that this bone is attached to
  65808. * @param result The vector3 that the local position should be copied to
  65809. */
  65810. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65811. }
  65812. }
  65813. declare module BABYLON {
  65814. /**
  65815. * Class for creating a cube texture
  65816. */
  65817. export class CubeTexture extends BaseTexture {
  65818. private _delayedOnLoad;
  65819. /**
  65820. * The url of the texture
  65821. */
  65822. url: string;
  65823. /**
  65824. * Gets or sets the center of the bounding box associated with the cube texture.
  65825. * It must define where the camera used to render the texture was set
  65826. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65827. */
  65828. boundingBoxPosition: Vector3;
  65829. private _boundingBoxSize;
  65830. /**
  65831. * Gets or sets the size of the bounding box associated with the cube texture
  65832. * When defined, the cubemap will switch to local mode
  65833. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65834. * @example https://www.babylonjs-playground.com/#RNASML
  65835. */
  65836. /**
  65837. * Returns the bounding box size
  65838. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65839. */
  65840. boundingBoxSize: Vector3;
  65841. protected _rotationY: number;
  65842. /**
  65843. * Sets texture matrix rotation angle around Y axis in radians.
  65844. */
  65845. /**
  65846. * Gets texture matrix rotation angle around Y axis radians.
  65847. */
  65848. rotationY: number;
  65849. /**
  65850. * Are mip maps generated for this texture or not.
  65851. */
  65852. readonly noMipmap: boolean;
  65853. private _noMipmap;
  65854. private _files;
  65855. private _extensions;
  65856. private _textureMatrix;
  65857. private _format;
  65858. private _createPolynomials;
  65859. /** @hidden */
  65860. _prefiltered: boolean;
  65861. /**
  65862. * Creates a cube texture from an array of image urls
  65863. * @param files defines an array of image urls
  65864. * @param scene defines the hosting scene
  65865. * @param noMipmap specifies if mip maps are not used
  65866. * @returns a cube texture
  65867. */
  65868. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65869. /**
  65870. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65871. * @param url defines the url of the prefiltered texture
  65872. * @param scene defines the scene the texture is attached to
  65873. * @param forcedExtension defines the extension of the file if different from the url
  65874. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65875. * @return the prefiltered texture
  65876. */
  65877. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65878. /**
  65879. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65880. * as prefiltered data.
  65881. * @param rootUrl defines the url of the texture or the root name of the six images
  65882. * @param scene defines the scene the texture is attached to
  65883. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65884. * @param noMipmap defines if mipmaps should be created or not
  65885. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  65886. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65887. * @param onError defines a callback triggered in case of error during load
  65888. * @param format defines the internal format to use for the texture once loaded
  65889. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65890. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65891. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65892. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65893. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65894. * @return the cube texture
  65895. */
  65896. 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);
  65897. /**
  65898. * Get the current class name of the texture useful for serialization or dynamic coding.
  65899. * @returns "CubeTexture"
  65900. */
  65901. getClassName(): string;
  65902. /**
  65903. * Update the url (and optional buffer) of this texture if url was null during construction.
  65904. * @param url the url of the texture
  65905. * @param forcedExtension defines the extension to use
  65906. * @param onLoad callback called when the texture is loaded (defaults to null)
  65907. */
  65908. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65909. /**
  65910. * Delays loading of the cube texture
  65911. * @param forcedExtension defines the extension to use
  65912. */
  65913. delayLoad(forcedExtension?: string): void;
  65914. /**
  65915. * Returns the reflection texture matrix
  65916. * @returns the reflection texture matrix
  65917. */
  65918. getReflectionTextureMatrix(): Matrix;
  65919. /**
  65920. * Sets the reflection texture matrix
  65921. * @param value Reflection texture matrix
  65922. */
  65923. setReflectionTextureMatrix(value: Matrix): void;
  65924. /**
  65925. * Parses text to create a cube texture
  65926. * @param parsedTexture define the serialized text to read from
  65927. * @param scene defines the hosting scene
  65928. * @param rootUrl defines the root url of the cube texture
  65929. * @returns a cube texture
  65930. */
  65931. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65932. /**
  65933. * Makes a clone, or deep copy, of the cube texture
  65934. * @returns a new cube texture
  65935. */
  65936. clone(): CubeTexture;
  65937. }
  65938. }
  65939. declare module BABYLON {
  65940. /** @hidden */
  65941. export var postprocessVertexShader: {
  65942. name: string;
  65943. shader: string;
  65944. };
  65945. }
  65946. declare module BABYLON {
  65947. /**
  65948. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65949. * This is the base of the follow, arc rotate cameras and Free camera
  65950. * @see http://doc.babylonjs.com/features/cameras
  65951. */
  65952. export class TargetCamera extends Camera {
  65953. private static _RigCamTransformMatrix;
  65954. private static _TargetTransformMatrix;
  65955. private static _TargetFocalPoint;
  65956. /**
  65957. * Define the current direction the camera is moving to
  65958. */
  65959. cameraDirection: Vector3;
  65960. /**
  65961. * Define the current rotation the camera is rotating to
  65962. */
  65963. cameraRotation: Vector2;
  65964. /**
  65965. * When set, the up vector of the camera will be updated by the rotation of the camera
  65966. */
  65967. updateUpVectorFromRotation: boolean;
  65968. private _tmpQuaternion;
  65969. /**
  65970. * Define the current rotation of the camera
  65971. */
  65972. rotation: Vector3;
  65973. /**
  65974. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65975. */
  65976. rotationQuaternion: Quaternion;
  65977. /**
  65978. * Define the current speed of the camera
  65979. */
  65980. speed: number;
  65981. /**
  65982. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65983. * around all axis.
  65984. */
  65985. noRotationConstraint: boolean;
  65986. /**
  65987. * Define the current target of the camera as an object or a position.
  65988. */
  65989. lockedTarget: any;
  65990. /** @hidden */
  65991. _currentTarget: Vector3;
  65992. /** @hidden */
  65993. _initialFocalDistance: number;
  65994. /** @hidden */
  65995. _viewMatrix: Matrix;
  65996. /** @hidden */
  65997. _camMatrix: Matrix;
  65998. /** @hidden */
  65999. _cameraTransformMatrix: Matrix;
  66000. /** @hidden */
  66001. _cameraRotationMatrix: Matrix;
  66002. /** @hidden */
  66003. _referencePoint: Vector3;
  66004. /** @hidden */
  66005. _transformedReferencePoint: Vector3;
  66006. protected _globalCurrentTarget: Vector3;
  66007. protected _globalCurrentUpVector: Vector3;
  66008. /** @hidden */
  66009. _reset: () => void;
  66010. private _defaultUp;
  66011. /**
  66012. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66013. * This is the base of the follow, arc rotate cameras and Free camera
  66014. * @see http://doc.babylonjs.com/features/cameras
  66015. * @param name Defines the name of the camera in the scene
  66016. * @param position Defines the start position of the camera in the scene
  66017. * @param scene Defines the scene the camera belongs to
  66018. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66019. */
  66020. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66021. /**
  66022. * Gets the position in front of the camera at a given distance.
  66023. * @param distance The distance from the camera we want the position to be
  66024. * @returns the position
  66025. */
  66026. getFrontPosition(distance: number): Vector3;
  66027. /** @hidden */
  66028. _getLockedTargetPosition(): Nullable<Vector3>;
  66029. private _storedPosition;
  66030. private _storedRotation;
  66031. private _storedRotationQuaternion;
  66032. /**
  66033. * Store current camera state of the camera (fov, position, rotation, etc..)
  66034. * @returns the camera
  66035. */
  66036. storeState(): Camera;
  66037. /**
  66038. * Restored camera state. You must call storeState() first
  66039. * @returns whether it was successful or not
  66040. * @hidden
  66041. */
  66042. _restoreStateValues(): boolean;
  66043. /** @hidden */
  66044. _initCache(): void;
  66045. /** @hidden */
  66046. _updateCache(ignoreParentClass?: boolean): void;
  66047. /** @hidden */
  66048. _isSynchronizedViewMatrix(): boolean;
  66049. /** @hidden */
  66050. _computeLocalCameraSpeed(): number;
  66051. /**
  66052. * Defines the target the camera should look at.
  66053. * This will automatically adapt alpha beta and radius to fit within the new target.
  66054. * @param target Defines the new target as a Vector or a mesh
  66055. */
  66056. setTarget(target: Vector3): void;
  66057. /**
  66058. * Return the current target position of the camera. This value is expressed in local space.
  66059. * @returns the target position
  66060. */
  66061. getTarget(): Vector3;
  66062. /** @hidden */
  66063. _decideIfNeedsToMove(): boolean;
  66064. /** @hidden */
  66065. _updatePosition(): void;
  66066. /** @hidden */
  66067. _checkInputs(): void;
  66068. protected _updateCameraRotationMatrix(): void;
  66069. /**
  66070. * 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)
  66071. * @returns the current camera
  66072. */
  66073. private _rotateUpVectorWithCameraRotationMatrix;
  66074. private _cachedRotationZ;
  66075. private _cachedQuaternionRotationZ;
  66076. /** @hidden */
  66077. _getViewMatrix(): Matrix;
  66078. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66079. /**
  66080. * @hidden
  66081. */
  66082. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66083. /**
  66084. * @hidden
  66085. */
  66086. _updateRigCameras(): void;
  66087. private _getRigCamPositionAndTarget;
  66088. /**
  66089. * Gets the current object class name.
  66090. * @return the class name
  66091. */
  66092. getClassName(): string;
  66093. }
  66094. }
  66095. declare module BABYLON {
  66096. /**
  66097. * @ignore
  66098. * This is a list of all the different input types that are available in the application.
  66099. * Fo instance: ArcRotateCameraGamepadInput...
  66100. */
  66101. export var CameraInputTypes: {};
  66102. /**
  66103. * This is the contract to implement in order to create a new input class.
  66104. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66105. */
  66106. export interface ICameraInput<TCamera extends Camera> {
  66107. /**
  66108. * Defines the camera the input is attached to.
  66109. */
  66110. camera: Nullable<TCamera>;
  66111. /**
  66112. * Gets the class name of the current intput.
  66113. * @returns the class name
  66114. */
  66115. getClassName(): string;
  66116. /**
  66117. * Get the friendly name associated with the input class.
  66118. * @returns the input friendly name
  66119. */
  66120. getSimpleName(): string;
  66121. /**
  66122. * Attach the input controls to a specific dom element to get the input from.
  66123. * @param element Defines the element the controls should be listened from
  66124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66125. */
  66126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66127. /**
  66128. * Detach the current controls from the specified dom element.
  66129. * @param element Defines the element to stop listening the inputs from
  66130. */
  66131. detachControl(element: Nullable<HTMLElement>): void;
  66132. /**
  66133. * Update the current camera state depending on the inputs that have been used this frame.
  66134. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66135. */
  66136. checkInputs?: () => void;
  66137. }
  66138. /**
  66139. * Represents a map of input types to input instance or input index to input instance.
  66140. */
  66141. export interface CameraInputsMap<TCamera extends Camera> {
  66142. /**
  66143. * Accessor to the input by input type.
  66144. */
  66145. [name: string]: ICameraInput<TCamera>;
  66146. /**
  66147. * Accessor to the input by input index.
  66148. */
  66149. [idx: number]: ICameraInput<TCamera>;
  66150. }
  66151. /**
  66152. * This represents the input manager used within a camera.
  66153. * It helps dealing with all the different kind of input attached to a camera.
  66154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66155. */
  66156. export class CameraInputsManager<TCamera extends Camera> {
  66157. /**
  66158. * Defines the list of inputs attahed to the camera.
  66159. */
  66160. attached: CameraInputsMap<TCamera>;
  66161. /**
  66162. * Defines the dom element the camera is collecting inputs from.
  66163. * This is null if the controls have not been attached.
  66164. */
  66165. attachedElement: Nullable<HTMLElement>;
  66166. /**
  66167. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66168. */
  66169. noPreventDefault: boolean;
  66170. /**
  66171. * Defined the camera the input manager belongs to.
  66172. */
  66173. camera: TCamera;
  66174. /**
  66175. * Update the current camera state depending on the inputs that have been used this frame.
  66176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66177. */
  66178. checkInputs: () => void;
  66179. /**
  66180. * Instantiate a new Camera Input Manager.
  66181. * @param camera Defines the camera the input manager blongs to
  66182. */
  66183. constructor(camera: TCamera);
  66184. /**
  66185. * Add an input method to a camera
  66186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66187. * @param input camera input method
  66188. */
  66189. add(input: ICameraInput<TCamera>): void;
  66190. /**
  66191. * Remove a specific input method from a camera
  66192. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  66193. * @param inputToRemove camera input method
  66194. */
  66195. remove(inputToRemove: ICameraInput<TCamera>): void;
  66196. /**
  66197. * Remove a specific input type from a camera
  66198. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  66199. * @param inputType the type of the input to remove
  66200. */
  66201. removeByType(inputType: string): void;
  66202. private _addCheckInputs;
  66203. /**
  66204. * Attach the input controls to the currently attached dom element to listen the events from.
  66205. * @param input Defines the input to attach
  66206. */
  66207. attachInput(input: ICameraInput<TCamera>): void;
  66208. /**
  66209. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  66210. * @param element Defines the dom element to collect the events from
  66211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66212. */
  66213. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  66214. /**
  66215. * Detach the current manager inputs controls from a specific dom element.
  66216. * @param element Defines the dom element to collect the events from
  66217. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  66218. */
  66219. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66220. /**
  66221. * Rebuild the dynamic inputCheck function from the current list of
  66222. * defined inputs in the manager.
  66223. */
  66224. rebuildInputCheck(): void;
  66225. /**
  66226. * Remove all attached input methods from a camera
  66227. */
  66228. clear(): void;
  66229. /**
  66230. * Serialize the current input manager attached to a camera.
  66231. * This ensures than once parsed,
  66232. * the input associated to the camera will be identical to the current ones
  66233. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66234. */
  66235. serialize(serializedCamera: any): void;
  66236. /**
  66237. * Parses an input manager serialized JSON to restore the previous list of inputs
  66238. * and states associated to a camera.
  66239. * @param parsedCamera Defines the JSON to parse
  66240. */
  66241. parse(parsedCamera: any): void;
  66242. }
  66243. }
  66244. declare module BABYLON {
  66245. /**
  66246. * Gather the list of keyboard event types as constants.
  66247. */
  66248. export class KeyboardEventTypes {
  66249. /**
  66250. * The keydown event is fired when a key becomes active (pressed).
  66251. */
  66252. static readonly KEYDOWN: number;
  66253. /**
  66254. * The keyup event is fired when a key has been released.
  66255. */
  66256. static readonly KEYUP: number;
  66257. }
  66258. /**
  66259. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66260. */
  66261. export class KeyboardInfo {
  66262. /**
  66263. * Defines the type of event (KeyboardEventTypes)
  66264. */
  66265. type: number;
  66266. /**
  66267. * Defines the related dom event
  66268. */
  66269. event: KeyboardEvent;
  66270. /**
  66271. * Instantiates a new keyboard info.
  66272. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66273. * @param type Defines the type of event (KeyboardEventTypes)
  66274. * @param event Defines the related dom event
  66275. */
  66276. constructor(
  66277. /**
  66278. * Defines the type of event (KeyboardEventTypes)
  66279. */
  66280. type: number,
  66281. /**
  66282. * Defines the related dom event
  66283. */
  66284. event: KeyboardEvent);
  66285. }
  66286. /**
  66287. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66288. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66289. */
  66290. export class KeyboardInfoPre extends KeyboardInfo {
  66291. /**
  66292. * Defines the type of event (KeyboardEventTypes)
  66293. */
  66294. type: number;
  66295. /**
  66296. * Defines the related dom event
  66297. */
  66298. event: KeyboardEvent;
  66299. /**
  66300. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66301. */
  66302. skipOnPointerObservable: boolean;
  66303. /**
  66304. * Instantiates a new keyboard pre info.
  66305. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66306. * @param type Defines the type of event (KeyboardEventTypes)
  66307. * @param event Defines the related dom event
  66308. */
  66309. constructor(
  66310. /**
  66311. * Defines the type of event (KeyboardEventTypes)
  66312. */
  66313. type: number,
  66314. /**
  66315. * Defines the related dom event
  66316. */
  66317. event: KeyboardEvent);
  66318. }
  66319. }
  66320. declare module BABYLON {
  66321. /**
  66322. * Manage the keyboard inputs to control the movement of a free camera.
  66323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66324. */
  66325. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66326. /**
  66327. * Defines the camera the input is attached to.
  66328. */
  66329. camera: FreeCamera;
  66330. /**
  66331. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66332. */
  66333. keysUp: number[];
  66334. /**
  66335. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66336. */
  66337. keysDown: number[];
  66338. /**
  66339. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66340. */
  66341. keysLeft: number[];
  66342. /**
  66343. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66344. */
  66345. keysRight: number[];
  66346. private _keys;
  66347. private _onCanvasBlurObserver;
  66348. private _onKeyboardObserver;
  66349. private _engine;
  66350. private _scene;
  66351. /**
  66352. * Attach the input controls to a specific dom element to get the input from.
  66353. * @param element Defines the element the controls should be listened from
  66354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66355. */
  66356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66357. /**
  66358. * Detach the current controls from the specified dom element.
  66359. * @param element Defines the element to stop listening the inputs from
  66360. */
  66361. detachControl(element: Nullable<HTMLElement>): void;
  66362. /**
  66363. * Update the current camera state depending on the inputs that have been used this frame.
  66364. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66365. */
  66366. checkInputs(): void;
  66367. /**
  66368. * Gets the class name of the current intput.
  66369. * @returns the class name
  66370. */
  66371. getClassName(): string;
  66372. /** @hidden */
  66373. _onLostFocus(): void;
  66374. /**
  66375. * Get the friendly name associated with the input class.
  66376. * @returns the input friendly name
  66377. */
  66378. getSimpleName(): string;
  66379. }
  66380. }
  66381. declare module BABYLON {
  66382. /**
  66383. * Interface describing all the common properties and methods a shadow light needs to implement.
  66384. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66385. * as well as binding the different shadow properties to the effects.
  66386. */
  66387. export interface IShadowLight extends Light {
  66388. /**
  66389. * The light id in the scene (used in scene.findLighById for instance)
  66390. */
  66391. id: string;
  66392. /**
  66393. * The position the shdow will be casted from.
  66394. */
  66395. position: Vector3;
  66396. /**
  66397. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66398. */
  66399. direction: Vector3;
  66400. /**
  66401. * The transformed position. Position of the light in world space taking parenting in account.
  66402. */
  66403. transformedPosition: Vector3;
  66404. /**
  66405. * The transformed direction. Direction of the light in world space taking parenting in account.
  66406. */
  66407. transformedDirection: Vector3;
  66408. /**
  66409. * The friendly name of the light in the scene.
  66410. */
  66411. name: string;
  66412. /**
  66413. * Defines the shadow projection clipping minimum z value.
  66414. */
  66415. shadowMinZ: number;
  66416. /**
  66417. * Defines the shadow projection clipping maximum z value.
  66418. */
  66419. shadowMaxZ: number;
  66420. /**
  66421. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66422. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66423. */
  66424. computeTransformedInformation(): boolean;
  66425. /**
  66426. * Gets the scene the light belongs to.
  66427. * @returns The scene
  66428. */
  66429. getScene(): Scene;
  66430. /**
  66431. * Callback defining a custom Projection Matrix Builder.
  66432. * This can be used to override the default projection matrix computation.
  66433. */
  66434. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66435. /**
  66436. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66437. * @param matrix The materix to updated with the projection information
  66438. * @param viewMatrix The transform matrix of the light
  66439. * @param renderList The list of mesh to render in the map
  66440. * @returns The current light
  66441. */
  66442. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66443. /**
  66444. * Gets the current depth scale used in ESM.
  66445. * @returns The scale
  66446. */
  66447. getDepthScale(): number;
  66448. /**
  66449. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66450. * @returns true if a cube texture needs to be use
  66451. */
  66452. needCube(): boolean;
  66453. /**
  66454. * Detects if the projection matrix requires to be recomputed this frame.
  66455. * @returns true if it requires to be recomputed otherwise, false.
  66456. */
  66457. needProjectionMatrixCompute(): boolean;
  66458. /**
  66459. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66460. */
  66461. forceProjectionMatrixCompute(): void;
  66462. /**
  66463. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66464. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66465. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66466. */
  66467. getShadowDirection(faceIndex?: number): Vector3;
  66468. /**
  66469. * Gets the minZ used for shadow according to both the scene and the light.
  66470. * @param activeCamera The camera we are returning the min for
  66471. * @returns the depth min z
  66472. */
  66473. getDepthMinZ(activeCamera: Camera): number;
  66474. /**
  66475. * Gets the maxZ used for shadow according to both the scene and the light.
  66476. * @param activeCamera The camera we are returning the max for
  66477. * @returns the depth max z
  66478. */
  66479. getDepthMaxZ(activeCamera: Camera): number;
  66480. }
  66481. /**
  66482. * Base implementation IShadowLight
  66483. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66484. */
  66485. export abstract class ShadowLight extends Light implements IShadowLight {
  66486. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66487. protected _position: Vector3;
  66488. protected _setPosition(value: Vector3): void;
  66489. /**
  66490. * Sets the position the shadow will be casted from. Also use as the light position for both
  66491. * point and spot lights.
  66492. */
  66493. /**
  66494. * Sets the position the shadow will be casted from. Also use as the light position for both
  66495. * point and spot lights.
  66496. */
  66497. position: Vector3;
  66498. protected _direction: Vector3;
  66499. protected _setDirection(value: Vector3): void;
  66500. /**
  66501. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66502. * Also use as the light direction on spot and directional lights.
  66503. */
  66504. /**
  66505. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66506. * Also use as the light direction on spot and directional lights.
  66507. */
  66508. direction: Vector3;
  66509. private _shadowMinZ;
  66510. /**
  66511. * Gets the shadow projection clipping minimum z value.
  66512. */
  66513. /**
  66514. * Sets the shadow projection clipping minimum z value.
  66515. */
  66516. shadowMinZ: number;
  66517. private _shadowMaxZ;
  66518. /**
  66519. * Sets the shadow projection clipping maximum z value.
  66520. */
  66521. /**
  66522. * Gets the shadow projection clipping maximum z value.
  66523. */
  66524. shadowMaxZ: number;
  66525. /**
  66526. * Callback defining a custom Projection Matrix Builder.
  66527. * This can be used to override the default projection matrix computation.
  66528. */
  66529. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66530. /**
  66531. * The transformed position. Position of the light in world space taking parenting in account.
  66532. */
  66533. transformedPosition: Vector3;
  66534. /**
  66535. * The transformed direction. Direction of the light in world space taking parenting in account.
  66536. */
  66537. transformedDirection: Vector3;
  66538. private _needProjectionMatrixCompute;
  66539. /**
  66540. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66541. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66542. */
  66543. computeTransformedInformation(): boolean;
  66544. /**
  66545. * Return the depth scale used for the shadow map.
  66546. * @returns the depth scale.
  66547. */
  66548. getDepthScale(): number;
  66549. /**
  66550. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66551. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66552. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66553. */
  66554. getShadowDirection(faceIndex?: number): Vector3;
  66555. /**
  66556. * Returns the ShadowLight absolute position in the World.
  66557. * @returns the position vector in world space
  66558. */
  66559. getAbsolutePosition(): Vector3;
  66560. /**
  66561. * Sets the ShadowLight direction toward the passed target.
  66562. * @param target The point to target in local space
  66563. * @returns the updated ShadowLight direction
  66564. */
  66565. setDirectionToTarget(target: Vector3): Vector3;
  66566. /**
  66567. * Returns the light rotation in euler definition.
  66568. * @returns the x y z rotation in local space.
  66569. */
  66570. getRotation(): Vector3;
  66571. /**
  66572. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66573. * @returns true if a cube texture needs to be use
  66574. */
  66575. needCube(): boolean;
  66576. /**
  66577. * Detects if the projection matrix requires to be recomputed this frame.
  66578. * @returns true if it requires to be recomputed otherwise, false.
  66579. */
  66580. needProjectionMatrixCompute(): boolean;
  66581. /**
  66582. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66583. */
  66584. forceProjectionMatrixCompute(): void;
  66585. /** @hidden */
  66586. _initCache(): void;
  66587. /** @hidden */
  66588. _isSynchronized(): boolean;
  66589. /**
  66590. * Computes the world matrix of the node
  66591. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66592. * @returns the world matrix
  66593. */
  66594. computeWorldMatrix(force?: boolean): Matrix;
  66595. /**
  66596. * Gets the minZ used for shadow according to both the scene and the light.
  66597. * @param activeCamera The camera we are returning the min for
  66598. * @returns the depth min z
  66599. */
  66600. getDepthMinZ(activeCamera: Camera): number;
  66601. /**
  66602. * Gets the maxZ used for shadow according to both the scene and the light.
  66603. * @param activeCamera The camera we are returning the max for
  66604. * @returns the depth max z
  66605. */
  66606. getDepthMaxZ(activeCamera: Camera): number;
  66607. /**
  66608. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66609. * @param matrix The materix to updated with the projection information
  66610. * @param viewMatrix The transform matrix of the light
  66611. * @param renderList The list of mesh to render in the map
  66612. * @returns The current light
  66613. */
  66614. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66615. }
  66616. }
  66617. declare module BABYLON {
  66618. /**
  66619. * "Static Class" containing the most commonly used helper while dealing with material for
  66620. * rendering purpose.
  66621. *
  66622. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66623. *
  66624. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66625. */
  66626. export class MaterialHelper {
  66627. /**
  66628. * Bind the current view position to an effect.
  66629. * @param effect The effect to be bound
  66630. * @param scene The scene the eyes position is used from
  66631. */
  66632. static BindEyePosition(effect: Effect, scene: Scene): void;
  66633. /**
  66634. * Helps preparing the defines values about the UVs in used in the effect.
  66635. * UVs are shared as much as we can accross channels in the shaders.
  66636. * @param texture The texture we are preparing the UVs for
  66637. * @param defines The defines to update
  66638. * @param key The channel key "diffuse", "specular"... used in the shader
  66639. */
  66640. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66641. /**
  66642. * Binds a texture matrix value to its corrsponding uniform
  66643. * @param texture The texture to bind the matrix for
  66644. * @param uniformBuffer The uniform buffer receivin the data
  66645. * @param key The channel key "diffuse", "specular"... used in the shader
  66646. */
  66647. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66648. /**
  66649. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66650. * @param mesh defines the current mesh
  66651. * @param scene defines the current scene
  66652. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66653. * @param pointsCloud defines if point cloud rendering has to be turned on
  66654. * @param fogEnabled defines if fog has to be turned on
  66655. * @param alphaTest defines if alpha testing has to be turned on
  66656. * @param defines defines the current list of defines
  66657. */
  66658. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66659. /**
  66660. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66661. * @param scene defines the current scene
  66662. * @param engine defines the current engine
  66663. * @param defines specifies the list of active defines
  66664. * @param useInstances defines if instances have to be turned on
  66665. * @param useClipPlane defines if clip plane have to be turned on
  66666. */
  66667. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66668. /**
  66669. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66670. * @param mesh The mesh containing the geometry data we will draw
  66671. * @param defines The defines to update
  66672. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66673. * @param useBones Precise whether bones should be used or not (override mesh info)
  66674. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66675. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66676. * @returns false if defines are considered not dirty and have not been checked
  66677. */
  66678. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66679. /**
  66680. * Prepares the defines related to the light information passed in parameter
  66681. * @param scene The scene we are intending to draw
  66682. * @param mesh The mesh the effect is compiling for
  66683. * @param defines The defines to update
  66684. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66685. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66686. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66687. * @returns true if normals will be required for the rest of the effect
  66688. */
  66689. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66690. /**
  66691. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66692. * that won t be acctive due to defines being turned off.
  66693. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66694. * @param samplersList The samplers list
  66695. * @param defines The defines helping in the list generation
  66696. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66697. */
  66698. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66699. /**
  66700. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66701. * @param defines The defines to update while falling back
  66702. * @param fallbacks The authorized effect fallbacks
  66703. * @param maxSimultaneousLights The maximum number of lights allowed
  66704. * @param rank the current rank of the Effect
  66705. * @returns The newly affected rank
  66706. */
  66707. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66708. /**
  66709. * Prepares the list of attributes required for morph targets according to the effect defines.
  66710. * @param attribs The current list of supported attribs
  66711. * @param mesh The mesh to prepare the morph targets attributes for
  66712. * @param defines The current Defines of the effect
  66713. */
  66714. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66715. /**
  66716. * Prepares the list of attributes required for bones according to the effect defines.
  66717. * @param attribs The current list of supported attribs
  66718. * @param mesh The mesh to prepare the bones attributes for
  66719. * @param defines The current Defines of the effect
  66720. * @param fallbacks The current efffect fallback strategy
  66721. */
  66722. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66723. /**
  66724. * Prepares the list of attributes required for instances according to the effect defines.
  66725. * @param attribs The current list of supported attribs
  66726. * @param defines The current Defines of the effect
  66727. */
  66728. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66729. /**
  66730. * Binds the light shadow information to the effect for the given mesh.
  66731. * @param light The light containing the generator
  66732. * @param scene The scene the lights belongs to
  66733. * @param mesh The mesh we are binding the information to render
  66734. * @param lightIndex The light index in the effect used to render the mesh
  66735. * @param effect The effect we are binding the data to
  66736. */
  66737. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66738. /**
  66739. * Binds the light information to the effect.
  66740. * @param light The light containing the generator
  66741. * @param effect The effect we are binding the data to
  66742. * @param lightIndex The light index in the effect used to render
  66743. */
  66744. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66745. /**
  66746. * Binds the lights information from the scene to the effect for the given mesh.
  66747. * @param scene The scene the lights belongs to
  66748. * @param mesh The mesh we are binding the information to render
  66749. * @param effect The effect we are binding the data to
  66750. * @param defines The generated defines for the effect
  66751. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66752. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66753. */
  66754. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66755. private static _tempFogColor;
  66756. /**
  66757. * Binds the fog information from the scene to the effect for the given mesh.
  66758. * @param scene The scene the lights belongs to
  66759. * @param mesh The mesh we are binding the information to render
  66760. * @param effect The effect we are binding the data to
  66761. * @param linearSpace Defines if the fog effect is applied in linear space
  66762. */
  66763. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66764. /**
  66765. * Binds the bones information from the mesh to the effect.
  66766. * @param mesh The mesh we are binding the information to render
  66767. * @param effect The effect we are binding the data to
  66768. */
  66769. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66770. /**
  66771. * Binds the morph targets information from the mesh to the effect.
  66772. * @param abstractMesh The mesh we are binding the information to render
  66773. * @param effect The effect we are binding the data to
  66774. */
  66775. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66776. /**
  66777. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66778. * @param defines The generated defines used in the effect
  66779. * @param effect The effect we are binding the data to
  66780. * @param scene The scene we are willing to render with logarithmic scale for
  66781. */
  66782. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66783. /**
  66784. * Binds the clip plane information from the scene to the effect.
  66785. * @param scene The scene the clip plane information are extracted from
  66786. * @param effect The effect we are binding the data to
  66787. */
  66788. static BindClipPlane(effect: Effect, scene: Scene): void;
  66789. }
  66790. }
  66791. declare module BABYLON {
  66792. /** @hidden */
  66793. export var kernelBlurVaryingDeclaration: {
  66794. name: string;
  66795. shader: string;
  66796. };
  66797. }
  66798. declare module BABYLON {
  66799. /** @hidden */
  66800. export var kernelBlurFragment: {
  66801. name: string;
  66802. shader: string;
  66803. };
  66804. }
  66805. declare module BABYLON {
  66806. /** @hidden */
  66807. export var kernelBlurFragment2: {
  66808. name: string;
  66809. shader: string;
  66810. };
  66811. }
  66812. declare module BABYLON {
  66813. /** @hidden */
  66814. export var kernelBlurPixelShader: {
  66815. name: string;
  66816. shader: string;
  66817. };
  66818. }
  66819. declare module BABYLON {
  66820. /** @hidden */
  66821. export var kernelBlurVertex: {
  66822. name: string;
  66823. shader: string;
  66824. };
  66825. }
  66826. declare module BABYLON {
  66827. /** @hidden */
  66828. export var kernelBlurVertexShader: {
  66829. name: string;
  66830. shader: string;
  66831. };
  66832. }
  66833. declare module BABYLON {
  66834. /**
  66835. * The Blur Post Process which blurs an image based on a kernel and direction.
  66836. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66837. */
  66838. export class BlurPostProcess extends PostProcess {
  66839. /** The direction in which to blur the image. */
  66840. direction: Vector2;
  66841. private blockCompilation;
  66842. protected _kernel: number;
  66843. protected _idealKernel: number;
  66844. protected _packedFloat: boolean;
  66845. private _staticDefines;
  66846. /**
  66847. * Sets the length in pixels of the blur sample region
  66848. */
  66849. /**
  66850. * Gets the length in pixels of the blur sample region
  66851. */
  66852. kernel: number;
  66853. /**
  66854. * Sets wether or not the blur needs to unpack/repack floats
  66855. */
  66856. /**
  66857. * Gets wether or not the blur is unpacking/repacking floats
  66858. */
  66859. packedFloat: boolean;
  66860. /**
  66861. * Creates a new instance BlurPostProcess
  66862. * @param name The name of the effect.
  66863. * @param direction The direction in which to blur the image.
  66864. * @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.
  66865. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66866. * @param camera The camera to apply the render pass to.
  66867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66868. * @param engine The engine which the post process will be applied. (default: current engine)
  66869. * @param reusable If the post process can be reused on the same frame. (default: false)
  66870. * @param textureType Type of textures used when performing the post process. (default: 0)
  66871. * @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)
  66872. */
  66873. constructor(name: string,
  66874. /** The direction in which to blur the image. */
  66875. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66876. /**
  66877. * Updates the effect with the current post process compile time values and recompiles the shader.
  66878. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66879. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66880. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66881. * @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
  66882. * @param onCompiled Called when the shader has been compiled.
  66883. * @param onError Called if there is an error when compiling a shader.
  66884. */
  66885. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66886. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66887. /**
  66888. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66889. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66890. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66891. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66892. * The gaps between physical kernels are compensated for in the weighting of the samples
  66893. * @param idealKernel Ideal blur kernel.
  66894. * @return Nearest best kernel.
  66895. */
  66896. protected _nearestBestKernel(idealKernel: number): number;
  66897. /**
  66898. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66899. * @param x The point on the Gaussian distribution to sample.
  66900. * @return the value of the Gaussian function at x.
  66901. */
  66902. protected _gaussianWeight(x: number): number;
  66903. /**
  66904. * Generates a string that can be used as a floating point number in GLSL.
  66905. * @param x Value to print.
  66906. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66907. * @return GLSL float string.
  66908. */
  66909. protected _glslFloat(x: number, decimalFigures?: number): string;
  66910. }
  66911. }
  66912. declare module BABYLON {
  66913. /** @hidden */
  66914. export var shadowMapPixelShader: {
  66915. name: string;
  66916. shader: string;
  66917. };
  66918. }
  66919. declare module BABYLON {
  66920. /** @hidden */
  66921. export var bonesDeclaration: {
  66922. name: string;
  66923. shader: string;
  66924. };
  66925. }
  66926. declare module BABYLON {
  66927. /** @hidden */
  66928. export var morphTargetsVertexGlobalDeclaration: {
  66929. name: string;
  66930. shader: string;
  66931. };
  66932. }
  66933. declare module BABYLON {
  66934. /** @hidden */
  66935. export var morphTargetsVertexDeclaration: {
  66936. name: string;
  66937. shader: string;
  66938. };
  66939. }
  66940. declare module BABYLON {
  66941. /** @hidden */
  66942. export var instancesDeclaration: {
  66943. name: string;
  66944. shader: string;
  66945. };
  66946. }
  66947. declare module BABYLON {
  66948. /** @hidden */
  66949. export var helperFunctions: {
  66950. name: string;
  66951. shader: string;
  66952. };
  66953. }
  66954. declare module BABYLON {
  66955. /** @hidden */
  66956. export var morphTargetsVertex: {
  66957. name: string;
  66958. shader: string;
  66959. };
  66960. }
  66961. declare module BABYLON {
  66962. /** @hidden */
  66963. export var instancesVertex: {
  66964. name: string;
  66965. shader: string;
  66966. };
  66967. }
  66968. declare module BABYLON {
  66969. /** @hidden */
  66970. export var bonesVertex: {
  66971. name: string;
  66972. shader: string;
  66973. };
  66974. }
  66975. declare module BABYLON {
  66976. /** @hidden */
  66977. export var shadowMapVertexShader: {
  66978. name: string;
  66979. shader: string;
  66980. };
  66981. }
  66982. declare module BABYLON {
  66983. /** @hidden */
  66984. export var depthBoxBlurPixelShader: {
  66985. name: string;
  66986. shader: string;
  66987. };
  66988. }
  66989. declare module BABYLON {
  66990. /**
  66991. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66992. */
  66993. export interface ICustomShaderOptions {
  66994. /**
  66995. * Gets or sets the custom shader name to use
  66996. */
  66997. shaderName: string;
  66998. /**
  66999. * The list of attribute names used in the shader
  67000. */
  67001. attributes?: string[];
  67002. /**
  67003. * The list of unifrom names used in the shader
  67004. */
  67005. uniforms?: string[];
  67006. /**
  67007. * The list of sampler names used in the shader
  67008. */
  67009. samplers?: string[];
  67010. /**
  67011. * The list of defines used in the shader
  67012. */
  67013. defines?: string[];
  67014. }
  67015. /**
  67016. * Interface to implement to create a shadow generator compatible with BJS.
  67017. */
  67018. export interface IShadowGenerator {
  67019. /**
  67020. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67021. * @returns The render target texture if present otherwise, null
  67022. */
  67023. getShadowMap(): Nullable<RenderTargetTexture>;
  67024. /**
  67025. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67026. * @returns The render target texture if the shadow map is present otherwise, null
  67027. */
  67028. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67029. /**
  67030. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67031. * @param subMesh The submesh we want to render in the shadow map
  67032. * @param useInstances Defines wether will draw in the map using instances
  67033. * @returns true if ready otherwise, false
  67034. */
  67035. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67036. /**
  67037. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67038. * @param defines Defines of the material we want to update
  67039. * @param lightIndex Index of the light in the enabled light list of the material
  67040. */
  67041. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67042. /**
  67043. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67044. * defined in the generator but impacting the effect).
  67045. * It implies the unifroms available on the materials are the standard BJS ones.
  67046. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67047. * @param effect The effect we are binfing the information for
  67048. */
  67049. bindShadowLight(lightIndex: string, effect: Effect): void;
  67050. /**
  67051. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67052. * (eq to shadow prjection matrix * light transform matrix)
  67053. * @returns The transform matrix used to create the shadow map
  67054. */
  67055. getTransformMatrix(): Matrix;
  67056. /**
  67057. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67058. * Cube and 2D textures for instance.
  67059. */
  67060. recreateShadowMap(): void;
  67061. /**
  67062. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67063. * @param onCompiled Callback triggered at the and of the effects compilation
  67064. * @param options Sets of optional options forcing the compilation with different modes
  67065. */
  67066. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67067. useInstances: boolean;
  67068. }>): void;
  67069. /**
  67070. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67071. * @param options Sets of optional options forcing the compilation with different modes
  67072. * @returns A promise that resolves when the compilation completes
  67073. */
  67074. forceCompilationAsync(options?: Partial<{
  67075. useInstances: boolean;
  67076. }>): Promise<void>;
  67077. /**
  67078. * Serializes the shadow generator setup to a json object.
  67079. * @returns The serialized JSON object
  67080. */
  67081. serialize(): any;
  67082. /**
  67083. * Disposes the Shadow map and related Textures and effects.
  67084. */
  67085. dispose(): void;
  67086. }
  67087. /**
  67088. * Default implementation IShadowGenerator.
  67089. * This is the main object responsible of generating shadows in the framework.
  67090. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67091. */
  67092. export class ShadowGenerator implements IShadowGenerator {
  67093. /**
  67094. * Shadow generator mode None: no filtering applied.
  67095. */
  67096. static readonly FILTER_NONE: number;
  67097. /**
  67098. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67099. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67100. */
  67101. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67102. /**
  67103. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67104. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67105. */
  67106. static readonly FILTER_POISSONSAMPLING: number;
  67107. /**
  67108. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67109. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67110. */
  67111. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67112. /**
  67113. * Shadow generator mode ESM: 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_CLOSEEXPONENTIALSHADOWMAP: number;
  67118. /**
  67119. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67120. * edge artifacts on steep falloff.
  67121. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67122. */
  67123. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67124. /**
  67125. * Shadow generator mode PCF: Percentage Closer Filtering
  67126. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67127. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67128. */
  67129. static readonly FILTER_PCF: number;
  67130. /**
  67131. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67132. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67133. * Contact Hardening
  67134. */
  67135. static readonly FILTER_PCSS: number;
  67136. /**
  67137. * Reserved for PCF and PCSS
  67138. * Highest Quality.
  67139. *
  67140. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  67141. *
  67142. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  67143. */
  67144. static readonly QUALITY_HIGH: number;
  67145. /**
  67146. * Reserved for PCF and PCSS
  67147. * Good tradeoff for quality/perf cross devices
  67148. *
  67149. * Execute PCF on a 3*3 kernel.
  67150. *
  67151. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  67152. */
  67153. static readonly QUALITY_MEDIUM: number;
  67154. /**
  67155. * Reserved for PCF and PCSS
  67156. * The lowest quality but the fastest.
  67157. *
  67158. * Execute PCF on a 1*1 kernel.
  67159. *
  67160. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  67161. */
  67162. static readonly QUALITY_LOW: number;
  67163. /** Gets or sets the custom shader name to use */
  67164. customShaderOptions: ICustomShaderOptions;
  67165. /**
  67166. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  67167. */
  67168. onBeforeShadowMapRenderObservable: Observable<Effect>;
  67169. /**
  67170. * Observable triggered before a mesh is rendered in the shadow map.
  67171. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  67172. */
  67173. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  67174. private _bias;
  67175. /**
  67176. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  67177. */
  67178. /**
  67179. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  67180. */
  67181. bias: number;
  67182. private _normalBias;
  67183. /**
  67184. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67185. */
  67186. /**
  67187. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67188. */
  67189. normalBias: number;
  67190. private _blurBoxOffset;
  67191. /**
  67192. * Gets the blur box offset: offset applied during the blur pass.
  67193. * Only useful if useKernelBlur = false
  67194. */
  67195. /**
  67196. * Sets the blur box offset: offset applied during the blur pass.
  67197. * Only useful if useKernelBlur = false
  67198. */
  67199. blurBoxOffset: number;
  67200. private _blurScale;
  67201. /**
  67202. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  67203. * 2 means half of the size.
  67204. */
  67205. /**
  67206. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  67207. * 2 means half of the size.
  67208. */
  67209. blurScale: number;
  67210. private _blurKernel;
  67211. /**
  67212. * Gets the blur kernel: kernel size of the blur pass.
  67213. * Only useful if useKernelBlur = true
  67214. */
  67215. /**
  67216. * Sets the blur kernel: kernel size of the blur pass.
  67217. * Only useful if useKernelBlur = true
  67218. */
  67219. blurKernel: number;
  67220. private _useKernelBlur;
  67221. /**
  67222. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67223. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67224. */
  67225. /**
  67226. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67227. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67228. */
  67229. useKernelBlur: boolean;
  67230. private _depthScale;
  67231. /**
  67232. * Gets the depth scale used in ESM mode.
  67233. */
  67234. /**
  67235. * Sets the depth scale used in ESM mode.
  67236. * This can override the scale stored on the light.
  67237. */
  67238. depthScale: number;
  67239. private _filter;
  67240. /**
  67241. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67242. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67243. */
  67244. /**
  67245. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67246. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67247. */
  67248. filter: number;
  67249. /**
  67250. * Gets if the current filter is set to Poisson Sampling.
  67251. */
  67252. /**
  67253. * Sets the current filter to Poisson Sampling.
  67254. */
  67255. usePoissonSampling: boolean;
  67256. /**
  67257. * Gets if the current filter is set to ESM.
  67258. */
  67259. /**
  67260. * Sets the current filter is to ESM.
  67261. */
  67262. useExponentialShadowMap: boolean;
  67263. /**
  67264. * Gets if the current filter is set to filtered ESM.
  67265. */
  67266. /**
  67267. * Gets if the current filter is set to filtered ESM.
  67268. */
  67269. useBlurExponentialShadowMap: boolean;
  67270. /**
  67271. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67272. * exponential to prevent steep falloff artifacts).
  67273. */
  67274. /**
  67275. * Sets the current filter to "close ESM" (using the inverse of the
  67276. * exponential to prevent steep falloff artifacts).
  67277. */
  67278. useCloseExponentialShadowMap: boolean;
  67279. /**
  67280. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67281. * exponential to prevent steep falloff artifacts).
  67282. */
  67283. /**
  67284. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67285. * exponential to prevent steep falloff artifacts).
  67286. */
  67287. useBlurCloseExponentialShadowMap: boolean;
  67288. /**
  67289. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67290. */
  67291. /**
  67292. * Sets the current filter to "PCF" (percentage closer filtering).
  67293. */
  67294. usePercentageCloserFiltering: boolean;
  67295. private _filteringQuality;
  67296. /**
  67297. * Gets the PCF or PCSS Quality.
  67298. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67299. */
  67300. /**
  67301. * Sets the PCF or PCSS Quality.
  67302. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67303. */
  67304. filteringQuality: number;
  67305. /**
  67306. * Gets if the current filter is set to "PCSS" (contact hardening).
  67307. */
  67308. /**
  67309. * Sets the current filter to "PCSS" (contact hardening).
  67310. */
  67311. useContactHardeningShadow: boolean;
  67312. private _contactHardeningLightSizeUVRatio;
  67313. /**
  67314. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67315. * Using a ratio helps keeping shape stability independently of the map size.
  67316. *
  67317. * It does not account for the light projection as it was having too much
  67318. * instability during the light setup or during light position changes.
  67319. *
  67320. * Only valid if useContactHardeningShadow is true.
  67321. */
  67322. /**
  67323. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67324. * Using a ratio helps keeping shape stability independently of the map size.
  67325. *
  67326. * It does not account for the light projection as it was having too much
  67327. * instability during the light setup or during light position changes.
  67328. *
  67329. * Only valid if useContactHardeningShadow is true.
  67330. */
  67331. contactHardeningLightSizeUVRatio: number;
  67332. private _darkness;
  67333. /**
  67334. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67335. * 0 means strongest and 1 would means no shadow.
  67336. * @returns the darkness.
  67337. */
  67338. getDarkness(): number;
  67339. /**
  67340. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67341. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67342. * @returns the shadow generator allowing fluent coding.
  67343. */
  67344. setDarkness(darkness: number): ShadowGenerator;
  67345. private _transparencyShadow;
  67346. /**
  67347. * Sets the ability to have transparent shadow (boolean).
  67348. * @param transparent True if transparent else False
  67349. * @returns the shadow generator allowing fluent coding
  67350. */
  67351. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67352. private _shadowMap;
  67353. private _shadowMap2;
  67354. /**
  67355. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67356. * @returns The render target texture if present otherwise, null
  67357. */
  67358. getShadowMap(): Nullable<RenderTargetTexture>;
  67359. /**
  67360. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67361. * @returns The render target texture if the shadow map is present otherwise, null
  67362. */
  67363. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67364. /**
  67365. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67366. * @param mesh Mesh to add
  67367. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67368. * @returns the Shadow Generator itself
  67369. */
  67370. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67371. /**
  67372. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67373. * @param mesh Mesh to remove
  67374. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67375. * @returns the Shadow Generator itself
  67376. */
  67377. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67378. /**
  67379. * Controls the extent to which the shadows fade out at the edge of the frustum
  67380. * Used only by directionals and spots
  67381. */
  67382. frustumEdgeFalloff: number;
  67383. private _light;
  67384. /**
  67385. * Returns the associated light object.
  67386. * @returns the light generating the shadow
  67387. */
  67388. getLight(): IShadowLight;
  67389. /**
  67390. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67391. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67392. * It might on the other hand introduce peter panning.
  67393. */
  67394. forceBackFacesOnly: boolean;
  67395. private _scene;
  67396. private _lightDirection;
  67397. private _effect;
  67398. private _viewMatrix;
  67399. private _projectionMatrix;
  67400. private _transformMatrix;
  67401. private _cachedPosition;
  67402. private _cachedDirection;
  67403. private _cachedDefines;
  67404. private _currentRenderID;
  67405. private _boxBlurPostprocess;
  67406. private _kernelBlurXPostprocess;
  67407. private _kernelBlurYPostprocess;
  67408. private _blurPostProcesses;
  67409. private _mapSize;
  67410. private _currentFaceIndex;
  67411. private _currentFaceIndexCache;
  67412. private _textureType;
  67413. private _defaultTextureMatrix;
  67414. /** @hidden */
  67415. static _SceneComponentInitialization: (scene: Scene) => void;
  67416. /**
  67417. * Creates a ShadowGenerator object.
  67418. * A ShadowGenerator is the required tool to use the shadows.
  67419. * Each light casting shadows needs to use its own ShadowGenerator.
  67420. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67421. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67422. * @param light The light object generating the shadows.
  67423. * @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.
  67424. */
  67425. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67426. private _initializeGenerator;
  67427. private _initializeShadowMap;
  67428. private _initializeBlurRTTAndPostProcesses;
  67429. private _renderForShadowMap;
  67430. private _renderSubMeshForShadowMap;
  67431. private _applyFilterValues;
  67432. /**
  67433. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67434. * @param onCompiled Callback triggered at the and of the effects compilation
  67435. * @param options Sets of optional options forcing the compilation with different modes
  67436. */
  67437. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67438. useInstances: boolean;
  67439. }>): void;
  67440. /**
  67441. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67442. * @param options Sets of optional options forcing the compilation with different modes
  67443. * @returns A promise that resolves when the compilation completes
  67444. */
  67445. forceCompilationAsync(options?: Partial<{
  67446. useInstances: boolean;
  67447. }>): Promise<void>;
  67448. /**
  67449. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67450. * @param subMesh The submesh we want to render in the shadow map
  67451. * @param useInstances Defines wether will draw in the map using instances
  67452. * @returns true if ready otherwise, false
  67453. */
  67454. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67455. /**
  67456. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67457. * @param defines Defines of the material we want to update
  67458. * @param lightIndex Index of the light in the enabled light list of the material
  67459. */
  67460. prepareDefines(defines: any, lightIndex: number): void;
  67461. /**
  67462. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67463. * defined in the generator but impacting the effect).
  67464. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67465. * @param effect The effect we are binfing the information for
  67466. */
  67467. bindShadowLight(lightIndex: string, effect: Effect): void;
  67468. /**
  67469. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67470. * (eq to shadow prjection matrix * light transform matrix)
  67471. * @returns The transform matrix used to create the shadow map
  67472. */
  67473. getTransformMatrix(): Matrix;
  67474. /**
  67475. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67476. * Cube and 2D textures for instance.
  67477. */
  67478. recreateShadowMap(): void;
  67479. private _disposeBlurPostProcesses;
  67480. private _disposeRTTandPostProcesses;
  67481. /**
  67482. * Disposes the ShadowGenerator.
  67483. * Returns nothing.
  67484. */
  67485. dispose(): void;
  67486. /**
  67487. * Serializes the shadow generator setup to a json object.
  67488. * @returns The serialized JSON object
  67489. */
  67490. serialize(): any;
  67491. /**
  67492. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67493. * @param parsedShadowGenerator The JSON object to parse
  67494. * @param scene The scene to create the shadow map for
  67495. * @returns The parsed shadow generator
  67496. */
  67497. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67498. }
  67499. }
  67500. declare module BABYLON {
  67501. /**
  67502. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67503. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67504. * 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.
  67505. */
  67506. export abstract class Light extends Node {
  67507. /**
  67508. * Falloff Default: light is falling off following the material specification:
  67509. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67510. */
  67511. static readonly FALLOFF_DEFAULT: number;
  67512. /**
  67513. * Falloff Physical: light is falling off following the inverse squared distance law.
  67514. */
  67515. static readonly FALLOFF_PHYSICAL: number;
  67516. /**
  67517. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67518. * to enhance interoperability with other engines.
  67519. */
  67520. static readonly FALLOFF_GLTF: number;
  67521. /**
  67522. * Falloff Standard: light is falling off like in the standard material
  67523. * to enhance interoperability with other materials.
  67524. */
  67525. static readonly FALLOFF_STANDARD: number;
  67526. /**
  67527. * If every light affecting the material is in this lightmapMode,
  67528. * material.lightmapTexture adds or multiplies
  67529. * (depends on material.useLightmapAsShadowmap)
  67530. * after every other light calculations.
  67531. */
  67532. static readonly LIGHTMAP_DEFAULT: number;
  67533. /**
  67534. * material.lightmapTexture as only diffuse lighting from this light
  67535. * adds only specular lighting from this light
  67536. * adds dynamic shadows
  67537. */
  67538. static readonly LIGHTMAP_SPECULAR: number;
  67539. /**
  67540. * material.lightmapTexture as only lighting
  67541. * no light calculation from this light
  67542. * only adds dynamic shadows from this light
  67543. */
  67544. static readonly LIGHTMAP_SHADOWSONLY: number;
  67545. /**
  67546. * Each light type uses the default quantity according to its type:
  67547. * point/spot lights use luminous intensity
  67548. * directional lights use illuminance
  67549. */
  67550. static readonly INTENSITYMODE_AUTOMATIC: number;
  67551. /**
  67552. * lumen (lm)
  67553. */
  67554. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67555. /**
  67556. * candela (lm/sr)
  67557. */
  67558. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67559. /**
  67560. * lux (lm/m^2)
  67561. */
  67562. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67563. /**
  67564. * nit (cd/m^2)
  67565. */
  67566. static readonly INTENSITYMODE_LUMINANCE: number;
  67567. /**
  67568. * Light type const id of the point light.
  67569. */
  67570. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67571. /**
  67572. * Light type const id of the directional light.
  67573. */
  67574. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67575. /**
  67576. * Light type const id of the spot light.
  67577. */
  67578. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67579. /**
  67580. * Light type const id of the hemispheric light.
  67581. */
  67582. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67583. /**
  67584. * Diffuse gives the basic color to an object.
  67585. */
  67586. diffuse: Color3;
  67587. /**
  67588. * Specular produces a highlight color on an object.
  67589. * Note: This is note affecting PBR materials.
  67590. */
  67591. specular: Color3;
  67592. /**
  67593. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67594. * falling off base on range or angle.
  67595. * This can be set to any values in Light.FALLOFF_x.
  67596. *
  67597. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67598. * other types of materials.
  67599. */
  67600. falloffType: number;
  67601. /**
  67602. * Strength of the light.
  67603. * Note: By default it is define in the framework own unit.
  67604. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67605. */
  67606. intensity: number;
  67607. private _range;
  67608. protected _inverseSquaredRange: number;
  67609. /**
  67610. * Defines how far from the source the light is impacting in scene units.
  67611. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67612. */
  67613. /**
  67614. * Defines how far from the source the light is impacting in scene units.
  67615. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67616. */
  67617. range: number;
  67618. /**
  67619. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67620. * of light.
  67621. */
  67622. private _photometricScale;
  67623. private _intensityMode;
  67624. /**
  67625. * Gets the photometric scale used to interpret the intensity.
  67626. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67627. */
  67628. /**
  67629. * Sets the photometric scale used to interpret the intensity.
  67630. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67631. */
  67632. intensityMode: number;
  67633. private _radius;
  67634. /**
  67635. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67636. */
  67637. /**
  67638. * sets the light radius used by PBR Materials to simulate soft area lights.
  67639. */
  67640. radius: number;
  67641. private _renderPriority;
  67642. /**
  67643. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67644. * exceeding the number allowed of the materials.
  67645. */
  67646. renderPriority: number;
  67647. private _shadowEnabled;
  67648. /**
  67649. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67650. * the current shadow generator.
  67651. */
  67652. /**
  67653. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67654. * the current shadow generator.
  67655. */
  67656. shadowEnabled: boolean;
  67657. private _includedOnlyMeshes;
  67658. /**
  67659. * Gets the only meshes impacted by this light.
  67660. */
  67661. /**
  67662. * Sets the only meshes impacted by this light.
  67663. */
  67664. includedOnlyMeshes: AbstractMesh[];
  67665. private _excludedMeshes;
  67666. /**
  67667. * Gets the meshes not impacted by this light.
  67668. */
  67669. /**
  67670. * Sets the meshes not impacted by this light.
  67671. */
  67672. excludedMeshes: AbstractMesh[];
  67673. private _excludeWithLayerMask;
  67674. /**
  67675. * Gets the layer id use to find what meshes are not impacted by the light.
  67676. * Inactive if 0
  67677. */
  67678. /**
  67679. * Sets the layer id use to find what meshes are not impacted by the light.
  67680. * Inactive if 0
  67681. */
  67682. excludeWithLayerMask: number;
  67683. private _includeOnlyWithLayerMask;
  67684. /**
  67685. * Gets the layer id use to find what meshes are impacted by the light.
  67686. * Inactive if 0
  67687. */
  67688. /**
  67689. * Sets the layer id use to find what meshes are impacted by the light.
  67690. * Inactive if 0
  67691. */
  67692. includeOnlyWithLayerMask: number;
  67693. private _lightmapMode;
  67694. /**
  67695. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67696. */
  67697. /**
  67698. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67699. */
  67700. lightmapMode: number;
  67701. /**
  67702. * Shadow generator associted to the light.
  67703. * @hidden Internal use only.
  67704. */
  67705. _shadowGenerator: Nullable<IShadowGenerator>;
  67706. /**
  67707. * @hidden Internal use only.
  67708. */
  67709. _excludedMeshesIds: string[];
  67710. /**
  67711. * @hidden Internal use only.
  67712. */
  67713. _includedOnlyMeshesIds: string[];
  67714. /**
  67715. * The current light unifom buffer.
  67716. * @hidden Internal use only.
  67717. */
  67718. _uniformBuffer: UniformBuffer;
  67719. /**
  67720. * Creates a Light object in the scene.
  67721. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67722. * @param name The firendly name of the light
  67723. * @param scene The scene the light belongs too
  67724. */
  67725. constructor(name: string, scene: Scene);
  67726. protected abstract _buildUniformLayout(): void;
  67727. /**
  67728. * Sets the passed Effect "effect" with the Light information.
  67729. * @param effect The effect to update
  67730. * @param lightIndex The index of the light in the effect to update
  67731. * @returns The light
  67732. */
  67733. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67734. /**
  67735. * Returns the string "Light".
  67736. * @returns the class name
  67737. */
  67738. getClassName(): string;
  67739. /** @hidden */
  67740. readonly _isLight: boolean;
  67741. /**
  67742. * Converts the light information to a readable string for debug purpose.
  67743. * @param fullDetails Supports for multiple levels of logging within scene loading
  67744. * @returns the human readable light info
  67745. */
  67746. toString(fullDetails?: boolean): string;
  67747. /** @hidden */
  67748. protected _syncParentEnabledState(): void;
  67749. /**
  67750. * Set the enabled state of this node.
  67751. * @param value - the new enabled state
  67752. */
  67753. setEnabled(value: boolean): void;
  67754. /**
  67755. * Returns the Light associated shadow generator if any.
  67756. * @return the associated shadow generator.
  67757. */
  67758. getShadowGenerator(): Nullable<IShadowGenerator>;
  67759. /**
  67760. * Returns a Vector3, the absolute light position in the World.
  67761. * @returns the world space position of the light
  67762. */
  67763. getAbsolutePosition(): Vector3;
  67764. /**
  67765. * Specifies if the light will affect the passed mesh.
  67766. * @param mesh The mesh to test against the light
  67767. * @return true the mesh is affected otherwise, false.
  67768. */
  67769. canAffectMesh(mesh: AbstractMesh): boolean;
  67770. /**
  67771. * Sort function to order lights for rendering.
  67772. * @param a First Light object to compare to second.
  67773. * @param b Second Light object to compare first.
  67774. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67775. */
  67776. static CompareLightsPriority(a: Light, b: Light): number;
  67777. /**
  67778. * Releases resources associated with this node.
  67779. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67780. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67781. */
  67782. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67783. /**
  67784. * Returns the light type ID (integer).
  67785. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67786. */
  67787. getTypeID(): number;
  67788. /**
  67789. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67790. * @returns the scaled intensity in intensity mode unit
  67791. */
  67792. getScaledIntensity(): number;
  67793. /**
  67794. * Returns a new Light object, named "name", from the current one.
  67795. * @param name The name of the cloned light
  67796. * @returns the new created light
  67797. */
  67798. clone(name: string): Nullable<Light>;
  67799. /**
  67800. * Serializes the current light into a Serialization object.
  67801. * @returns the serialized object.
  67802. */
  67803. serialize(): any;
  67804. /**
  67805. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67806. * This new light is named "name" and added to the passed scene.
  67807. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67808. * @param name The friendly name of the light
  67809. * @param scene The scene the new light will belong to
  67810. * @returns the constructor function
  67811. */
  67812. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67813. /**
  67814. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67815. * @param parsedLight The JSON representation of the light
  67816. * @param scene The scene to create the parsed light in
  67817. * @returns the created light after parsing
  67818. */
  67819. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67820. private _hookArrayForExcluded;
  67821. private _hookArrayForIncludedOnly;
  67822. private _resyncMeshes;
  67823. /**
  67824. * Forces the meshes to update their light related information in their rendering used effects
  67825. * @hidden Internal Use Only
  67826. */
  67827. _markMeshesAsLightDirty(): void;
  67828. /**
  67829. * Recomputes the cached photometric scale if needed.
  67830. */
  67831. private _computePhotometricScale;
  67832. /**
  67833. * Returns the Photometric Scale according to the light type and intensity mode.
  67834. */
  67835. private _getPhotometricScale;
  67836. /**
  67837. * Reorder the light in the scene according to their defined priority.
  67838. * @hidden Internal Use Only
  67839. */
  67840. _reorderLightsInScene(): void;
  67841. /**
  67842. * Prepares the list of defines specific to the light type.
  67843. * @param defines the list of defines
  67844. * @param lightIndex defines the index of the light for the effect
  67845. */
  67846. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67847. }
  67848. }
  67849. declare module BABYLON {
  67850. /**
  67851. * Interface used to define Action
  67852. */
  67853. export interface IAction {
  67854. /**
  67855. * Trigger for the action
  67856. */
  67857. trigger: number;
  67858. /** Options of the trigger */
  67859. triggerOptions: any;
  67860. /**
  67861. * Gets the trigger parameters
  67862. * @returns the trigger parameters
  67863. */
  67864. getTriggerParameter(): any;
  67865. /**
  67866. * Internal only - executes current action event
  67867. * @hidden
  67868. */
  67869. _executeCurrent(evt?: ActionEvent): void;
  67870. /**
  67871. * Serialize placeholder for child classes
  67872. * @param parent of child
  67873. * @returns the serialized object
  67874. */
  67875. serialize(parent: any): any;
  67876. /**
  67877. * Internal only
  67878. * @hidden
  67879. */
  67880. _prepare(): void;
  67881. /**
  67882. * Internal only - manager for action
  67883. * @hidden
  67884. */
  67885. _actionManager: AbstractActionManager;
  67886. }
  67887. /**
  67888. * The action to be carried out following a trigger
  67889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67890. */
  67891. export class Action implements IAction {
  67892. /** the trigger, with or without parameters, for the action */
  67893. triggerOptions: any;
  67894. /**
  67895. * Trigger for the action
  67896. */
  67897. trigger: number;
  67898. /**
  67899. * Internal only - manager for action
  67900. * @hidden
  67901. */
  67902. _actionManager: ActionManager;
  67903. private _nextActiveAction;
  67904. private _child;
  67905. private _condition?;
  67906. private _triggerParameter;
  67907. /**
  67908. * An event triggered prior to action being executed.
  67909. */
  67910. onBeforeExecuteObservable: Observable<Action>;
  67911. /**
  67912. * Creates a new Action
  67913. * @param triggerOptions the trigger, with or without parameters, for the action
  67914. * @param condition an optional determinant of action
  67915. */
  67916. constructor(
  67917. /** the trigger, with or without parameters, for the action */
  67918. triggerOptions: any, condition?: Condition);
  67919. /**
  67920. * Internal only
  67921. * @hidden
  67922. */
  67923. _prepare(): void;
  67924. /**
  67925. * Gets the trigger parameters
  67926. * @returns the trigger parameters
  67927. */
  67928. getTriggerParameter(): any;
  67929. /**
  67930. * Internal only - executes current action event
  67931. * @hidden
  67932. */
  67933. _executeCurrent(evt?: ActionEvent): void;
  67934. /**
  67935. * Execute placeholder for child classes
  67936. * @param evt optional action event
  67937. */
  67938. execute(evt?: ActionEvent): void;
  67939. /**
  67940. * Skips to next active action
  67941. */
  67942. skipToNextActiveAction(): void;
  67943. /**
  67944. * Adds action to chain of actions, may be a DoNothingAction
  67945. * @param action defines the next action to execute
  67946. * @returns The action passed in
  67947. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67948. */
  67949. then(action: Action): Action;
  67950. /**
  67951. * Internal only
  67952. * @hidden
  67953. */
  67954. _getProperty(propertyPath: string): string;
  67955. /**
  67956. * Internal only
  67957. * @hidden
  67958. */
  67959. _getEffectiveTarget(target: any, propertyPath: string): any;
  67960. /**
  67961. * Serialize placeholder for child classes
  67962. * @param parent of child
  67963. * @returns the serialized object
  67964. */
  67965. serialize(parent: any): any;
  67966. /**
  67967. * Internal only called by serialize
  67968. * @hidden
  67969. */
  67970. protected _serialize(serializedAction: any, parent?: any): any;
  67971. /**
  67972. * Internal only
  67973. * @hidden
  67974. */
  67975. static _SerializeValueAsString: (value: any) => string;
  67976. /**
  67977. * Internal only
  67978. * @hidden
  67979. */
  67980. static _GetTargetProperty: (target: Scene | Node) => {
  67981. name: string;
  67982. targetType: string;
  67983. value: string;
  67984. };
  67985. }
  67986. }
  67987. declare module BABYLON {
  67988. /**
  67989. * A Condition applied to an Action
  67990. */
  67991. export class Condition {
  67992. /**
  67993. * Internal only - manager for action
  67994. * @hidden
  67995. */
  67996. _actionManager: ActionManager;
  67997. /**
  67998. * Internal only
  67999. * @hidden
  68000. */
  68001. _evaluationId: number;
  68002. /**
  68003. * Internal only
  68004. * @hidden
  68005. */
  68006. _currentResult: boolean;
  68007. /**
  68008. * Creates a new Condition
  68009. * @param actionManager the manager of the action the condition is applied to
  68010. */
  68011. constructor(actionManager: ActionManager);
  68012. /**
  68013. * Check if the current condition is valid
  68014. * @returns a boolean
  68015. */
  68016. isValid(): boolean;
  68017. /**
  68018. * Internal only
  68019. * @hidden
  68020. */
  68021. _getProperty(propertyPath: string): string;
  68022. /**
  68023. * Internal only
  68024. * @hidden
  68025. */
  68026. _getEffectiveTarget(target: any, propertyPath: string): any;
  68027. /**
  68028. * Serialize placeholder for child classes
  68029. * @returns the serialized object
  68030. */
  68031. serialize(): any;
  68032. /**
  68033. * Internal only
  68034. * @hidden
  68035. */
  68036. protected _serialize(serializedCondition: any): any;
  68037. }
  68038. /**
  68039. * Defines specific conditional operators as extensions of Condition
  68040. */
  68041. export class ValueCondition extends Condition {
  68042. /** path to specify the property of the target the conditional operator uses */
  68043. propertyPath: string;
  68044. /** the value compared by the conditional operator against the current value of the property */
  68045. value: any;
  68046. /** the conditional operator, default ValueCondition.IsEqual */
  68047. operator: number;
  68048. /**
  68049. * Internal only
  68050. * @hidden
  68051. */
  68052. private static _IsEqual;
  68053. /**
  68054. * Internal only
  68055. * @hidden
  68056. */
  68057. private static _IsDifferent;
  68058. /**
  68059. * Internal only
  68060. * @hidden
  68061. */
  68062. private static _IsGreater;
  68063. /**
  68064. * Internal only
  68065. * @hidden
  68066. */
  68067. private static _IsLesser;
  68068. /**
  68069. * returns the number for IsEqual
  68070. */
  68071. static readonly IsEqual: number;
  68072. /**
  68073. * Returns the number for IsDifferent
  68074. */
  68075. static readonly IsDifferent: number;
  68076. /**
  68077. * Returns the number for IsGreater
  68078. */
  68079. static readonly IsGreater: number;
  68080. /**
  68081. * Returns the number for IsLesser
  68082. */
  68083. static readonly IsLesser: number;
  68084. /**
  68085. * Internal only The action manager for the condition
  68086. * @hidden
  68087. */
  68088. _actionManager: ActionManager;
  68089. /**
  68090. * Internal only
  68091. * @hidden
  68092. */
  68093. private _target;
  68094. /**
  68095. * Internal only
  68096. * @hidden
  68097. */
  68098. private _effectiveTarget;
  68099. /**
  68100. * Internal only
  68101. * @hidden
  68102. */
  68103. private _property;
  68104. /**
  68105. * Creates a new ValueCondition
  68106. * @param actionManager manager for the action the condition applies to
  68107. * @param target for the action
  68108. * @param propertyPath path to specify the property of the target the conditional operator uses
  68109. * @param value the value compared by the conditional operator against the current value of the property
  68110. * @param operator the conditional operator, default ValueCondition.IsEqual
  68111. */
  68112. constructor(actionManager: ActionManager, target: any,
  68113. /** path to specify the property of the target the conditional operator uses */
  68114. propertyPath: string,
  68115. /** the value compared by the conditional operator against the current value of the property */
  68116. value: any,
  68117. /** the conditional operator, default ValueCondition.IsEqual */
  68118. operator?: number);
  68119. /**
  68120. * Compares the given value with the property value for the specified conditional operator
  68121. * @returns the result of the comparison
  68122. */
  68123. isValid(): boolean;
  68124. /**
  68125. * Serialize the ValueCondition into a JSON compatible object
  68126. * @returns serialization object
  68127. */
  68128. serialize(): any;
  68129. /**
  68130. * Gets the name of the conditional operator for the ValueCondition
  68131. * @param operator the conditional operator
  68132. * @returns the name
  68133. */
  68134. static GetOperatorName(operator: number): string;
  68135. }
  68136. /**
  68137. * Defines a predicate condition as an extension of Condition
  68138. */
  68139. export class PredicateCondition extends Condition {
  68140. /** defines the predicate function used to validate the condition */
  68141. predicate: () => boolean;
  68142. /**
  68143. * Internal only - manager for action
  68144. * @hidden
  68145. */
  68146. _actionManager: ActionManager;
  68147. /**
  68148. * Creates a new PredicateCondition
  68149. * @param actionManager manager for the action the condition applies to
  68150. * @param predicate defines the predicate function used to validate the condition
  68151. */
  68152. constructor(actionManager: ActionManager,
  68153. /** defines the predicate function used to validate the condition */
  68154. predicate: () => boolean);
  68155. /**
  68156. * @returns the validity of the predicate condition
  68157. */
  68158. isValid(): boolean;
  68159. }
  68160. /**
  68161. * Defines a state condition as an extension of Condition
  68162. */
  68163. export class StateCondition extends Condition {
  68164. /** Value to compare with target state */
  68165. value: string;
  68166. /**
  68167. * Internal only - manager for action
  68168. * @hidden
  68169. */
  68170. _actionManager: ActionManager;
  68171. /**
  68172. * Internal only
  68173. * @hidden
  68174. */
  68175. private _target;
  68176. /**
  68177. * Creates a new StateCondition
  68178. * @param actionManager manager for the action the condition applies to
  68179. * @param target of the condition
  68180. * @param value to compare with target state
  68181. */
  68182. constructor(actionManager: ActionManager, target: any,
  68183. /** Value to compare with target state */
  68184. value: string);
  68185. /**
  68186. * Gets a boolean indicating if the current condition is met
  68187. * @returns the validity of the state
  68188. */
  68189. isValid(): boolean;
  68190. /**
  68191. * Serialize the StateCondition into a JSON compatible object
  68192. * @returns serialization object
  68193. */
  68194. serialize(): any;
  68195. }
  68196. }
  68197. declare module BABYLON {
  68198. /**
  68199. * This defines an action responsible to toggle a boolean once triggered.
  68200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68201. */
  68202. export class SwitchBooleanAction extends Action {
  68203. /**
  68204. * The path to the boolean property in the target object
  68205. */
  68206. propertyPath: string;
  68207. private _target;
  68208. private _effectiveTarget;
  68209. private _property;
  68210. /**
  68211. * Instantiate the action
  68212. * @param triggerOptions defines the trigger options
  68213. * @param target defines the object containing the boolean
  68214. * @param propertyPath defines the path to the boolean property in the target object
  68215. * @param condition defines the trigger related conditions
  68216. */
  68217. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  68218. /** @hidden */
  68219. _prepare(): void;
  68220. /**
  68221. * Execute the action toggle the boolean value.
  68222. */
  68223. execute(): void;
  68224. /**
  68225. * Serializes the actions and its related information.
  68226. * @param parent defines the object to serialize in
  68227. * @returns the serialized object
  68228. */
  68229. serialize(parent: any): any;
  68230. }
  68231. /**
  68232. * This defines an action responsible to set a the state field of the target
  68233. * to a desired value once triggered.
  68234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68235. */
  68236. export class SetStateAction extends Action {
  68237. /**
  68238. * The value to store in the state field.
  68239. */
  68240. value: string;
  68241. private _target;
  68242. /**
  68243. * Instantiate the action
  68244. * @param triggerOptions defines the trigger options
  68245. * @param target defines the object containing the state property
  68246. * @param value defines the value to store in the state field
  68247. * @param condition defines the trigger related conditions
  68248. */
  68249. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68250. /**
  68251. * Execute the action and store the value on the target state property.
  68252. */
  68253. execute(): void;
  68254. /**
  68255. * Serializes the actions and its related information.
  68256. * @param parent defines the object to serialize in
  68257. * @returns the serialized object
  68258. */
  68259. serialize(parent: any): any;
  68260. }
  68261. /**
  68262. * This defines an action responsible to set a property of the target
  68263. * to a desired value once triggered.
  68264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68265. */
  68266. export class SetValueAction extends Action {
  68267. /**
  68268. * The path of the property to set in the target.
  68269. */
  68270. propertyPath: string;
  68271. /**
  68272. * The value to set in the property
  68273. */
  68274. value: any;
  68275. private _target;
  68276. private _effectiveTarget;
  68277. private _property;
  68278. /**
  68279. * Instantiate the action
  68280. * @param triggerOptions defines the trigger options
  68281. * @param target defines the object containing the property
  68282. * @param propertyPath defines the path of the property to set in the target
  68283. * @param value defines the value to set in the property
  68284. * @param condition defines the trigger related conditions
  68285. */
  68286. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68287. /** @hidden */
  68288. _prepare(): void;
  68289. /**
  68290. * Execute the action and set the targetted property to the desired value.
  68291. */
  68292. execute(): void;
  68293. /**
  68294. * Serializes the actions and its related information.
  68295. * @param parent defines the object to serialize in
  68296. * @returns the serialized object
  68297. */
  68298. serialize(parent: any): any;
  68299. }
  68300. /**
  68301. * This defines an action responsible to increment the target value
  68302. * to a desired value once triggered.
  68303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68304. */
  68305. export class IncrementValueAction extends Action {
  68306. /**
  68307. * The path of the property to increment in the target.
  68308. */
  68309. propertyPath: string;
  68310. /**
  68311. * The value we should increment the property by.
  68312. */
  68313. value: any;
  68314. private _target;
  68315. private _effectiveTarget;
  68316. private _property;
  68317. /**
  68318. * Instantiate the action
  68319. * @param triggerOptions defines the trigger options
  68320. * @param target defines the object containing the property
  68321. * @param propertyPath defines the path of the property to increment in the target
  68322. * @param value defines the value value we should increment the property by
  68323. * @param condition defines the trigger related conditions
  68324. */
  68325. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68326. /** @hidden */
  68327. _prepare(): void;
  68328. /**
  68329. * Execute the action and increment the target of the value amount.
  68330. */
  68331. execute(): void;
  68332. /**
  68333. * Serializes the actions and its related information.
  68334. * @param parent defines the object to serialize in
  68335. * @returns the serialized object
  68336. */
  68337. serialize(parent: any): any;
  68338. }
  68339. /**
  68340. * This defines an action responsible to start an animation once triggered.
  68341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68342. */
  68343. export class PlayAnimationAction extends Action {
  68344. /**
  68345. * Where the animation should start (animation frame)
  68346. */
  68347. from: number;
  68348. /**
  68349. * Where the animation should stop (animation frame)
  68350. */
  68351. to: number;
  68352. /**
  68353. * Define if the animation should loop or stop after the first play.
  68354. */
  68355. loop?: boolean;
  68356. private _target;
  68357. /**
  68358. * Instantiate the action
  68359. * @param triggerOptions defines the trigger options
  68360. * @param target defines the target animation or animation name
  68361. * @param from defines from where the animation should start (animation frame)
  68362. * @param end defines where the animation should stop (animation frame)
  68363. * @param loop defines if the animation should loop or stop after the first play
  68364. * @param condition defines the trigger related conditions
  68365. */
  68366. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68367. /** @hidden */
  68368. _prepare(): void;
  68369. /**
  68370. * Execute the action and play the animation.
  68371. */
  68372. execute(): void;
  68373. /**
  68374. * Serializes the actions and its related information.
  68375. * @param parent defines the object to serialize in
  68376. * @returns the serialized object
  68377. */
  68378. serialize(parent: any): any;
  68379. }
  68380. /**
  68381. * This defines an action responsible to stop an animation once triggered.
  68382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68383. */
  68384. export class StopAnimationAction extends Action {
  68385. private _target;
  68386. /**
  68387. * Instantiate the action
  68388. * @param triggerOptions defines the trigger options
  68389. * @param target defines the target animation or animation name
  68390. * @param condition defines the trigger related conditions
  68391. */
  68392. constructor(triggerOptions: any, target: any, condition?: Condition);
  68393. /** @hidden */
  68394. _prepare(): void;
  68395. /**
  68396. * Execute the action and stop the animation.
  68397. */
  68398. execute(): void;
  68399. /**
  68400. * Serializes the actions and its related information.
  68401. * @param parent defines the object to serialize in
  68402. * @returns the serialized object
  68403. */
  68404. serialize(parent: any): any;
  68405. }
  68406. /**
  68407. * This defines an action responsible that does nothing once triggered.
  68408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68409. */
  68410. export class DoNothingAction extends Action {
  68411. /**
  68412. * Instantiate the action
  68413. * @param triggerOptions defines the trigger options
  68414. * @param condition defines the trigger related conditions
  68415. */
  68416. constructor(triggerOptions?: any, condition?: Condition);
  68417. /**
  68418. * Execute the action and do nothing.
  68419. */
  68420. execute(): void;
  68421. /**
  68422. * Serializes the actions and its related information.
  68423. * @param parent defines the object to serialize in
  68424. * @returns the serialized object
  68425. */
  68426. serialize(parent: any): any;
  68427. }
  68428. /**
  68429. * This defines an action responsible to trigger several actions once triggered.
  68430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68431. */
  68432. export class CombineAction extends Action {
  68433. /**
  68434. * The list of aggregated animations to run.
  68435. */
  68436. children: Action[];
  68437. /**
  68438. * Instantiate the action
  68439. * @param triggerOptions defines the trigger options
  68440. * @param children defines the list of aggregated animations to run
  68441. * @param condition defines the trigger related conditions
  68442. */
  68443. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68444. /** @hidden */
  68445. _prepare(): void;
  68446. /**
  68447. * Execute the action and executes all the aggregated actions.
  68448. */
  68449. execute(evt: ActionEvent): void;
  68450. /**
  68451. * Serializes the actions and its related information.
  68452. * @param parent defines the object to serialize in
  68453. * @returns the serialized object
  68454. */
  68455. serialize(parent: any): any;
  68456. }
  68457. /**
  68458. * This defines an action responsible to run code (external event) once triggered.
  68459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68460. */
  68461. export class ExecuteCodeAction extends Action {
  68462. /**
  68463. * The callback function to run.
  68464. */
  68465. func: (evt: ActionEvent) => void;
  68466. /**
  68467. * Instantiate the action
  68468. * @param triggerOptions defines the trigger options
  68469. * @param func defines the callback function to run
  68470. * @param condition defines the trigger related conditions
  68471. */
  68472. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68473. /**
  68474. * Execute the action and run the attached code.
  68475. */
  68476. execute(evt: ActionEvent): void;
  68477. }
  68478. /**
  68479. * This defines an action responsible to set the parent property of the target once triggered.
  68480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68481. */
  68482. export class SetParentAction extends Action {
  68483. private _parent;
  68484. private _target;
  68485. /**
  68486. * Instantiate the action
  68487. * @param triggerOptions defines the trigger options
  68488. * @param target defines the target containing the parent property
  68489. * @param parent defines from where the animation should start (animation frame)
  68490. * @param condition defines the trigger related conditions
  68491. */
  68492. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68493. /** @hidden */
  68494. _prepare(): void;
  68495. /**
  68496. * Execute the action and set the parent property.
  68497. */
  68498. execute(): void;
  68499. /**
  68500. * Serializes the actions and its related information.
  68501. * @param parent defines the object to serialize in
  68502. * @returns the serialized object
  68503. */
  68504. serialize(parent: any): any;
  68505. }
  68506. }
  68507. declare module BABYLON {
  68508. /**
  68509. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68510. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68512. */
  68513. export class ActionManager extends AbstractActionManager {
  68514. /**
  68515. * Nothing
  68516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68517. */
  68518. static readonly NothingTrigger: number;
  68519. /**
  68520. * On pick
  68521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68522. */
  68523. static readonly OnPickTrigger: number;
  68524. /**
  68525. * On left pick
  68526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68527. */
  68528. static readonly OnLeftPickTrigger: number;
  68529. /**
  68530. * On right pick
  68531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68532. */
  68533. static readonly OnRightPickTrigger: number;
  68534. /**
  68535. * On center pick
  68536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68537. */
  68538. static readonly OnCenterPickTrigger: number;
  68539. /**
  68540. * On pick down
  68541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68542. */
  68543. static readonly OnPickDownTrigger: number;
  68544. /**
  68545. * On double pick
  68546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68547. */
  68548. static readonly OnDoublePickTrigger: number;
  68549. /**
  68550. * On pick up
  68551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68552. */
  68553. static readonly OnPickUpTrigger: number;
  68554. /**
  68555. * On pick out.
  68556. * This trigger will only be raised if you also declared a OnPickDown
  68557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68558. */
  68559. static readonly OnPickOutTrigger: number;
  68560. /**
  68561. * On long press
  68562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68563. */
  68564. static readonly OnLongPressTrigger: number;
  68565. /**
  68566. * On pointer over
  68567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68568. */
  68569. static readonly OnPointerOverTrigger: number;
  68570. /**
  68571. * On pointer out
  68572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68573. */
  68574. static readonly OnPointerOutTrigger: number;
  68575. /**
  68576. * On every frame
  68577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68578. */
  68579. static readonly OnEveryFrameTrigger: number;
  68580. /**
  68581. * On intersection enter
  68582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68583. */
  68584. static readonly OnIntersectionEnterTrigger: number;
  68585. /**
  68586. * On intersection exit
  68587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68588. */
  68589. static readonly OnIntersectionExitTrigger: number;
  68590. /**
  68591. * On key down
  68592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68593. */
  68594. static readonly OnKeyDownTrigger: number;
  68595. /**
  68596. * On key up
  68597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68598. */
  68599. static readonly OnKeyUpTrigger: number;
  68600. private _scene;
  68601. /**
  68602. * Creates a new action manager
  68603. * @param scene defines the hosting scene
  68604. */
  68605. constructor(scene: Scene);
  68606. /**
  68607. * Releases all associated resources
  68608. */
  68609. dispose(): void;
  68610. /**
  68611. * Gets hosting scene
  68612. * @returns the hosting scene
  68613. */
  68614. getScene(): Scene;
  68615. /**
  68616. * Does this action manager handles actions of any of the given triggers
  68617. * @param triggers defines the triggers to be tested
  68618. * @return a boolean indicating whether one (or more) of the triggers is handled
  68619. */
  68620. hasSpecificTriggers(triggers: number[]): boolean;
  68621. /**
  68622. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68623. * speed.
  68624. * @param triggerA defines the trigger to be tested
  68625. * @param triggerB defines the trigger to be tested
  68626. * @return a boolean indicating whether one (or more) of the triggers is handled
  68627. */
  68628. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68629. /**
  68630. * Does this action manager handles actions of a given trigger
  68631. * @param trigger defines the trigger to be tested
  68632. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68633. * @return whether the trigger is handled
  68634. */
  68635. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68636. /**
  68637. * Does this action manager has pointer triggers
  68638. */
  68639. readonly hasPointerTriggers: boolean;
  68640. /**
  68641. * Does this action manager has pick triggers
  68642. */
  68643. readonly hasPickTriggers: boolean;
  68644. /**
  68645. * Registers an action to this action manager
  68646. * @param action defines the action to be registered
  68647. * @return the action amended (prepared) after registration
  68648. */
  68649. registerAction(action: IAction): Nullable<IAction>;
  68650. /**
  68651. * Unregisters an action to this action manager
  68652. * @param action defines the action to be unregistered
  68653. * @return a boolean indicating whether the action has been unregistered
  68654. */
  68655. unregisterAction(action: IAction): Boolean;
  68656. /**
  68657. * Process a specific trigger
  68658. * @param trigger defines the trigger to process
  68659. * @param evt defines the event details to be processed
  68660. */
  68661. processTrigger(trigger: number, evt?: IActionEvent): void;
  68662. /** @hidden */
  68663. _getEffectiveTarget(target: any, propertyPath: string): any;
  68664. /** @hidden */
  68665. _getProperty(propertyPath: string): string;
  68666. /**
  68667. * Serialize this manager to a JSON object
  68668. * @param name defines the property name to store this manager
  68669. * @returns a JSON representation of this manager
  68670. */
  68671. serialize(name: string): any;
  68672. /**
  68673. * Creates a new ActionManager from a JSON data
  68674. * @param parsedActions defines the JSON data to read from
  68675. * @param object defines the hosting mesh
  68676. * @param scene defines the hosting scene
  68677. */
  68678. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68679. /**
  68680. * Get a trigger name by index
  68681. * @param trigger defines the trigger index
  68682. * @returns a trigger name
  68683. */
  68684. static GetTriggerName(trigger: number): string;
  68685. }
  68686. }
  68687. declare module BABYLON {
  68688. /**
  68689. * Class representing a ray with position and direction
  68690. */
  68691. export class Ray {
  68692. /** origin point */
  68693. origin: Vector3;
  68694. /** direction */
  68695. direction: Vector3;
  68696. /** length of the ray */
  68697. length: number;
  68698. private static readonly TmpVector3;
  68699. private _tmpRay;
  68700. /**
  68701. * Creates a new ray
  68702. * @param origin origin point
  68703. * @param direction direction
  68704. * @param length length of the ray
  68705. */
  68706. constructor(
  68707. /** origin point */
  68708. origin: Vector3,
  68709. /** direction */
  68710. direction: Vector3,
  68711. /** length of the ray */
  68712. length?: number);
  68713. /**
  68714. * Checks if the ray intersects a box
  68715. * @param minimum bound of the box
  68716. * @param maximum bound of the box
  68717. * @param intersectionTreshold extra extend to be added to the box in all direction
  68718. * @returns if the box was hit
  68719. */
  68720. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68721. /**
  68722. * Checks if the ray intersects a box
  68723. * @param box the bounding box to check
  68724. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68725. * @returns if the box was hit
  68726. */
  68727. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68728. /**
  68729. * If the ray hits a sphere
  68730. * @param sphere the bounding sphere to check
  68731. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68732. * @returns true if it hits the sphere
  68733. */
  68734. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68735. /**
  68736. * If the ray hits a triange
  68737. * @param vertex0 triangle vertex
  68738. * @param vertex1 triangle vertex
  68739. * @param vertex2 triangle vertex
  68740. * @returns intersection information if hit
  68741. */
  68742. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68743. /**
  68744. * Checks if ray intersects a plane
  68745. * @param plane the plane to check
  68746. * @returns the distance away it was hit
  68747. */
  68748. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68749. /**
  68750. * Checks if ray intersects a mesh
  68751. * @param mesh the mesh to check
  68752. * @param fastCheck if only the bounding box should checked
  68753. * @returns picking info of the intersecton
  68754. */
  68755. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68756. /**
  68757. * Checks if ray intersects a mesh
  68758. * @param meshes the meshes to check
  68759. * @param fastCheck if only the bounding box should checked
  68760. * @param results array to store result in
  68761. * @returns Array of picking infos
  68762. */
  68763. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68764. private _comparePickingInfo;
  68765. private static smallnum;
  68766. private static rayl;
  68767. /**
  68768. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68769. * @param sega the first point of the segment to test the intersection against
  68770. * @param segb the second point of the segment to test the intersection against
  68771. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68772. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68773. */
  68774. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68775. /**
  68776. * Update the ray from viewport position
  68777. * @param x position
  68778. * @param y y position
  68779. * @param viewportWidth viewport width
  68780. * @param viewportHeight viewport height
  68781. * @param world world matrix
  68782. * @param view view matrix
  68783. * @param projection projection matrix
  68784. * @returns this ray updated
  68785. */
  68786. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68787. /**
  68788. * Creates a ray with origin and direction of 0,0,0
  68789. * @returns the new ray
  68790. */
  68791. static Zero(): Ray;
  68792. /**
  68793. * Creates a new ray from screen space and viewport
  68794. * @param x position
  68795. * @param y y position
  68796. * @param viewportWidth viewport width
  68797. * @param viewportHeight viewport height
  68798. * @param world world matrix
  68799. * @param view view matrix
  68800. * @param projection projection matrix
  68801. * @returns new ray
  68802. */
  68803. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68804. /**
  68805. * 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
  68806. * transformed to the given world matrix.
  68807. * @param origin The origin point
  68808. * @param end The end point
  68809. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68810. * @returns the new ray
  68811. */
  68812. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68813. /**
  68814. * Transforms a ray by a matrix
  68815. * @param ray ray to transform
  68816. * @param matrix matrix to apply
  68817. * @returns the resulting new ray
  68818. */
  68819. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68820. /**
  68821. * Transforms a ray by a matrix
  68822. * @param ray ray to transform
  68823. * @param matrix matrix to apply
  68824. * @param result ray to store result in
  68825. */
  68826. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68827. /**
  68828. * Unproject a ray from screen space to object space
  68829. * @param sourceX defines the screen space x coordinate to use
  68830. * @param sourceY defines the screen space y coordinate to use
  68831. * @param viewportWidth defines the current width of the viewport
  68832. * @param viewportHeight defines the current height of the viewport
  68833. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68834. * @param view defines the view matrix to use
  68835. * @param projection defines the projection matrix to use
  68836. */
  68837. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68838. }
  68839. /**
  68840. * Type used to define predicate used to select faces when a mesh intersection is detected
  68841. */
  68842. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  68843. interface Scene {
  68844. /** @hidden */
  68845. _tempPickingRay: Nullable<Ray>;
  68846. /** @hidden */
  68847. _cachedRayForTransform: Ray;
  68848. /** @hidden */
  68849. _pickWithRayInverseMatrix: Matrix;
  68850. /** @hidden */
  68851. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  68852. /** @hidden */
  68853. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  68854. }
  68855. }
  68856. declare module BABYLON {
  68857. /**
  68858. * Groups all the scene component constants in one place to ease maintenance.
  68859. * @hidden
  68860. */
  68861. export class SceneComponentConstants {
  68862. static readonly NAME_EFFECTLAYER: string;
  68863. static readonly NAME_LAYER: string;
  68864. static readonly NAME_LENSFLARESYSTEM: string;
  68865. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68866. static readonly NAME_PARTICLESYSTEM: string;
  68867. static readonly NAME_GAMEPAD: string;
  68868. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68869. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68870. static readonly NAME_DEPTHRENDERER: string;
  68871. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68872. static readonly NAME_SPRITE: string;
  68873. static readonly NAME_OUTLINERENDERER: string;
  68874. static readonly NAME_PROCEDURALTEXTURE: string;
  68875. static readonly NAME_SHADOWGENERATOR: string;
  68876. static readonly NAME_OCTREE: string;
  68877. static readonly NAME_PHYSICSENGINE: string;
  68878. static readonly NAME_AUDIO: string;
  68879. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68880. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68881. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68882. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68883. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68884. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68885. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68886. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68887. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68888. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68889. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68890. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68891. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68892. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68893. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68894. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68895. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68896. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68897. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68898. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68899. static readonly STEP_AFTERRENDER_AUDIO: number;
  68900. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68901. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68902. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68903. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68904. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68905. static readonly STEP_POINTERMOVE_SPRITE: number;
  68906. static readonly STEP_POINTERDOWN_SPRITE: number;
  68907. static readonly STEP_POINTERUP_SPRITE: number;
  68908. }
  68909. /**
  68910. * This represents a scene component.
  68911. *
  68912. * This is used to decouple the dependency the scene is having on the different workloads like
  68913. * layers, post processes...
  68914. */
  68915. export interface ISceneComponent {
  68916. /**
  68917. * The name of the component. Each component must have a unique name.
  68918. */
  68919. name: string;
  68920. /**
  68921. * The scene the component belongs to.
  68922. */
  68923. scene: Scene;
  68924. /**
  68925. * Register the component to one instance of a scene.
  68926. */
  68927. register(): void;
  68928. /**
  68929. * Rebuilds the elements related to this component in case of
  68930. * context lost for instance.
  68931. */
  68932. rebuild(): void;
  68933. /**
  68934. * Disposes the component and the associated ressources.
  68935. */
  68936. dispose(): void;
  68937. }
  68938. /**
  68939. * This represents a SERIALIZABLE scene component.
  68940. *
  68941. * This extends Scene Component to add Serialization methods on top.
  68942. */
  68943. export interface ISceneSerializableComponent extends ISceneComponent {
  68944. /**
  68945. * Adds all the element from the container to the scene
  68946. * @param container the container holding the elements
  68947. */
  68948. addFromContainer(container: AbstractScene): void;
  68949. /**
  68950. * Removes all the elements in the container from the scene
  68951. * @param container contains the elements to remove
  68952. */
  68953. removeFromContainer(container: AbstractScene): void;
  68954. /**
  68955. * Serializes the component data to the specified json object
  68956. * @param serializationObject The object to serialize to
  68957. */
  68958. serialize(serializationObject: any): void;
  68959. }
  68960. /**
  68961. * Strong typing of a Mesh related stage step action
  68962. */
  68963. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68964. /**
  68965. * Strong typing of a Evaluate Sub Mesh related stage step action
  68966. */
  68967. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68968. /**
  68969. * Strong typing of a Active Mesh related stage step action
  68970. */
  68971. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68972. /**
  68973. * Strong typing of a Camera related stage step action
  68974. */
  68975. export type CameraStageAction = (camera: Camera) => void;
  68976. /**
  68977. * Strong typing of a Render Target related stage step action
  68978. */
  68979. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68980. /**
  68981. * Strong typing of a RenderingGroup related stage step action
  68982. */
  68983. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68984. /**
  68985. * Strong typing of a Mesh Render related stage step action
  68986. */
  68987. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68988. /**
  68989. * Strong typing of a simple stage step action
  68990. */
  68991. export type SimpleStageAction = () => void;
  68992. /**
  68993. * Strong typing of a render target action.
  68994. */
  68995. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68996. /**
  68997. * Strong typing of a pointer move action.
  68998. */
  68999. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69000. /**
  69001. * Strong typing of a pointer up/down action.
  69002. */
  69003. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69004. /**
  69005. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69006. * @hidden
  69007. */
  69008. export class Stage<T extends Function> extends Array<{
  69009. index: number;
  69010. component: ISceneComponent;
  69011. action: T;
  69012. }> {
  69013. /**
  69014. * Hide ctor from the rest of the world.
  69015. * @param items The items to add.
  69016. */
  69017. private constructor();
  69018. /**
  69019. * Creates a new Stage.
  69020. * @returns A new instance of a Stage
  69021. */
  69022. static Create<T extends Function>(): Stage<T>;
  69023. /**
  69024. * Registers a step in an ordered way in the targeted stage.
  69025. * @param index Defines the position to register the step in
  69026. * @param component Defines the component attached to the step
  69027. * @param action Defines the action to launch during the step
  69028. */
  69029. registerStep(index: number, component: ISceneComponent, action: T): void;
  69030. /**
  69031. * Clears all the steps from the stage.
  69032. */
  69033. clear(): void;
  69034. }
  69035. }
  69036. declare module BABYLON {
  69037. interface Scene {
  69038. /** @hidden */
  69039. _pointerOverSprite: Nullable<Sprite>;
  69040. /** @hidden */
  69041. _pickedDownSprite: Nullable<Sprite>;
  69042. /** @hidden */
  69043. _tempSpritePickingRay: Nullable<Ray>;
  69044. /**
  69045. * All of the sprite managers added to this scene
  69046. * @see http://doc.babylonjs.com/babylon101/sprites
  69047. */
  69048. spriteManagers: Array<ISpriteManager>;
  69049. /**
  69050. * An event triggered when sprites rendering is about to start
  69051. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69052. */
  69053. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69054. /**
  69055. * An event triggered when sprites rendering is done
  69056. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69057. */
  69058. onAfterSpritesRenderingObservable: Observable<Scene>;
  69059. /** @hidden */
  69060. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69061. /** Launch a ray to try to pick a sprite in the scene
  69062. * @param x position on screen
  69063. * @param y position on screen
  69064. * @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
  69065. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69066. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69067. * @returns a PickingInfo
  69068. */
  69069. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69070. /** Use the given ray to pick a sprite in the scene
  69071. * @param ray The ray (in world space) to use to pick meshes
  69072. * @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
  69073. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69074. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69075. * @returns a PickingInfo
  69076. */
  69077. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69078. /**
  69079. * Force the sprite under the pointer
  69080. * @param sprite defines the sprite to use
  69081. */
  69082. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69083. /**
  69084. * Gets the sprite under the pointer
  69085. * @returns a Sprite or null if no sprite is under the pointer
  69086. */
  69087. getPointerOverSprite(): Nullable<Sprite>;
  69088. }
  69089. /**
  69090. * Defines the sprite scene component responsible to manage sprites
  69091. * in a given scene.
  69092. */
  69093. export class SpriteSceneComponent implements ISceneComponent {
  69094. /**
  69095. * The component name helpfull to identify the component in the list of scene components.
  69096. */
  69097. readonly name: string;
  69098. /**
  69099. * The scene the component belongs to.
  69100. */
  69101. scene: Scene;
  69102. /** @hidden */
  69103. private _spritePredicate;
  69104. /**
  69105. * Creates a new instance of the component for the given scene
  69106. * @param scene Defines the scene to register the component in
  69107. */
  69108. constructor(scene: Scene);
  69109. /**
  69110. * Registers the component in a given scene
  69111. */
  69112. register(): void;
  69113. /**
  69114. * Rebuilds the elements related to this component in case of
  69115. * context lost for instance.
  69116. */
  69117. rebuild(): void;
  69118. /**
  69119. * Disposes the component and the associated ressources.
  69120. */
  69121. dispose(): void;
  69122. private _pickSpriteButKeepRay;
  69123. private _pointerMove;
  69124. private _pointerDown;
  69125. private _pointerUp;
  69126. }
  69127. }
  69128. declare module BABYLON {
  69129. /** @hidden */
  69130. export var fogFragmentDeclaration: {
  69131. name: string;
  69132. shader: string;
  69133. };
  69134. }
  69135. declare module BABYLON {
  69136. /** @hidden */
  69137. export var fogFragment: {
  69138. name: string;
  69139. shader: string;
  69140. };
  69141. }
  69142. declare module BABYLON {
  69143. /** @hidden */
  69144. export var spritesPixelShader: {
  69145. name: string;
  69146. shader: string;
  69147. };
  69148. }
  69149. declare module BABYLON {
  69150. /** @hidden */
  69151. export var fogVertexDeclaration: {
  69152. name: string;
  69153. shader: string;
  69154. };
  69155. }
  69156. declare module BABYLON {
  69157. /** @hidden */
  69158. export var spritesVertexShader: {
  69159. name: string;
  69160. shader: string;
  69161. };
  69162. }
  69163. declare module BABYLON {
  69164. /**
  69165. * Defines the minimum interface to fullfil in order to be a sprite manager.
  69166. */
  69167. export interface ISpriteManager extends IDisposable {
  69168. /**
  69169. * Restricts the camera to viewing objects with the same layerMask.
  69170. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  69171. */
  69172. layerMask: number;
  69173. /**
  69174. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  69175. */
  69176. isPickable: boolean;
  69177. /**
  69178. * Specifies the rendering group id for this mesh (0 by default)
  69179. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  69180. */
  69181. renderingGroupId: number;
  69182. /**
  69183. * Defines the list of sprites managed by the manager.
  69184. */
  69185. sprites: Array<Sprite>;
  69186. /**
  69187. * Tests the intersection of a sprite with a specific ray.
  69188. * @param ray The ray we are sending to test the collision
  69189. * @param camera The camera space we are sending rays in
  69190. * @param predicate A predicate allowing excluding sprites from the list of object to test
  69191. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  69192. * @returns picking info or null.
  69193. */
  69194. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69195. /**
  69196. * Renders the list of sprites on screen.
  69197. */
  69198. render(): void;
  69199. }
  69200. /**
  69201. * Class used to manage multiple sprites on the same spritesheet
  69202. * @see http://doc.babylonjs.com/babylon101/sprites
  69203. */
  69204. export class SpriteManager implements ISpriteManager {
  69205. /** defines the manager's name */
  69206. name: string;
  69207. /** Gets the list of sprites */
  69208. sprites: Sprite[];
  69209. /** Gets or sets the rendering group id (0 by default) */
  69210. renderingGroupId: number;
  69211. /** Gets or sets camera layer mask */
  69212. layerMask: number;
  69213. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69214. fogEnabled: boolean;
  69215. /** Gets or sets a boolean indicating if the sprites are pickable */
  69216. isPickable: boolean;
  69217. /** Defines the default width of a cell in the spritesheet */
  69218. cellWidth: number;
  69219. /** Defines the default height of a cell in the spritesheet */
  69220. cellHeight: number;
  69221. /**
  69222. * An event triggered when the manager is disposed.
  69223. */
  69224. onDisposeObservable: Observable<SpriteManager>;
  69225. private _onDisposeObserver;
  69226. /**
  69227. * Callback called when the manager is disposed
  69228. */
  69229. onDispose: () => void;
  69230. private _capacity;
  69231. private _spriteTexture;
  69232. private _epsilon;
  69233. private _scene;
  69234. private _vertexData;
  69235. private _buffer;
  69236. private _vertexBuffers;
  69237. private _indexBuffer;
  69238. private _effectBase;
  69239. private _effectFog;
  69240. /**
  69241. * Gets or sets the spritesheet texture
  69242. */
  69243. texture: Texture;
  69244. /**
  69245. * Creates a new sprite manager
  69246. * @param name defines the manager's name
  69247. * @param imgUrl defines the sprite sheet url
  69248. * @param capacity defines the maximum allowed number of sprites
  69249. * @param cellSize defines the size of a sprite cell
  69250. * @param scene defines the hosting scene
  69251. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69252. * @param samplingMode defines the smapling mode to use with spritesheet
  69253. */
  69254. constructor(
  69255. /** defines the manager's name */
  69256. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69257. private _appendSpriteVertex;
  69258. /**
  69259. * Intersects the sprites with a ray
  69260. * @param ray defines the ray to intersect with
  69261. * @param camera defines the current active camera
  69262. * @param predicate defines a predicate used to select candidate sprites
  69263. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69264. * @returns null if no hit or a PickingInfo
  69265. */
  69266. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69267. /**
  69268. * Render all child sprites
  69269. */
  69270. render(): void;
  69271. /**
  69272. * Release associated resources
  69273. */
  69274. dispose(): void;
  69275. }
  69276. }
  69277. declare module BABYLON {
  69278. /**
  69279. * Class used to represent a sprite
  69280. * @see http://doc.babylonjs.com/babylon101/sprites
  69281. */
  69282. export class Sprite {
  69283. /** defines the name */
  69284. name: string;
  69285. /** Gets or sets the current world position */
  69286. position: Vector3;
  69287. /** Gets or sets the main color */
  69288. color: Color4;
  69289. /** Gets or sets the width */
  69290. width: number;
  69291. /** Gets or sets the height */
  69292. height: number;
  69293. /** Gets or sets rotation angle */
  69294. angle: number;
  69295. /** Gets or sets the cell index in the sprite sheet */
  69296. cellIndex: number;
  69297. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69298. invertU: number;
  69299. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69300. invertV: number;
  69301. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69302. disposeWhenFinishedAnimating: boolean;
  69303. /** Gets the list of attached animations */
  69304. animations: Animation[];
  69305. /** Gets or sets a boolean indicating if the sprite can be picked */
  69306. isPickable: boolean;
  69307. /**
  69308. * Gets or sets the associated action manager
  69309. */
  69310. actionManager: Nullable<ActionManager>;
  69311. private _animationStarted;
  69312. private _loopAnimation;
  69313. private _fromIndex;
  69314. private _toIndex;
  69315. private _delay;
  69316. private _direction;
  69317. private _manager;
  69318. private _time;
  69319. private _onAnimationEnd;
  69320. /**
  69321. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69322. */
  69323. isVisible: boolean;
  69324. /**
  69325. * Gets or sets the sprite size
  69326. */
  69327. size: number;
  69328. /**
  69329. * Creates a new Sprite
  69330. * @param name defines the name
  69331. * @param manager defines the manager
  69332. */
  69333. constructor(
  69334. /** defines the name */
  69335. name: string, manager: ISpriteManager);
  69336. /**
  69337. * Starts an animation
  69338. * @param from defines the initial key
  69339. * @param to defines the end key
  69340. * @param loop defines if the animation must loop
  69341. * @param delay defines the start delay (in ms)
  69342. * @param onAnimationEnd defines a callback to call when animation ends
  69343. */
  69344. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69345. /** Stops current animation (if any) */
  69346. stopAnimation(): void;
  69347. /** @hidden */
  69348. _animate(deltaTime: number): void;
  69349. /** Release associated resources */
  69350. dispose(): void;
  69351. }
  69352. }
  69353. declare module BABYLON {
  69354. /**
  69355. * Information about the result of picking within a scene
  69356. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69357. */
  69358. export class PickingInfo {
  69359. /** @hidden */
  69360. _pickingUnavailable: boolean;
  69361. /**
  69362. * If the pick collided with an object
  69363. */
  69364. hit: boolean;
  69365. /**
  69366. * Distance away where the pick collided
  69367. */
  69368. distance: number;
  69369. /**
  69370. * The location of pick collision
  69371. */
  69372. pickedPoint: Nullable<Vector3>;
  69373. /**
  69374. * The mesh corresponding the the pick collision
  69375. */
  69376. pickedMesh: Nullable<AbstractMesh>;
  69377. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69378. bu: number;
  69379. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69380. bv: number;
  69381. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69382. faceId: number;
  69383. /** Id of the the submesh that was picked */
  69384. subMeshId: number;
  69385. /** If a sprite was picked, this will be the sprite the pick collided with */
  69386. pickedSprite: Nullable<Sprite>;
  69387. /**
  69388. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69389. */
  69390. originMesh: Nullable<AbstractMesh>;
  69391. /**
  69392. * The ray that was used to perform the picking.
  69393. */
  69394. ray: Nullable<Ray>;
  69395. /**
  69396. * Gets the normal correspodning to the face the pick collided with
  69397. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69398. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69399. * @returns The normal correspodning to the face the pick collided with
  69400. */
  69401. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69402. /**
  69403. * Gets the texture coordinates of where the pick occured
  69404. * @returns the vector containing the coordnates of the texture
  69405. */
  69406. getTextureCoordinates(): Nullable<Vector2>;
  69407. }
  69408. }
  69409. declare module BABYLON {
  69410. /**
  69411. * Gather the list of pointer event types as constants.
  69412. */
  69413. export class PointerEventTypes {
  69414. /**
  69415. * 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.
  69416. */
  69417. static readonly POINTERDOWN: number;
  69418. /**
  69419. * The pointerup event is fired when a pointer is no longer active.
  69420. */
  69421. static readonly POINTERUP: number;
  69422. /**
  69423. * The pointermove event is fired when a pointer changes coordinates.
  69424. */
  69425. static readonly POINTERMOVE: number;
  69426. /**
  69427. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69428. */
  69429. static readonly POINTERWHEEL: number;
  69430. /**
  69431. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69432. */
  69433. static readonly POINTERPICK: number;
  69434. /**
  69435. * The pointertap event is fired when a the object has been touched and released without drag.
  69436. */
  69437. static readonly POINTERTAP: number;
  69438. /**
  69439. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69440. */
  69441. static readonly POINTERDOUBLETAP: number;
  69442. }
  69443. /**
  69444. * Base class of pointer info types.
  69445. */
  69446. export class PointerInfoBase {
  69447. /**
  69448. * Defines the type of event (PointerEventTypes)
  69449. */
  69450. type: number;
  69451. /**
  69452. * Defines the related dom event
  69453. */
  69454. event: PointerEvent | MouseWheelEvent;
  69455. /**
  69456. * Instantiates the base class of pointers info.
  69457. * @param type Defines the type of event (PointerEventTypes)
  69458. * @param event Defines the related dom event
  69459. */
  69460. constructor(
  69461. /**
  69462. * Defines the type of event (PointerEventTypes)
  69463. */
  69464. type: number,
  69465. /**
  69466. * Defines the related dom event
  69467. */
  69468. event: PointerEvent | MouseWheelEvent);
  69469. }
  69470. /**
  69471. * This class is used to store pointer related info for the onPrePointerObservable event.
  69472. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69473. */
  69474. export class PointerInfoPre extends PointerInfoBase {
  69475. /**
  69476. * Ray from a pointer if availible (eg. 6dof controller)
  69477. */
  69478. ray: Nullable<Ray>;
  69479. /**
  69480. * Defines the local position of the pointer on the canvas.
  69481. */
  69482. localPosition: Vector2;
  69483. /**
  69484. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69485. */
  69486. skipOnPointerObservable: boolean;
  69487. /**
  69488. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69489. * @param type Defines the type of event (PointerEventTypes)
  69490. * @param event Defines the related dom event
  69491. * @param localX Defines the local x coordinates of the pointer when the event occured
  69492. * @param localY Defines the local y coordinates of the pointer when the event occured
  69493. */
  69494. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69495. }
  69496. /**
  69497. * This type contains all the data related to a pointer event in Babylon.js.
  69498. * 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.
  69499. */
  69500. export class PointerInfo extends PointerInfoBase {
  69501. /**
  69502. * Defines the picking info associated to the info (if any)\
  69503. */
  69504. pickInfo: Nullable<PickingInfo>;
  69505. /**
  69506. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69507. * @param type Defines the type of event (PointerEventTypes)
  69508. * @param event Defines the related dom event
  69509. * @param pickInfo Defines the picking info associated to the info (if any)\
  69510. */
  69511. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69512. /**
  69513. * Defines the picking info associated to the info (if any)\
  69514. */
  69515. pickInfo: Nullable<PickingInfo>);
  69516. }
  69517. /**
  69518. * Data relating to a touch event on the screen.
  69519. */
  69520. export interface PointerTouch {
  69521. /**
  69522. * X coordinate of touch.
  69523. */
  69524. x: number;
  69525. /**
  69526. * Y coordinate of touch.
  69527. */
  69528. y: number;
  69529. /**
  69530. * Id of touch. Unique for each finger.
  69531. */
  69532. pointerId: number;
  69533. /**
  69534. * Event type passed from DOM.
  69535. */
  69536. type: any;
  69537. }
  69538. }
  69539. declare module BABYLON {
  69540. /**
  69541. * Manage the mouse inputs to control the movement of a free camera.
  69542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69543. */
  69544. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69545. /**
  69546. * Define if touch is enabled in the mouse input
  69547. */
  69548. touchEnabled: boolean;
  69549. /**
  69550. * Defines the camera the input is attached to.
  69551. */
  69552. camera: FreeCamera;
  69553. /**
  69554. * Defines the buttons associated with the input to handle camera move.
  69555. */
  69556. buttons: number[];
  69557. /**
  69558. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69559. */
  69560. angularSensibility: number;
  69561. private _pointerInput;
  69562. private _onMouseMove;
  69563. private _observer;
  69564. private previousPosition;
  69565. /**
  69566. * Manage the mouse inputs to control the movement of a free camera.
  69567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69568. * @param touchEnabled Defines if touch is enabled or not
  69569. */
  69570. constructor(
  69571. /**
  69572. * Define if touch is enabled in the mouse input
  69573. */
  69574. touchEnabled?: boolean);
  69575. /**
  69576. * Attach the input controls to a specific dom element to get the input from.
  69577. * @param element Defines the element the controls should be listened from
  69578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69579. */
  69580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69581. /**
  69582. * Called on JS contextmenu event.
  69583. * Override this method to provide functionality.
  69584. */
  69585. protected onContextMenu(evt: PointerEvent): void;
  69586. /**
  69587. * Detach the current controls from the specified dom element.
  69588. * @param element Defines the element to stop listening the inputs from
  69589. */
  69590. detachControl(element: Nullable<HTMLElement>): void;
  69591. /**
  69592. * Gets the class name of the current intput.
  69593. * @returns the class name
  69594. */
  69595. getClassName(): string;
  69596. /**
  69597. * Get the friendly name associated with the input class.
  69598. * @returns the input friendly name
  69599. */
  69600. getSimpleName(): string;
  69601. }
  69602. }
  69603. declare module BABYLON {
  69604. /**
  69605. * Manage the touch inputs to control the movement of a free camera.
  69606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69607. */
  69608. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69609. /**
  69610. * Defines the camera the input is attached to.
  69611. */
  69612. camera: FreeCamera;
  69613. /**
  69614. * Defines the touch sensibility for rotation.
  69615. * The higher the faster.
  69616. */
  69617. touchAngularSensibility: number;
  69618. /**
  69619. * Defines the touch sensibility for move.
  69620. * The higher the faster.
  69621. */
  69622. touchMoveSensibility: number;
  69623. private _offsetX;
  69624. private _offsetY;
  69625. private _pointerPressed;
  69626. private _pointerInput;
  69627. private _observer;
  69628. private _onLostFocus;
  69629. /**
  69630. * Attach the input controls to a specific dom element to get the input from.
  69631. * @param element Defines the element the controls should be listened from
  69632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69633. */
  69634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69635. /**
  69636. * Detach the current controls from the specified dom element.
  69637. * @param element Defines the element to stop listening the inputs from
  69638. */
  69639. detachControl(element: Nullable<HTMLElement>): void;
  69640. /**
  69641. * Update the current camera state depending on the inputs that have been used this frame.
  69642. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69643. */
  69644. checkInputs(): void;
  69645. /**
  69646. * Gets the class name of the current intput.
  69647. * @returns the class name
  69648. */
  69649. getClassName(): string;
  69650. /**
  69651. * Get the friendly name associated with the input class.
  69652. * @returns the input friendly name
  69653. */
  69654. getSimpleName(): string;
  69655. }
  69656. }
  69657. declare module BABYLON {
  69658. /**
  69659. * Default Inputs manager for the FreeCamera.
  69660. * It groups all the default supported inputs for ease of use.
  69661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69662. */
  69663. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69664. /**
  69665. * Instantiates a new FreeCameraInputsManager.
  69666. * @param camera Defines the camera the inputs belong to
  69667. */
  69668. constructor(camera: FreeCamera);
  69669. /**
  69670. * Add keyboard input support to the input manager.
  69671. * @returns the current input manager
  69672. */
  69673. addKeyboard(): FreeCameraInputsManager;
  69674. /**
  69675. * Add mouse input support to the input manager.
  69676. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69677. * @returns the current input manager
  69678. */
  69679. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69680. /**
  69681. * Add touch input support to the input manager.
  69682. * @returns the current input manager
  69683. */
  69684. addTouch(): FreeCameraInputsManager;
  69685. }
  69686. }
  69687. declare module BABYLON {
  69688. /**
  69689. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69690. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69691. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69692. */
  69693. export class FreeCamera extends TargetCamera {
  69694. /**
  69695. * Define the collision ellipsoid of the camera.
  69696. * This is helpful to simulate a camera body like the player body around the camera
  69697. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69698. */
  69699. ellipsoid: Vector3;
  69700. /**
  69701. * Define an offset for the position of the ellipsoid around the camera.
  69702. * This can be helpful to determine the center of the body near the gravity center of the body
  69703. * instead of its head.
  69704. */
  69705. ellipsoidOffset: Vector3;
  69706. /**
  69707. * Enable or disable collisions of the camera with the rest of the scene objects.
  69708. */
  69709. checkCollisions: boolean;
  69710. /**
  69711. * Enable or disable gravity on the camera.
  69712. */
  69713. applyGravity: boolean;
  69714. /**
  69715. * Define the input manager associated to the camera.
  69716. */
  69717. inputs: FreeCameraInputsManager;
  69718. /**
  69719. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69720. * Higher values reduce sensitivity.
  69721. */
  69722. /**
  69723. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69724. * Higher values reduce sensitivity.
  69725. */
  69726. angularSensibility: number;
  69727. /**
  69728. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69729. */
  69730. keysUp: number[];
  69731. /**
  69732. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69733. */
  69734. keysDown: number[];
  69735. /**
  69736. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69737. */
  69738. keysLeft: number[];
  69739. /**
  69740. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69741. */
  69742. keysRight: number[];
  69743. /**
  69744. * Event raised when the camera collide with a mesh in the scene.
  69745. */
  69746. onCollide: (collidedMesh: AbstractMesh) => void;
  69747. private _collider;
  69748. private _needMoveForGravity;
  69749. private _oldPosition;
  69750. private _diffPosition;
  69751. private _newPosition;
  69752. /** @hidden */
  69753. _localDirection: Vector3;
  69754. /** @hidden */
  69755. _transformedDirection: Vector3;
  69756. /**
  69757. * Instantiates a Free Camera.
  69758. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69759. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69760. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69761. * @param name Define the name of the camera in the scene
  69762. * @param position Define the start position of the camera in the scene
  69763. * @param scene Define the scene the camera belongs to
  69764. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69765. */
  69766. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69767. /**
  69768. * Attached controls to the current camera.
  69769. * @param element Defines the element the controls should be listened from
  69770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69771. */
  69772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69773. /**
  69774. * Detach the current controls from the camera.
  69775. * The camera will stop reacting to inputs.
  69776. * @param element Defines the element to stop listening the inputs from
  69777. */
  69778. detachControl(element: HTMLElement): void;
  69779. private _collisionMask;
  69780. /**
  69781. * Define a collision mask to limit the list of object the camera can collide with
  69782. */
  69783. collisionMask: number;
  69784. /** @hidden */
  69785. _collideWithWorld(displacement: Vector3): void;
  69786. private _onCollisionPositionChange;
  69787. /** @hidden */
  69788. _checkInputs(): void;
  69789. /** @hidden */
  69790. _decideIfNeedsToMove(): boolean;
  69791. /** @hidden */
  69792. _updatePosition(): void;
  69793. /**
  69794. * Destroy the camera and release the current resources hold by it.
  69795. */
  69796. dispose(): void;
  69797. /**
  69798. * Gets the current object class name.
  69799. * @return the class name
  69800. */
  69801. getClassName(): string;
  69802. }
  69803. }
  69804. declare module BABYLON {
  69805. /**
  69806. * Represents a gamepad control stick position
  69807. */
  69808. export class StickValues {
  69809. /**
  69810. * The x component of the control stick
  69811. */
  69812. x: number;
  69813. /**
  69814. * The y component of the control stick
  69815. */
  69816. y: number;
  69817. /**
  69818. * Initializes the gamepad x and y control stick values
  69819. * @param x The x component of the gamepad control stick value
  69820. * @param y The y component of the gamepad control stick value
  69821. */
  69822. constructor(
  69823. /**
  69824. * The x component of the control stick
  69825. */
  69826. x: number,
  69827. /**
  69828. * The y component of the control stick
  69829. */
  69830. y: number);
  69831. }
  69832. /**
  69833. * An interface which manages callbacks for gamepad button changes
  69834. */
  69835. export interface GamepadButtonChanges {
  69836. /**
  69837. * Called when a gamepad has been changed
  69838. */
  69839. changed: boolean;
  69840. /**
  69841. * Called when a gamepad press event has been triggered
  69842. */
  69843. pressChanged: boolean;
  69844. /**
  69845. * Called when a touch event has been triggered
  69846. */
  69847. touchChanged: boolean;
  69848. /**
  69849. * Called when a value has changed
  69850. */
  69851. valueChanged: boolean;
  69852. }
  69853. /**
  69854. * Represents a gamepad
  69855. */
  69856. export class Gamepad {
  69857. /**
  69858. * The id of the gamepad
  69859. */
  69860. id: string;
  69861. /**
  69862. * The index of the gamepad
  69863. */
  69864. index: number;
  69865. /**
  69866. * The browser gamepad
  69867. */
  69868. browserGamepad: any;
  69869. /**
  69870. * Specifies what type of gamepad this represents
  69871. */
  69872. type: number;
  69873. private _leftStick;
  69874. private _rightStick;
  69875. /** @hidden */
  69876. _isConnected: boolean;
  69877. private _leftStickAxisX;
  69878. private _leftStickAxisY;
  69879. private _rightStickAxisX;
  69880. private _rightStickAxisY;
  69881. /**
  69882. * Triggered when the left control stick has been changed
  69883. */
  69884. private _onleftstickchanged;
  69885. /**
  69886. * Triggered when the right control stick has been changed
  69887. */
  69888. private _onrightstickchanged;
  69889. /**
  69890. * Represents a gamepad controller
  69891. */
  69892. static GAMEPAD: number;
  69893. /**
  69894. * Represents a generic controller
  69895. */
  69896. static GENERIC: number;
  69897. /**
  69898. * Represents an XBox controller
  69899. */
  69900. static XBOX: number;
  69901. /**
  69902. * Represents a pose-enabled controller
  69903. */
  69904. static POSE_ENABLED: number;
  69905. /**
  69906. * Specifies whether the left control stick should be Y-inverted
  69907. */
  69908. protected _invertLeftStickY: boolean;
  69909. /**
  69910. * Specifies if the gamepad has been connected
  69911. */
  69912. readonly isConnected: boolean;
  69913. /**
  69914. * Initializes the gamepad
  69915. * @param id The id of the gamepad
  69916. * @param index The index of the gamepad
  69917. * @param browserGamepad The browser gamepad
  69918. * @param leftStickX The x component of the left joystick
  69919. * @param leftStickY The y component of the left joystick
  69920. * @param rightStickX The x component of the right joystick
  69921. * @param rightStickY The y component of the right joystick
  69922. */
  69923. constructor(
  69924. /**
  69925. * The id of the gamepad
  69926. */
  69927. id: string,
  69928. /**
  69929. * The index of the gamepad
  69930. */
  69931. index: number,
  69932. /**
  69933. * The browser gamepad
  69934. */
  69935. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69936. /**
  69937. * Callback triggered when the left joystick has changed
  69938. * @param callback
  69939. */
  69940. onleftstickchanged(callback: (values: StickValues) => void): void;
  69941. /**
  69942. * Callback triggered when the right joystick has changed
  69943. * @param callback
  69944. */
  69945. onrightstickchanged(callback: (values: StickValues) => void): void;
  69946. /**
  69947. * Gets the left joystick
  69948. */
  69949. /**
  69950. * Sets the left joystick values
  69951. */
  69952. leftStick: StickValues;
  69953. /**
  69954. * Gets the right joystick
  69955. */
  69956. /**
  69957. * Sets the right joystick value
  69958. */
  69959. rightStick: StickValues;
  69960. /**
  69961. * Updates the gamepad joystick positions
  69962. */
  69963. update(): void;
  69964. /**
  69965. * Disposes the gamepad
  69966. */
  69967. dispose(): void;
  69968. }
  69969. /**
  69970. * Represents a generic gamepad
  69971. */
  69972. export class GenericPad extends Gamepad {
  69973. private _buttons;
  69974. private _onbuttondown;
  69975. private _onbuttonup;
  69976. /**
  69977. * Observable triggered when a button has been pressed
  69978. */
  69979. onButtonDownObservable: Observable<number>;
  69980. /**
  69981. * Observable triggered when a button has been released
  69982. */
  69983. onButtonUpObservable: Observable<number>;
  69984. /**
  69985. * Callback triggered when a button has been pressed
  69986. * @param callback Called when a button has been pressed
  69987. */
  69988. onbuttondown(callback: (buttonPressed: number) => void): void;
  69989. /**
  69990. * Callback triggered when a button has been released
  69991. * @param callback Called when a button has been released
  69992. */
  69993. onbuttonup(callback: (buttonReleased: number) => void): void;
  69994. /**
  69995. * Initializes the generic gamepad
  69996. * @param id The id of the generic gamepad
  69997. * @param index The index of the generic gamepad
  69998. * @param browserGamepad The browser gamepad
  69999. */
  70000. constructor(id: string, index: number, browserGamepad: any);
  70001. private _setButtonValue;
  70002. /**
  70003. * Updates the generic gamepad
  70004. */
  70005. update(): void;
  70006. /**
  70007. * Disposes the generic gamepad
  70008. */
  70009. dispose(): void;
  70010. }
  70011. }
  70012. declare module BABYLON {
  70013. /**
  70014. * Defines the types of pose enabled controllers that are supported
  70015. */
  70016. export enum PoseEnabledControllerType {
  70017. /**
  70018. * HTC Vive
  70019. */
  70020. VIVE = 0,
  70021. /**
  70022. * Oculus Rift
  70023. */
  70024. OCULUS = 1,
  70025. /**
  70026. * Windows mixed reality
  70027. */
  70028. WINDOWS = 2,
  70029. /**
  70030. * Samsung gear VR
  70031. */
  70032. GEAR_VR = 3,
  70033. /**
  70034. * Google Daydream
  70035. */
  70036. DAYDREAM = 4,
  70037. /**
  70038. * Generic
  70039. */
  70040. GENERIC = 5
  70041. }
  70042. /**
  70043. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70044. */
  70045. export interface MutableGamepadButton {
  70046. /**
  70047. * Value of the button/trigger
  70048. */
  70049. value: number;
  70050. /**
  70051. * If the button/trigger is currently touched
  70052. */
  70053. touched: boolean;
  70054. /**
  70055. * If the button/trigger is currently pressed
  70056. */
  70057. pressed: boolean;
  70058. }
  70059. /**
  70060. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70061. * @hidden
  70062. */
  70063. export interface ExtendedGamepadButton extends GamepadButton {
  70064. /**
  70065. * If the button/trigger is currently pressed
  70066. */
  70067. readonly pressed: boolean;
  70068. /**
  70069. * If the button/trigger is currently touched
  70070. */
  70071. readonly touched: boolean;
  70072. /**
  70073. * Value of the button/trigger
  70074. */
  70075. readonly value: number;
  70076. }
  70077. /** @hidden */
  70078. export interface _GamePadFactory {
  70079. /**
  70080. * Returns wether or not the current gamepad can be created for this type of controller.
  70081. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70082. * @returns true if it can be created, otherwise false
  70083. */
  70084. canCreate(gamepadInfo: any): boolean;
  70085. /**
  70086. * Creates a new instance of the Gamepad.
  70087. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70088. * @returns the new gamepad instance
  70089. */
  70090. create(gamepadInfo: any): Gamepad;
  70091. }
  70092. /**
  70093. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70094. */
  70095. export class PoseEnabledControllerHelper {
  70096. /** @hidden */
  70097. static _ControllerFactories: _GamePadFactory[];
  70098. /** @hidden */
  70099. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70100. /**
  70101. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70102. * @param vrGamepad the gamepad to initialized
  70103. * @returns a vr controller of the type the gamepad identified as
  70104. */
  70105. static InitiateController(vrGamepad: any): Gamepad;
  70106. }
  70107. /**
  70108. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70109. */
  70110. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70111. private _deviceRoomPosition;
  70112. private _deviceRoomRotationQuaternion;
  70113. /**
  70114. * The device position in babylon space
  70115. */
  70116. devicePosition: Vector3;
  70117. /**
  70118. * The device rotation in babylon space
  70119. */
  70120. deviceRotationQuaternion: Quaternion;
  70121. /**
  70122. * The scale factor of the device in babylon space
  70123. */
  70124. deviceScaleFactor: number;
  70125. /**
  70126. * (Likely devicePosition should be used instead) The device position in its room space
  70127. */
  70128. position: Vector3;
  70129. /**
  70130. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70131. */
  70132. rotationQuaternion: Quaternion;
  70133. /**
  70134. * The type of controller (Eg. Windows mixed reality)
  70135. */
  70136. controllerType: PoseEnabledControllerType;
  70137. protected _calculatedPosition: Vector3;
  70138. private _calculatedRotation;
  70139. /**
  70140. * The raw pose from the device
  70141. */
  70142. rawPose: DevicePose;
  70143. private _trackPosition;
  70144. private _maxRotationDistFromHeadset;
  70145. private _draggedRoomRotation;
  70146. /**
  70147. * @hidden
  70148. */
  70149. _disableTrackPosition(fixedPosition: Vector3): void;
  70150. /**
  70151. * Internal, the mesh attached to the controller
  70152. * @hidden
  70153. */
  70154. _mesh: Nullable<AbstractMesh>;
  70155. private _poseControlledCamera;
  70156. private _leftHandSystemQuaternion;
  70157. /**
  70158. * Internal, matrix used to convert room space to babylon space
  70159. * @hidden
  70160. */
  70161. _deviceToWorld: Matrix;
  70162. /**
  70163. * Node to be used when casting a ray from the controller
  70164. * @hidden
  70165. */
  70166. _pointingPoseNode: Nullable<TransformNode>;
  70167. /**
  70168. * Name of the child mesh that can be used to cast a ray from the controller
  70169. */
  70170. static readonly POINTING_POSE: string;
  70171. /**
  70172. * Creates a new PoseEnabledController from a gamepad
  70173. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  70174. */
  70175. constructor(browserGamepad: any);
  70176. private _workingMatrix;
  70177. /**
  70178. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  70179. */
  70180. update(): void;
  70181. /**
  70182. * Updates only the pose device and mesh without doing any button event checking
  70183. */
  70184. protected _updatePoseAndMesh(): void;
  70185. /**
  70186. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  70187. * @param poseData raw pose fromthe device
  70188. */
  70189. updateFromDevice(poseData: DevicePose): void;
  70190. /**
  70191. * @hidden
  70192. */
  70193. _meshAttachedObservable: Observable<AbstractMesh>;
  70194. /**
  70195. * Attaches a mesh to the controller
  70196. * @param mesh the mesh to be attached
  70197. */
  70198. attachToMesh(mesh: AbstractMesh): void;
  70199. /**
  70200. * Attaches the controllers mesh to a camera
  70201. * @param camera the camera the mesh should be attached to
  70202. */
  70203. attachToPoseControlledCamera(camera: TargetCamera): void;
  70204. /**
  70205. * Disposes of the controller
  70206. */
  70207. dispose(): void;
  70208. /**
  70209. * The mesh that is attached to the controller
  70210. */
  70211. readonly mesh: Nullable<AbstractMesh>;
  70212. /**
  70213. * Gets the ray of the controller in the direction the controller is pointing
  70214. * @param length the length the resulting ray should be
  70215. * @returns a ray in the direction the controller is pointing
  70216. */
  70217. getForwardRay(length?: number): Ray;
  70218. }
  70219. }
  70220. declare module BABYLON {
  70221. /**
  70222. * Defines the WebVRController object that represents controllers tracked in 3D space
  70223. */
  70224. export abstract class WebVRController extends PoseEnabledController {
  70225. /**
  70226. * Internal, the default controller model for the controller
  70227. */
  70228. protected _defaultModel: AbstractMesh;
  70229. /**
  70230. * Fired when the trigger state has changed
  70231. */
  70232. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70233. /**
  70234. * Fired when the main button state has changed
  70235. */
  70236. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70237. /**
  70238. * Fired when the secondary button state has changed
  70239. */
  70240. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70241. /**
  70242. * Fired when the pad state has changed
  70243. */
  70244. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70245. /**
  70246. * Fired when controllers stick values have changed
  70247. */
  70248. onPadValuesChangedObservable: Observable<StickValues>;
  70249. /**
  70250. * Array of button availible on the controller
  70251. */
  70252. protected _buttons: Array<MutableGamepadButton>;
  70253. private _onButtonStateChange;
  70254. /**
  70255. * Fired when a controller button's state has changed
  70256. * @param callback the callback containing the button that was modified
  70257. */
  70258. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70259. /**
  70260. * X and Y axis corrisponding to the controllers joystick
  70261. */
  70262. pad: StickValues;
  70263. /**
  70264. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70265. */
  70266. hand: string;
  70267. /**
  70268. * The default controller model for the controller
  70269. */
  70270. readonly defaultModel: AbstractMesh;
  70271. /**
  70272. * Creates a new WebVRController from a gamepad
  70273. * @param vrGamepad the gamepad that the WebVRController should be created from
  70274. */
  70275. constructor(vrGamepad: any);
  70276. /**
  70277. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70278. */
  70279. update(): void;
  70280. /**
  70281. * Function to be called when a button is modified
  70282. */
  70283. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70284. /**
  70285. * Loads a mesh and attaches it to the controller
  70286. * @param scene the scene the mesh should be added to
  70287. * @param meshLoaded callback for when the mesh has been loaded
  70288. */
  70289. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70290. private _setButtonValue;
  70291. private _changes;
  70292. private _checkChanges;
  70293. /**
  70294. * Disposes of th webVRCOntroller
  70295. */
  70296. dispose(): void;
  70297. }
  70298. }
  70299. declare module BABYLON {
  70300. /**
  70301. * The HemisphericLight simulates the ambient environment light,
  70302. * so the passed direction is the light reflection direction, not the incoming direction.
  70303. */
  70304. export class HemisphericLight extends Light {
  70305. /**
  70306. * The groundColor is the light in the opposite direction to the one specified during creation.
  70307. * 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.
  70308. */
  70309. groundColor: Color3;
  70310. /**
  70311. * The light reflection direction, not the incoming direction.
  70312. */
  70313. direction: Vector3;
  70314. /**
  70315. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70316. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70317. * The HemisphericLight can't cast shadows.
  70318. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70319. * @param name The friendly name of the light
  70320. * @param direction The direction of the light reflection
  70321. * @param scene The scene the light belongs to
  70322. */
  70323. constructor(name: string, direction: Vector3, scene: Scene);
  70324. protected _buildUniformLayout(): void;
  70325. /**
  70326. * Returns the string "HemisphericLight".
  70327. * @return The class name
  70328. */
  70329. getClassName(): string;
  70330. /**
  70331. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70332. * Returns the updated direction.
  70333. * @param target The target the direction should point to
  70334. * @return The computed direction
  70335. */
  70336. setDirectionToTarget(target: Vector3): Vector3;
  70337. /**
  70338. * Returns the shadow generator associated to the light.
  70339. * @returns Always null for hemispheric lights because it does not support shadows.
  70340. */
  70341. getShadowGenerator(): Nullable<IShadowGenerator>;
  70342. /**
  70343. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70344. * @param effect The effect to update
  70345. * @param lightIndex The index of the light in the effect to update
  70346. * @returns The hemispheric light
  70347. */
  70348. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70349. /**
  70350. * Computes the world matrix of the node
  70351. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70352. * @param useWasUpdatedFlag defines a reserved property
  70353. * @returns the world matrix
  70354. */
  70355. computeWorldMatrix(): Matrix;
  70356. /**
  70357. * Returns the integer 3.
  70358. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70359. */
  70360. getTypeID(): number;
  70361. /**
  70362. * Prepares the list of defines specific to the light type.
  70363. * @param defines the list of defines
  70364. * @param lightIndex defines the index of the light for the effect
  70365. */
  70366. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70367. }
  70368. }
  70369. declare module BABYLON {
  70370. /**
  70371. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70372. * IMPORTANT!! The data is right-hand data.
  70373. * @export
  70374. * @interface DevicePose
  70375. */
  70376. export interface DevicePose {
  70377. /**
  70378. * The position of the device, values in array are [x,y,z].
  70379. */
  70380. readonly position: Nullable<Float32Array>;
  70381. /**
  70382. * The linearVelocity of the device, values in array are [x,y,z].
  70383. */
  70384. readonly linearVelocity: Nullable<Float32Array>;
  70385. /**
  70386. * The linearAcceleration of the device, values in array are [x,y,z].
  70387. */
  70388. readonly linearAcceleration: Nullable<Float32Array>;
  70389. /**
  70390. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70391. */
  70392. readonly orientation: Nullable<Float32Array>;
  70393. /**
  70394. * The angularVelocity of the device, values in array are [x,y,z].
  70395. */
  70396. readonly angularVelocity: Nullable<Float32Array>;
  70397. /**
  70398. * The angularAcceleration of the device, values in array are [x,y,z].
  70399. */
  70400. readonly angularAcceleration: Nullable<Float32Array>;
  70401. }
  70402. /**
  70403. * Interface representing a pose controlled object in Babylon.
  70404. * A pose controlled object has both regular pose values as well as pose values
  70405. * from an external device such as a VR head mounted display
  70406. */
  70407. export interface PoseControlled {
  70408. /**
  70409. * The position of the object in babylon space.
  70410. */
  70411. position: Vector3;
  70412. /**
  70413. * The rotation quaternion of the object in babylon space.
  70414. */
  70415. rotationQuaternion: Quaternion;
  70416. /**
  70417. * The position of the device in babylon space.
  70418. */
  70419. devicePosition?: Vector3;
  70420. /**
  70421. * The rotation quaternion of the device in babylon space.
  70422. */
  70423. deviceRotationQuaternion: Quaternion;
  70424. /**
  70425. * The raw pose coming from the device.
  70426. */
  70427. rawPose: Nullable<DevicePose>;
  70428. /**
  70429. * The scale of the device to be used when translating from device space to babylon space.
  70430. */
  70431. deviceScaleFactor: number;
  70432. /**
  70433. * Updates the poseControlled values based on the input device pose.
  70434. * @param poseData the pose data to update the object with
  70435. */
  70436. updateFromDevice(poseData: DevicePose): void;
  70437. }
  70438. /**
  70439. * Set of options to customize the webVRCamera
  70440. */
  70441. export interface WebVROptions {
  70442. /**
  70443. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70444. */
  70445. trackPosition?: boolean;
  70446. /**
  70447. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70448. */
  70449. positionScale?: number;
  70450. /**
  70451. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70452. */
  70453. displayName?: string;
  70454. /**
  70455. * Should the native controller meshes be initialized. (default: true)
  70456. */
  70457. controllerMeshes?: boolean;
  70458. /**
  70459. * Creating a default HemiLight only on controllers. (default: true)
  70460. */
  70461. defaultLightingOnControllers?: boolean;
  70462. /**
  70463. * If you don't want to use the default VR button of the helper. (default: false)
  70464. */
  70465. useCustomVRButton?: boolean;
  70466. /**
  70467. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70468. */
  70469. customVRButton?: HTMLButtonElement;
  70470. /**
  70471. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70472. */
  70473. rayLength?: number;
  70474. /**
  70475. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70476. */
  70477. defaultHeight?: number;
  70478. }
  70479. /**
  70480. * This represents a WebVR camera.
  70481. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70482. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70483. */
  70484. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70485. private webVROptions;
  70486. /**
  70487. * @hidden
  70488. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70489. */
  70490. _vrDevice: any;
  70491. /**
  70492. * The rawPose of the vrDevice.
  70493. */
  70494. rawPose: Nullable<DevicePose>;
  70495. private _onVREnabled;
  70496. private _specsVersion;
  70497. private _attached;
  70498. private _frameData;
  70499. protected _descendants: Array<Node>;
  70500. private _deviceRoomPosition;
  70501. /** @hidden */
  70502. _deviceRoomRotationQuaternion: Quaternion;
  70503. private _standingMatrix;
  70504. /**
  70505. * Represents device position in babylon space.
  70506. */
  70507. devicePosition: Vector3;
  70508. /**
  70509. * Represents device rotation in babylon space.
  70510. */
  70511. deviceRotationQuaternion: Quaternion;
  70512. /**
  70513. * The scale of the device to be used when translating from device space to babylon space.
  70514. */
  70515. deviceScaleFactor: number;
  70516. private _deviceToWorld;
  70517. private _worldToDevice;
  70518. /**
  70519. * References to the webVR controllers for the vrDevice.
  70520. */
  70521. controllers: Array<WebVRController>;
  70522. /**
  70523. * Emits an event when a controller is attached.
  70524. */
  70525. onControllersAttachedObservable: Observable<WebVRController[]>;
  70526. /**
  70527. * Emits an event when a controller's mesh has been loaded;
  70528. */
  70529. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70530. /**
  70531. * Emits an event when the HMD's pose has been updated.
  70532. */
  70533. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70534. private _poseSet;
  70535. /**
  70536. * If the rig cameras be used as parent instead of this camera.
  70537. */
  70538. rigParenting: boolean;
  70539. private _lightOnControllers;
  70540. private _defaultHeight?;
  70541. /**
  70542. * Instantiates a WebVRFreeCamera.
  70543. * @param name The name of the WebVRFreeCamera
  70544. * @param position The starting anchor position for the camera
  70545. * @param scene The scene the camera belongs to
  70546. * @param webVROptions a set of customizable options for the webVRCamera
  70547. */
  70548. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70549. /**
  70550. * Gets the device distance from the ground in meters.
  70551. * @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.
  70552. */
  70553. deviceDistanceToRoomGround(): number;
  70554. /**
  70555. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70556. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70557. */
  70558. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70559. /**
  70560. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70561. * @returns A promise with a boolean set to if the standing matrix is supported.
  70562. */
  70563. useStandingMatrixAsync(): Promise<boolean>;
  70564. /**
  70565. * Disposes the camera
  70566. */
  70567. dispose(): void;
  70568. /**
  70569. * Gets a vrController by name.
  70570. * @param name The name of the controller to retreive
  70571. * @returns the controller matching the name specified or null if not found
  70572. */
  70573. getControllerByName(name: string): Nullable<WebVRController>;
  70574. private _leftController;
  70575. /**
  70576. * The controller corrisponding to the users left hand.
  70577. */
  70578. readonly leftController: Nullable<WebVRController>;
  70579. private _rightController;
  70580. /**
  70581. * The controller corrisponding to the users right hand.
  70582. */
  70583. readonly rightController: Nullable<WebVRController>;
  70584. /**
  70585. * Casts a ray forward from the vrCamera's gaze.
  70586. * @param length Length of the ray (default: 100)
  70587. * @returns the ray corrisponding to the gaze
  70588. */
  70589. getForwardRay(length?: number): Ray;
  70590. /**
  70591. * @hidden
  70592. * Updates the camera based on device's frame data
  70593. */
  70594. _checkInputs(): void;
  70595. /**
  70596. * Updates the poseControlled values based on the input device pose.
  70597. * @param poseData Pose coming from the device
  70598. */
  70599. updateFromDevice(poseData: DevicePose): void;
  70600. private _htmlElementAttached;
  70601. private _detachIfAttached;
  70602. /**
  70603. * WebVR's attach control will start broadcasting frames to the device.
  70604. * Note that in certain browsers (chrome for example) this function must be called
  70605. * within a user-interaction callback. Example:
  70606. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70607. *
  70608. * @param element html element to attach the vrDevice to
  70609. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70610. */
  70611. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70612. /**
  70613. * Detaches the camera from the html element and disables VR
  70614. *
  70615. * @param element html element to detach from
  70616. */
  70617. detachControl(element: HTMLElement): void;
  70618. /**
  70619. * @returns the name of this class
  70620. */
  70621. getClassName(): string;
  70622. /**
  70623. * Calls resetPose on the vrDisplay
  70624. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70625. */
  70626. resetToCurrentRotation(): void;
  70627. /**
  70628. * @hidden
  70629. * Updates the rig cameras (left and right eye)
  70630. */
  70631. _updateRigCameras(): void;
  70632. private _workingVector;
  70633. private _oneVector;
  70634. private _workingMatrix;
  70635. private updateCacheCalled;
  70636. private _correctPositionIfNotTrackPosition;
  70637. /**
  70638. * @hidden
  70639. * Updates the cached values of the camera
  70640. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70641. */
  70642. _updateCache(ignoreParentClass?: boolean): void;
  70643. /**
  70644. * @hidden
  70645. * Get current device position in babylon world
  70646. */
  70647. _computeDevicePosition(): void;
  70648. /**
  70649. * Updates the current device position and rotation in the babylon world
  70650. */
  70651. update(): void;
  70652. /**
  70653. * @hidden
  70654. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70655. * @returns an identity matrix
  70656. */
  70657. _getViewMatrix(): Matrix;
  70658. private _tmpMatrix;
  70659. /**
  70660. * This function is called by the two RIG cameras.
  70661. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70662. * @hidden
  70663. */
  70664. _getWebVRViewMatrix(): Matrix;
  70665. /** @hidden */
  70666. _getWebVRProjectionMatrix(): Matrix;
  70667. private _onGamepadConnectedObserver;
  70668. private _onGamepadDisconnectedObserver;
  70669. private _updateCacheWhenTrackingDisabledObserver;
  70670. /**
  70671. * Initializes the controllers and their meshes
  70672. */
  70673. initControllers(): void;
  70674. }
  70675. }
  70676. declare module BABYLON {
  70677. /**
  70678. * Size options for a post process
  70679. */
  70680. export type PostProcessOptions = {
  70681. width: number;
  70682. height: number;
  70683. };
  70684. /**
  70685. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70686. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70687. */
  70688. export class PostProcess {
  70689. /** Name of the PostProcess. */
  70690. name: string;
  70691. /**
  70692. * Gets or sets the unique id of the post process
  70693. */
  70694. uniqueId: number;
  70695. /**
  70696. * Width of the texture to apply the post process on
  70697. */
  70698. width: number;
  70699. /**
  70700. * Height of the texture to apply the post process on
  70701. */
  70702. height: number;
  70703. /**
  70704. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70705. * @hidden
  70706. */
  70707. _outputTexture: Nullable<InternalTexture>;
  70708. /**
  70709. * Sampling mode used by the shader
  70710. * See https://doc.babylonjs.com/classes/3.1/texture
  70711. */
  70712. renderTargetSamplingMode: number;
  70713. /**
  70714. * Clear color to use when screen clearing
  70715. */
  70716. clearColor: Color4;
  70717. /**
  70718. * If the buffer needs to be cleared before applying the post process. (default: true)
  70719. * Should be set to false if shader will overwrite all previous pixels.
  70720. */
  70721. autoClear: boolean;
  70722. /**
  70723. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70724. */
  70725. alphaMode: number;
  70726. /**
  70727. * Sets the setAlphaBlendConstants of the babylon engine
  70728. */
  70729. alphaConstants: Color4;
  70730. /**
  70731. * Animations to be used for the post processing
  70732. */
  70733. animations: Animation[];
  70734. /**
  70735. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70736. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70737. */
  70738. enablePixelPerfectMode: boolean;
  70739. /**
  70740. * Force the postprocess to be applied without taking in account viewport
  70741. */
  70742. forceFullscreenViewport: boolean;
  70743. /**
  70744. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70745. *
  70746. * | Value | Type | Description |
  70747. * | ----- | ----------------------------------- | ----------- |
  70748. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70749. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70750. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70751. *
  70752. */
  70753. scaleMode: number;
  70754. /**
  70755. * Force textures to be a power of two (default: false)
  70756. */
  70757. alwaysForcePOT: boolean;
  70758. private _samples;
  70759. /**
  70760. * Number of sample textures (default: 1)
  70761. */
  70762. samples: number;
  70763. /**
  70764. * Modify the scale of the post process to be the same as the viewport (default: false)
  70765. */
  70766. adaptScaleToCurrentViewport: boolean;
  70767. private _camera;
  70768. private _scene;
  70769. private _engine;
  70770. private _options;
  70771. private _reusable;
  70772. private _textureType;
  70773. /**
  70774. * Smart array of input and output textures for the post process.
  70775. * @hidden
  70776. */
  70777. _textures: SmartArray<InternalTexture>;
  70778. /**
  70779. * The index in _textures that corresponds to the output texture.
  70780. * @hidden
  70781. */
  70782. _currentRenderTextureInd: number;
  70783. private _effect;
  70784. private _samplers;
  70785. private _fragmentUrl;
  70786. private _vertexUrl;
  70787. private _parameters;
  70788. private _scaleRatio;
  70789. protected _indexParameters: any;
  70790. private _shareOutputWithPostProcess;
  70791. private _texelSize;
  70792. private _forcedOutputTexture;
  70793. /**
  70794. * Returns the fragment url or shader name used in the post process.
  70795. * @returns the fragment url or name in the shader store.
  70796. */
  70797. getEffectName(): string;
  70798. /**
  70799. * An event triggered when the postprocess is activated.
  70800. */
  70801. onActivateObservable: Observable<Camera>;
  70802. private _onActivateObserver;
  70803. /**
  70804. * A function that is added to the onActivateObservable
  70805. */
  70806. onActivate: Nullable<(camera: Camera) => void>;
  70807. /**
  70808. * An event triggered when the postprocess changes its size.
  70809. */
  70810. onSizeChangedObservable: Observable<PostProcess>;
  70811. private _onSizeChangedObserver;
  70812. /**
  70813. * A function that is added to the onSizeChangedObservable
  70814. */
  70815. onSizeChanged: (postProcess: PostProcess) => void;
  70816. /**
  70817. * An event triggered when the postprocess applies its effect.
  70818. */
  70819. onApplyObservable: Observable<Effect>;
  70820. private _onApplyObserver;
  70821. /**
  70822. * A function that is added to the onApplyObservable
  70823. */
  70824. onApply: (effect: Effect) => void;
  70825. /**
  70826. * An event triggered before rendering the postprocess
  70827. */
  70828. onBeforeRenderObservable: Observable<Effect>;
  70829. private _onBeforeRenderObserver;
  70830. /**
  70831. * A function that is added to the onBeforeRenderObservable
  70832. */
  70833. onBeforeRender: (effect: Effect) => void;
  70834. /**
  70835. * An event triggered after rendering the postprocess
  70836. */
  70837. onAfterRenderObservable: Observable<Effect>;
  70838. private _onAfterRenderObserver;
  70839. /**
  70840. * A function that is added to the onAfterRenderObservable
  70841. */
  70842. onAfterRender: (efect: Effect) => void;
  70843. /**
  70844. * 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
  70845. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70846. */
  70847. inputTexture: InternalTexture;
  70848. /**
  70849. * Gets the camera which post process is applied to.
  70850. * @returns The camera the post process is applied to.
  70851. */
  70852. getCamera(): Camera;
  70853. /**
  70854. * Gets the texel size of the postprocess.
  70855. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70856. */
  70857. readonly texelSize: Vector2;
  70858. /**
  70859. * Creates a new instance PostProcess
  70860. * @param name The name of the PostProcess.
  70861. * @param fragmentUrl The url of the fragment shader to be used.
  70862. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70863. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70864. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70865. * @param camera The camera to apply the render pass to.
  70866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70867. * @param engine The engine which the post process will be applied. (default: current engine)
  70868. * @param reusable If the post process can be reused on the same frame. (default: false)
  70869. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70870. * @param textureType Type of textures used when performing the post process. (default: 0)
  70871. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70872. * @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
  70873. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70874. */
  70875. constructor(
  70876. /** Name of the PostProcess. */
  70877. 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);
  70878. /**
  70879. * Gets a string idenfifying the name of the class
  70880. * @returns "PostProcess" string
  70881. */
  70882. getClassName(): string;
  70883. /**
  70884. * Gets the engine which this post process belongs to.
  70885. * @returns The engine the post process was enabled with.
  70886. */
  70887. getEngine(): Engine;
  70888. /**
  70889. * The effect that is created when initializing the post process.
  70890. * @returns The created effect corrisponding the the postprocess.
  70891. */
  70892. getEffect(): Effect;
  70893. /**
  70894. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70895. * @param postProcess The post process to share the output with.
  70896. * @returns This post process.
  70897. */
  70898. shareOutputWith(postProcess: PostProcess): PostProcess;
  70899. /**
  70900. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70901. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70902. */
  70903. useOwnOutput(): void;
  70904. /**
  70905. * Updates the effect with the current post process compile time values and recompiles the shader.
  70906. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70907. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70908. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70909. * @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
  70910. * @param onCompiled Called when the shader has been compiled.
  70911. * @param onError Called if there is an error when compiling a shader.
  70912. */
  70913. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70914. /**
  70915. * The post process is reusable if it can be used multiple times within one frame.
  70916. * @returns If the post process is reusable
  70917. */
  70918. isReusable(): boolean;
  70919. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70920. markTextureDirty(): void;
  70921. /**
  70922. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70923. * 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.
  70924. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70925. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70926. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70927. * @returns The target texture that was bound to be written to.
  70928. */
  70929. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70930. /**
  70931. * If the post process is supported.
  70932. */
  70933. readonly isSupported: boolean;
  70934. /**
  70935. * The aspect ratio of the output texture.
  70936. */
  70937. readonly aspectRatio: number;
  70938. /**
  70939. * Get a value indicating if the post-process is ready to be used
  70940. * @returns true if the post-process is ready (shader is compiled)
  70941. */
  70942. isReady(): boolean;
  70943. /**
  70944. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70945. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70946. */
  70947. apply(): Nullable<Effect>;
  70948. private _disposeTextures;
  70949. /**
  70950. * Disposes the post process.
  70951. * @param camera The camera to dispose the post process on.
  70952. */
  70953. dispose(camera?: Camera): void;
  70954. }
  70955. }
  70956. declare module BABYLON {
  70957. /**
  70958. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70959. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70960. */
  70961. export class PostProcessManager {
  70962. private _scene;
  70963. private _indexBuffer;
  70964. private _vertexBuffers;
  70965. /**
  70966. * Creates a new instance PostProcess
  70967. * @param scene The scene that the post process is associated with.
  70968. */
  70969. constructor(scene: Scene);
  70970. private _prepareBuffers;
  70971. private _buildIndexBuffer;
  70972. /**
  70973. * Rebuilds the vertex buffers of the manager.
  70974. * @hidden
  70975. */
  70976. _rebuild(): void;
  70977. /**
  70978. * Prepares a frame to be run through a post process.
  70979. * @param sourceTexture The input texture to the post procesess. (default: null)
  70980. * @param postProcesses An array of post processes to be run. (default: null)
  70981. * @returns True if the post processes were able to be run.
  70982. * @hidden
  70983. */
  70984. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70985. /**
  70986. * Manually render a set of post processes to a texture.
  70987. * @param postProcesses An array of post processes to be run.
  70988. * @param targetTexture The target texture to render to.
  70989. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70990. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70991. * @param lodLevel defines which lod of the texture to render to
  70992. */
  70993. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70994. /**
  70995. * Finalize the result of the output of the postprocesses.
  70996. * @param doNotPresent If true the result will not be displayed to the screen.
  70997. * @param targetTexture The target texture to render to.
  70998. * @param faceIndex The index of the face to bind the target texture to.
  70999. * @param postProcesses The array of post processes to render.
  71000. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71001. * @hidden
  71002. */
  71003. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71004. /**
  71005. * Disposes of the post process manager.
  71006. */
  71007. dispose(): void;
  71008. }
  71009. }
  71010. declare module BABYLON {
  71011. interface AbstractScene {
  71012. /**
  71013. * The list of layers (background and foreground) of the scene
  71014. */
  71015. layers: Array<Layer>;
  71016. }
  71017. /**
  71018. * Defines the layer scene component responsible to manage any layers
  71019. * in a given scene.
  71020. */
  71021. export class LayerSceneComponent implements ISceneComponent {
  71022. /**
  71023. * The component name helpfull to identify the component in the list of scene components.
  71024. */
  71025. readonly name: string;
  71026. /**
  71027. * The scene the component belongs to.
  71028. */
  71029. scene: Scene;
  71030. private _engine;
  71031. /**
  71032. * Creates a new instance of the component for the given scene
  71033. * @param scene Defines the scene to register the component in
  71034. */
  71035. constructor(scene: Scene);
  71036. /**
  71037. * Registers the component in a given scene
  71038. */
  71039. register(): void;
  71040. /**
  71041. * Rebuilds the elements related to this component in case of
  71042. * context lost for instance.
  71043. */
  71044. rebuild(): void;
  71045. /**
  71046. * Disposes the component and the associated ressources.
  71047. */
  71048. dispose(): void;
  71049. private _draw;
  71050. private _drawCameraPredicate;
  71051. private _drawCameraBackground;
  71052. private _drawCameraForeground;
  71053. private _drawRenderTargetPredicate;
  71054. private _drawRenderTargetBackground;
  71055. private _drawRenderTargetForeground;
  71056. }
  71057. }
  71058. declare module BABYLON {
  71059. /** @hidden */
  71060. export var layerPixelShader: {
  71061. name: string;
  71062. shader: string;
  71063. };
  71064. }
  71065. declare module BABYLON {
  71066. /** @hidden */
  71067. export var layerVertexShader: {
  71068. name: string;
  71069. shader: string;
  71070. };
  71071. }
  71072. declare module BABYLON {
  71073. /**
  71074. * This represents a full screen 2d layer.
  71075. * This can be useful to display a picture in the background of your scene for instance.
  71076. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71077. */
  71078. export class Layer {
  71079. /**
  71080. * Define the name of the layer.
  71081. */
  71082. name: string;
  71083. /**
  71084. * Define the texture the layer should display.
  71085. */
  71086. texture: Nullable<Texture>;
  71087. /**
  71088. * Is the layer in background or foreground.
  71089. */
  71090. isBackground: boolean;
  71091. /**
  71092. * Define the color of the layer (instead of texture).
  71093. */
  71094. color: Color4;
  71095. /**
  71096. * Define the scale of the layer in order to zoom in out of the texture.
  71097. */
  71098. scale: Vector2;
  71099. /**
  71100. * Define an offset for the layer in order to shift the texture.
  71101. */
  71102. offset: Vector2;
  71103. /**
  71104. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71105. */
  71106. alphaBlendingMode: number;
  71107. /**
  71108. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71109. * Alpha test will not mix with the background color in case of transparency.
  71110. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71111. */
  71112. alphaTest: boolean;
  71113. /**
  71114. * Define a mask to restrict the layer to only some of the scene cameras.
  71115. */
  71116. layerMask: number;
  71117. /**
  71118. * Define the list of render target the layer is visible into.
  71119. */
  71120. renderTargetTextures: RenderTargetTexture[];
  71121. /**
  71122. * Define if the layer is only used in renderTarget or if it also
  71123. * renders in the main frame buffer of the canvas.
  71124. */
  71125. renderOnlyInRenderTargetTextures: boolean;
  71126. private _scene;
  71127. private _vertexBuffers;
  71128. private _indexBuffer;
  71129. private _effect;
  71130. private _alphaTestEffect;
  71131. /**
  71132. * An event triggered when the layer is disposed.
  71133. */
  71134. onDisposeObservable: Observable<Layer>;
  71135. private _onDisposeObserver;
  71136. /**
  71137. * Back compatibility with callback before the onDisposeObservable existed.
  71138. * The set callback will be triggered when the layer has been disposed.
  71139. */
  71140. onDispose: () => void;
  71141. /**
  71142. * An event triggered before rendering the scene
  71143. */
  71144. onBeforeRenderObservable: Observable<Layer>;
  71145. private _onBeforeRenderObserver;
  71146. /**
  71147. * Back compatibility with callback before the onBeforeRenderObservable existed.
  71148. * The set callback will be triggered just before rendering the layer.
  71149. */
  71150. onBeforeRender: () => void;
  71151. /**
  71152. * An event triggered after rendering the scene
  71153. */
  71154. onAfterRenderObservable: Observable<Layer>;
  71155. private _onAfterRenderObserver;
  71156. /**
  71157. * Back compatibility with callback before the onAfterRenderObservable existed.
  71158. * The set callback will be triggered just after rendering the layer.
  71159. */
  71160. onAfterRender: () => void;
  71161. /**
  71162. * Instantiates a new layer.
  71163. * This represents a full screen 2d layer.
  71164. * This can be useful to display a picture in the background of your scene for instance.
  71165. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71166. * @param name Define the name of the layer in the scene
  71167. * @param imgUrl Define the url of the texture to display in the layer
  71168. * @param scene Define the scene the layer belongs to
  71169. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  71170. * @param color Defines a color for the layer
  71171. */
  71172. constructor(
  71173. /**
  71174. * Define the name of the layer.
  71175. */
  71176. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  71177. private _createIndexBuffer;
  71178. /** @hidden */
  71179. _rebuild(): void;
  71180. /**
  71181. * Renders the layer in the scene.
  71182. */
  71183. render(): void;
  71184. /**
  71185. * Disposes and releases the associated ressources.
  71186. */
  71187. dispose(): void;
  71188. }
  71189. }
  71190. declare module BABYLON {
  71191. interface AbstractScene {
  71192. /**
  71193. * The list of procedural textures added to the scene
  71194. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71195. */
  71196. proceduralTextures: Array<ProceduralTexture>;
  71197. }
  71198. /**
  71199. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  71200. * in a given scene.
  71201. */
  71202. export class ProceduralTextureSceneComponent implements ISceneComponent {
  71203. /**
  71204. * The component name helpfull to identify the component in the list of scene components.
  71205. */
  71206. readonly name: string;
  71207. /**
  71208. * The scene the component belongs to.
  71209. */
  71210. scene: Scene;
  71211. /**
  71212. * Creates a new instance of the component for the given scene
  71213. * @param scene Defines the scene to register the component in
  71214. */
  71215. constructor(scene: Scene);
  71216. /**
  71217. * Registers the component in a given scene
  71218. */
  71219. register(): void;
  71220. /**
  71221. * Rebuilds the elements related to this component in case of
  71222. * context lost for instance.
  71223. */
  71224. rebuild(): void;
  71225. /**
  71226. * Disposes the component and the associated ressources.
  71227. */
  71228. dispose(): void;
  71229. private _beforeClear;
  71230. }
  71231. }
  71232. declare module BABYLON {
  71233. /** @hidden */
  71234. export var proceduralVertexShader: {
  71235. name: string;
  71236. shader: string;
  71237. };
  71238. }
  71239. declare module BABYLON {
  71240. /**
  71241. * 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.
  71242. * This is the base class of any Procedural texture and contains most of the shareable code.
  71243. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71244. */
  71245. export class ProceduralTexture extends Texture {
  71246. isCube: boolean;
  71247. /**
  71248. * Define if the texture is enabled or not (disabled texture will not render)
  71249. */
  71250. isEnabled: boolean;
  71251. /**
  71252. * Define if the texture must be cleared before rendering (default is true)
  71253. */
  71254. autoClear: boolean;
  71255. /**
  71256. * Callback called when the texture is generated
  71257. */
  71258. onGenerated: () => void;
  71259. /**
  71260. * Event raised when the texture is generated
  71261. */
  71262. onGeneratedObservable: Observable<ProceduralTexture>;
  71263. /** @hidden */
  71264. _generateMipMaps: boolean;
  71265. /** @hidden **/
  71266. _effect: Effect;
  71267. /** @hidden */
  71268. _textures: {
  71269. [key: string]: Texture;
  71270. };
  71271. private _size;
  71272. private _currentRefreshId;
  71273. private _refreshRate;
  71274. private _vertexBuffers;
  71275. private _indexBuffer;
  71276. private _uniforms;
  71277. private _samplers;
  71278. private _fragment;
  71279. private _floats;
  71280. private _ints;
  71281. private _floatsArrays;
  71282. private _colors3;
  71283. private _colors4;
  71284. private _vectors2;
  71285. private _vectors3;
  71286. private _matrices;
  71287. private _fallbackTexture;
  71288. private _fallbackTextureUsed;
  71289. private _engine;
  71290. private _cachedDefines;
  71291. private _contentUpdateId;
  71292. private _contentData;
  71293. /**
  71294. * Instantiates a new procedural texture.
  71295. * 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.
  71296. * This is the base class of any Procedural texture and contains most of the shareable code.
  71297. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71298. * @param name Define the name of the texture
  71299. * @param size Define the size of the texture to create
  71300. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71301. * @param scene Define the scene the texture belongs to
  71302. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71303. * @param generateMipMaps Define if the texture should creates mip maps or not
  71304. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71305. */
  71306. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71307. /**
  71308. * The effect that is created when initializing the post process.
  71309. * @returns The created effect corrisponding the the postprocess.
  71310. */
  71311. getEffect(): Effect;
  71312. /**
  71313. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71314. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71315. */
  71316. getContent(): Nullable<ArrayBufferView>;
  71317. private _createIndexBuffer;
  71318. /** @hidden */
  71319. _rebuild(): void;
  71320. /**
  71321. * Resets the texture in order to recreate its associated resources.
  71322. * This can be called in case of context loss
  71323. */
  71324. reset(): void;
  71325. protected _getDefines(): string;
  71326. /**
  71327. * Is the texture ready to be used ? (rendered at least once)
  71328. * @returns true if ready, otherwise, false.
  71329. */
  71330. isReady(): boolean;
  71331. /**
  71332. * Resets the refresh counter of the texture and start bak from scratch.
  71333. * Could be useful to regenerate the texture if it is setup to render only once.
  71334. */
  71335. resetRefreshCounter(): void;
  71336. /**
  71337. * Set the fragment shader to use in order to render the texture.
  71338. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71339. */
  71340. setFragment(fragment: any): void;
  71341. /**
  71342. * Define the refresh rate of the texture or the rendering frequency.
  71343. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71344. */
  71345. refreshRate: number;
  71346. /** @hidden */
  71347. _shouldRender(): boolean;
  71348. /**
  71349. * Get the size the texture is rendering at.
  71350. * @returns the size (texture is always squared)
  71351. */
  71352. getRenderSize(): number;
  71353. /**
  71354. * Resize the texture to new value.
  71355. * @param size Define the new size the texture should have
  71356. * @param generateMipMaps Define whether the new texture should create mip maps
  71357. */
  71358. resize(size: number, generateMipMaps: boolean): void;
  71359. private _checkUniform;
  71360. /**
  71361. * Set a texture in the shader program used to render.
  71362. * @param name Define the name of the uniform samplers as defined in the shader
  71363. * @param texture Define the texture to bind to this sampler
  71364. * @return the texture itself allowing "fluent" like uniform updates
  71365. */
  71366. setTexture(name: string, texture: Texture): ProceduralTexture;
  71367. /**
  71368. * Set a float in the shader.
  71369. * @param name Define the name of the uniform as defined in the shader
  71370. * @param value Define the value to give to the uniform
  71371. * @return the texture itself allowing "fluent" like uniform updates
  71372. */
  71373. setFloat(name: string, value: number): ProceduralTexture;
  71374. /**
  71375. * Set a int in the shader.
  71376. * @param name Define the name of the uniform as defined in the shader
  71377. * @param value Define the value to give to the uniform
  71378. * @return the texture itself allowing "fluent" like uniform updates
  71379. */
  71380. setInt(name: string, value: number): ProceduralTexture;
  71381. /**
  71382. * Set an array of floats in the shader.
  71383. * @param name Define the name of the uniform as defined in the shader
  71384. * @param value Define the value to give to the uniform
  71385. * @return the texture itself allowing "fluent" like uniform updates
  71386. */
  71387. setFloats(name: string, value: number[]): ProceduralTexture;
  71388. /**
  71389. * Set a vec3 in the shader from a Color3.
  71390. * @param name Define the name of the uniform as defined in the shader
  71391. * @param value Define the value to give to the uniform
  71392. * @return the texture itself allowing "fluent" like uniform updates
  71393. */
  71394. setColor3(name: string, value: Color3): ProceduralTexture;
  71395. /**
  71396. * Set a vec4 in the shader from a Color4.
  71397. * @param name Define the name of the uniform as defined in the shader
  71398. * @param value Define the value to give to the uniform
  71399. * @return the texture itself allowing "fluent" like uniform updates
  71400. */
  71401. setColor4(name: string, value: Color4): ProceduralTexture;
  71402. /**
  71403. * Set a vec2 in the shader from a Vector2.
  71404. * @param name Define the name of the uniform as defined in the shader
  71405. * @param value Define the value to give to the uniform
  71406. * @return the texture itself allowing "fluent" like uniform updates
  71407. */
  71408. setVector2(name: string, value: Vector2): ProceduralTexture;
  71409. /**
  71410. * Set a vec3 in the shader from a Vector3.
  71411. * @param name Define the name of the uniform as defined in the shader
  71412. * @param value Define the value to give to the uniform
  71413. * @return the texture itself allowing "fluent" like uniform updates
  71414. */
  71415. setVector3(name: string, value: Vector3): ProceduralTexture;
  71416. /**
  71417. * Set a mat4 in the shader from a MAtrix.
  71418. * @param name Define the name of the uniform as defined in the shader
  71419. * @param value Define the value to give to the uniform
  71420. * @return the texture itself allowing "fluent" like uniform updates
  71421. */
  71422. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71423. /**
  71424. * Render the texture to its associated render target.
  71425. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71426. */
  71427. render(useCameraPostProcess?: boolean): void;
  71428. /**
  71429. * Clone the texture.
  71430. * @returns the cloned texture
  71431. */
  71432. clone(): ProceduralTexture;
  71433. /**
  71434. * Dispose the texture and release its asoociated resources.
  71435. */
  71436. dispose(): void;
  71437. }
  71438. }
  71439. declare module BABYLON {
  71440. /**
  71441. * This represents the base class for particle system in Babylon.
  71442. * 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.
  71443. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71444. * @example https://doc.babylonjs.com/babylon101/particles
  71445. */
  71446. export class BaseParticleSystem {
  71447. /**
  71448. * Source color is added to the destination color without alpha affecting the result
  71449. */
  71450. static BLENDMODE_ONEONE: number;
  71451. /**
  71452. * Blend current color and particle color using particle’s alpha
  71453. */
  71454. static BLENDMODE_STANDARD: number;
  71455. /**
  71456. * Add current color and particle color multiplied by particle’s alpha
  71457. */
  71458. static BLENDMODE_ADD: number;
  71459. /**
  71460. * Multiply current color with particle color
  71461. */
  71462. static BLENDMODE_MULTIPLY: number;
  71463. /**
  71464. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71465. */
  71466. static BLENDMODE_MULTIPLYADD: number;
  71467. /**
  71468. * List of animations used by the particle system.
  71469. */
  71470. animations: Animation[];
  71471. /**
  71472. * The id of the Particle system.
  71473. */
  71474. id: string;
  71475. /**
  71476. * The friendly name of the Particle system.
  71477. */
  71478. name: string;
  71479. /**
  71480. * The rendering group used by the Particle system to chose when to render.
  71481. */
  71482. renderingGroupId: number;
  71483. /**
  71484. * The emitter represents the Mesh or position we are attaching the particle system to.
  71485. */
  71486. emitter: Nullable<AbstractMesh | Vector3>;
  71487. /**
  71488. * The maximum number of particles to emit per frame
  71489. */
  71490. emitRate: number;
  71491. /**
  71492. * If you want to launch only a few particles at once, that can be done, as well.
  71493. */
  71494. manualEmitCount: number;
  71495. /**
  71496. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71497. */
  71498. updateSpeed: number;
  71499. /**
  71500. * The amount of time the particle system is running (depends of the overall update speed).
  71501. */
  71502. targetStopDuration: number;
  71503. /**
  71504. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71505. */
  71506. disposeOnStop: boolean;
  71507. /**
  71508. * Minimum power of emitting particles.
  71509. */
  71510. minEmitPower: number;
  71511. /**
  71512. * Maximum power of emitting particles.
  71513. */
  71514. maxEmitPower: number;
  71515. /**
  71516. * Minimum life time of emitting particles.
  71517. */
  71518. minLifeTime: number;
  71519. /**
  71520. * Maximum life time of emitting particles.
  71521. */
  71522. maxLifeTime: number;
  71523. /**
  71524. * Minimum Size of emitting particles.
  71525. */
  71526. minSize: number;
  71527. /**
  71528. * Maximum Size of emitting particles.
  71529. */
  71530. maxSize: number;
  71531. /**
  71532. * Minimum scale of emitting particles on X axis.
  71533. */
  71534. minScaleX: number;
  71535. /**
  71536. * Maximum scale of emitting particles on X axis.
  71537. */
  71538. maxScaleX: number;
  71539. /**
  71540. * Minimum scale of emitting particles on Y axis.
  71541. */
  71542. minScaleY: number;
  71543. /**
  71544. * Maximum scale of emitting particles on Y axis.
  71545. */
  71546. maxScaleY: number;
  71547. /**
  71548. * Gets or sets the minimal initial rotation in radians.
  71549. */
  71550. minInitialRotation: number;
  71551. /**
  71552. * Gets or sets the maximal initial rotation in radians.
  71553. */
  71554. maxInitialRotation: number;
  71555. /**
  71556. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71557. */
  71558. minAngularSpeed: number;
  71559. /**
  71560. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71561. */
  71562. maxAngularSpeed: number;
  71563. /**
  71564. * The texture used to render each particle. (this can be a spritesheet)
  71565. */
  71566. particleTexture: Nullable<Texture>;
  71567. /**
  71568. * The layer mask we are rendering the particles through.
  71569. */
  71570. layerMask: number;
  71571. /**
  71572. * This can help using your own shader to render the particle system.
  71573. * The according effect will be created
  71574. */
  71575. customShader: any;
  71576. /**
  71577. * By default particle system starts as soon as they are created. This prevents the
  71578. * automatic start to happen and let you decide when to start emitting particles.
  71579. */
  71580. preventAutoStart: boolean;
  71581. private _noiseTexture;
  71582. /**
  71583. * Gets or sets a texture used to add random noise to particle positions
  71584. */
  71585. noiseTexture: Nullable<ProceduralTexture>;
  71586. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71587. noiseStrength: Vector3;
  71588. /**
  71589. * Callback triggered when the particle animation is ending.
  71590. */
  71591. onAnimationEnd: Nullable<() => void>;
  71592. /**
  71593. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71594. */
  71595. blendMode: number;
  71596. /**
  71597. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71598. * to override the particles.
  71599. */
  71600. forceDepthWrite: boolean;
  71601. /** 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 */
  71602. preWarmCycles: number;
  71603. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71604. preWarmStepOffset: number;
  71605. /**
  71606. * 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)
  71607. */
  71608. spriteCellChangeSpeed: number;
  71609. /**
  71610. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71611. */
  71612. startSpriteCellID: number;
  71613. /**
  71614. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71615. */
  71616. endSpriteCellID: number;
  71617. /**
  71618. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71619. */
  71620. spriteCellWidth: number;
  71621. /**
  71622. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71623. */
  71624. spriteCellHeight: number;
  71625. /**
  71626. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71627. */
  71628. spriteRandomStartCell: boolean;
  71629. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71630. translationPivot: Vector2;
  71631. /** @hidden */
  71632. protected _isAnimationSheetEnabled: boolean;
  71633. /**
  71634. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71635. */
  71636. beginAnimationOnStart: boolean;
  71637. /**
  71638. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71639. */
  71640. beginAnimationFrom: number;
  71641. /**
  71642. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71643. */
  71644. beginAnimationTo: number;
  71645. /**
  71646. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71647. */
  71648. beginAnimationLoop: boolean;
  71649. /**
  71650. * Gets or sets a world offset applied to all particles
  71651. */
  71652. worldOffset: Vector3;
  71653. /**
  71654. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71655. */
  71656. isAnimationSheetEnabled: boolean;
  71657. /**
  71658. * Get hosting scene
  71659. * @returns the scene
  71660. */
  71661. getScene(): Scene;
  71662. /**
  71663. * You can use gravity if you want to give an orientation to your particles.
  71664. */
  71665. gravity: Vector3;
  71666. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71667. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71668. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71669. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71670. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71671. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71672. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71673. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71674. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71675. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71676. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71677. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71678. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71679. /**
  71680. * Defines the delay in milliseconds before starting the system (0 by default)
  71681. */
  71682. startDelay: number;
  71683. /**
  71684. * Gets the current list of drag gradients.
  71685. * You must use addDragGradient and removeDragGradient to udpate this list
  71686. * @returns the list of drag gradients
  71687. */
  71688. getDragGradients(): Nullable<Array<FactorGradient>>;
  71689. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71690. limitVelocityDamping: number;
  71691. /**
  71692. * Gets the current list of limit velocity gradients.
  71693. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71694. * @returns the list of limit velocity gradients
  71695. */
  71696. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71697. /**
  71698. * Gets the current list of color gradients.
  71699. * You must use addColorGradient and removeColorGradient to udpate this list
  71700. * @returns the list of color gradients
  71701. */
  71702. getColorGradients(): Nullable<Array<ColorGradient>>;
  71703. /**
  71704. * Gets the current list of size gradients.
  71705. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71706. * @returns the list of size gradients
  71707. */
  71708. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71709. /**
  71710. * Gets the current list of color remap gradients.
  71711. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71712. * @returns the list of color remap gradients
  71713. */
  71714. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71715. /**
  71716. * Gets the current list of alpha remap gradients.
  71717. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71718. * @returns the list of alpha remap gradients
  71719. */
  71720. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71721. /**
  71722. * Gets the current list of life time gradients.
  71723. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71724. * @returns the list of life time gradients
  71725. */
  71726. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71727. /**
  71728. * Gets the current list of angular speed gradients.
  71729. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71730. * @returns the list of angular speed gradients
  71731. */
  71732. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71733. /**
  71734. * Gets the current list of velocity gradients.
  71735. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71736. * @returns the list of velocity gradients
  71737. */
  71738. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71739. /**
  71740. * Gets the current list of start size gradients.
  71741. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71742. * @returns the list of start size gradients
  71743. */
  71744. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71745. /**
  71746. * Gets the current list of emit rate gradients.
  71747. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71748. * @returns the list of emit rate gradients
  71749. */
  71750. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71751. /**
  71752. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71753. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71754. */
  71755. direction1: Vector3;
  71756. /**
  71757. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71758. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71759. */
  71760. direction2: Vector3;
  71761. /**
  71762. * 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.
  71763. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71764. */
  71765. minEmitBox: Vector3;
  71766. /**
  71767. * 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.
  71768. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71769. */
  71770. maxEmitBox: Vector3;
  71771. /**
  71772. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71773. */
  71774. color1: Color4;
  71775. /**
  71776. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71777. */
  71778. color2: Color4;
  71779. /**
  71780. * Color the particle will have at the end of its lifetime
  71781. */
  71782. colorDead: Color4;
  71783. /**
  71784. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71785. */
  71786. textureMask: Color4;
  71787. /**
  71788. * The particle emitter type defines the emitter used by the particle system.
  71789. * It can be for example box, sphere, or cone...
  71790. */
  71791. particleEmitterType: IParticleEmitterType;
  71792. /** @hidden */
  71793. _isSubEmitter: boolean;
  71794. /**
  71795. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71796. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71797. */
  71798. billboardMode: number;
  71799. protected _isBillboardBased: boolean;
  71800. /**
  71801. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71802. */
  71803. isBillboardBased: boolean;
  71804. /**
  71805. * The scene the particle system belongs to.
  71806. */
  71807. protected _scene: Scene;
  71808. /**
  71809. * Local cache of defines for image processing.
  71810. */
  71811. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71812. /**
  71813. * Default configuration related to image processing available in the standard Material.
  71814. */
  71815. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71816. /**
  71817. * Gets the image processing configuration used either in this material.
  71818. */
  71819. /**
  71820. * Sets the Default image processing configuration used either in the this material.
  71821. *
  71822. * If sets to null, the scene one is in use.
  71823. */
  71824. imageProcessingConfiguration: ImageProcessingConfiguration;
  71825. /**
  71826. * Attaches a new image processing configuration to the Standard Material.
  71827. * @param configuration
  71828. */
  71829. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71830. /** @hidden */
  71831. protected _reset(): void;
  71832. /** @hidden */
  71833. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71834. /**
  71835. * Instantiates a particle system.
  71836. * 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.
  71837. * @param name The name of the particle system
  71838. */
  71839. constructor(name: string);
  71840. /**
  71841. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71842. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71843. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71844. * @returns the emitter
  71845. */
  71846. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71847. /**
  71848. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71849. * @param radius The radius of the hemisphere to emit from
  71850. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71851. * @returns the emitter
  71852. */
  71853. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71854. /**
  71855. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71856. * @param radius The radius of the sphere to emit from
  71857. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71858. * @returns the emitter
  71859. */
  71860. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71861. /**
  71862. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71863. * @param radius The radius of the sphere to emit from
  71864. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71865. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71866. * @returns the emitter
  71867. */
  71868. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71869. /**
  71870. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71871. * @param radius The radius of the emission cylinder
  71872. * @param height The height of the emission cylinder
  71873. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71874. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71875. * @returns the emitter
  71876. */
  71877. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71878. /**
  71879. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71880. * @param radius The radius of the cylinder to emit from
  71881. * @param height The height of the emission cylinder
  71882. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71883. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71884. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71885. * @returns the emitter
  71886. */
  71887. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71888. /**
  71889. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71890. * @param radius The radius of the cone to emit from
  71891. * @param angle The base angle of the cone
  71892. * @returns the emitter
  71893. */
  71894. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71895. /**
  71896. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71897. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71898. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71899. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71900. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71901. * @returns the emitter
  71902. */
  71903. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71904. }
  71905. }
  71906. declare module BABYLON {
  71907. /**
  71908. * Type of sub emitter
  71909. */
  71910. export enum SubEmitterType {
  71911. /**
  71912. * Attached to the particle over it's lifetime
  71913. */
  71914. ATTACHED = 0,
  71915. /**
  71916. * Created when the particle dies
  71917. */
  71918. END = 1
  71919. }
  71920. /**
  71921. * Sub emitter class used to emit particles from an existing particle
  71922. */
  71923. export class SubEmitter {
  71924. /**
  71925. * the particle system to be used by the sub emitter
  71926. */
  71927. particleSystem: ParticleSystem;
  71928. /**
  71929. * Type of the submitter (Default: END)
  71930. */
  71931. type: SubEmitterType;
  71932. /**
  71933. * 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)
  71934. * Note: This only is supported when using an emitter of type Mesh
  71935. */
  71936. inheritDirection: boolean;
  71937. /**
  71938. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71939. */
  71940. inheritedVelocityAmount: number;
  71941. /**
  71942. * Creates a sub emitter
  71943. * @param particleSystem the particle system to be used by the sub emitter
  71944. */
  71945. constructor(
  71946. /**
  71947. * the particle system to be used by the sub emitter
  71948. */
  71949. particleSystem: ParticleSystem);
  71950. /**
  71951. * Clones the sub emitter
  71952. * @returns the cloned sub emitter
  71953. */
  71954. clone(): SubEmitter;
  71955. /**
  71956. * Serialize current object to a JSON object
  71957. * @returns the serialized object
  71958. */
  71959. serialize(): any;
  71960. /** @hidden */
  71961. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71962. /**
  71963. * Creates a new SubEmitter from a serialized JSON version
  71964. * @param serializationObject defines the JSON object to read from
  71965. * @param scene defines the hosting scene
  71966. * @param rootUrl defines the rootUrl for data loading
  71967. * @returns a new SubEmitter
  71968. */
  71969. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71970. /** Release associated resources */
  71971. dispose(): void;
  71972. }
  71973. }
  71974. declare module BABYLON {
  71975. /** @hidden */
  71976. export var clipPlaneFragmentDeclaration: {
  71977. name: string;
  71978. shader: string;
  71979. };
  71980. }
  71981. declare module BABYLON {
  71982. /** @hidden */
  71983. export var imageProcessingDeclaration: {
  71984. name: string;
  71985. shader: string;
  71986. };
  71987. }
  71988. declare module BABYLON {
  71989. /** @hidden */
  71990. export var imageProcessingFunctions: {
  71991. name: string;
  71992. shader: string;
  71993. };
  71994. }
  71995. declare module BABYLON {
  71996. /** @hidden */
  71997. export var clipPlaneFragment: {
  71998. name: string;
  71999. shader: string;
  72000. };
  72001. }
  72002. declare module BABYLON {
  72003. /** @hidden */
  72004. export var particlesPixelShader: {
  72005. name: string;
  72006. shader: string;
  72007. };
  72008. }
  72009. declare module BABYLON {
  72010. /** @hidden */
  72011. export var clipPlaneVertexDeclaration: {
  72012. name: string;
  72013. shader: string;
  72014. };
  72015. }
  72016. declare module BABYLON {
  72017. /** @hidden */
  72018. export var clipPlaneVertex: {
  72019. name: string;
  72020. shader: string;
  72021. };
  72022. }
  72023. declare module BABYLON {
  72024. /** @hidden */
  72025. export var particlesVertexShader: {
  72026. name: string;
  72027. shader: string;
  72028. };
  72029. }
  72030. declare module BABYLON {
  72031. /**
  72032. * This represents a particle system in Babylon.
  72033. * 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.
  72034. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72035. * @example https://doc.babylonjs.com/babylon101/particles
  72036. */
  72037. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72038. /**
  72039. * Billboard mode will only apply to Y axis
  72040. */
  72041. static readonly BILLBOARDMODE_Y: number;
  72042. /**
  72043. * Billboard mode will apply to all axes
  72044. */
  72045. static readonly BILLBOARDMODE_ALL: number;
  72046. /**
  72047. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72048. */
  72049. static readonly BILLBOARDMODE_STRETCHED: number;
  72050. /**
  72051. * This function can be defined to provide custom update for active particles.
  72052. * This function will be called instead of regular update (age, position, color, etc.).
  72053. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72054. */
  72055. updateFunction: (particles: Particle[]) => void;
  72056. private _emitterWorldMatrix;
  72057. /**
  72058. * This function can be defined to specify initial direction for every new particle.
  72059. * It by default use the emitterType defined function
  72060. */
  72061. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72062. /**
  72063. * This function can be defined to specify initial position for every new particle.
  72064. * It by default use the emitterType defined function
  72065. */
  72066. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72067. /**
  72068. * @hidden
  72069. */
  72070. _inheritedVelocityOffset: Vector3;
  72071. /**
  72072. * An event triggered when the system is disposed
  72073. */
  72074. onDisposeObservable: Observable<ParticleSystem>;
  72075. private _onDisposeObserver;
  72076. /**
  72077. * Sets a callback that will be triggered when the system is disposed
  72078. */
  72079. onDispose: () => void;
  72080. private _particles;
  72081. private _epsilon;
  72082. private _capacity;
  72083. private _stockParticles;
  72084. private _newPartsExcess;
  72085. private _vertexData;
  72086. private _vertexBuffer;
  72087. private _vertexBuffers;
  72088. private _spriteBuffer;
  72089. private _indexBuffer;
  72090. private _effect;
  72091. private _customEffect;
  72092. private _cachedDefines;
  72093. private _scaledColorStep;
  72094. private _colorDiff;
  72095. private _scaledDirection;
  72096. private _scaledGravity;
  72097. private _currentRenderId;
  72098. private _alive;
  72099. private _useInstancing;
  72100. private _started;
  72101. private _stopped;
  72102. private _actualFrame;
  72103. private _scaledUpdateSpeed;
  72104. private _vertexBufferSize;
  72105. /** @hidden */
  72106. _currentEmitRateGradient: Nullable<FactorGradient>;
  72107. /** @hidden */
  72108. _currentEmitRate1: number;
  72109. /** @hidden */
  72110. _currentEmitRate2: number;
  72111. /** @hidden */
  72112. _currentStartSizeGradient: Nullable<FactorGradient>;
  72113. /** @hidden */
  72114. _currentStartSize1: number;
  72115. /** @hidden */
  72116. _currentStartSize2: number;
  72117. private readonly _rawTextureWidth;
  72118. private _rampGradientsTexture;
  72119. private _useRampGradients;
  72120. /** Gets or sets a boolean indicating that ramp gradients must be used
  72121. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72122. */
  72123. useRampGradients: boolean;
  72124. /**
  72125. * 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.
  72126. * 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: [])
  72127. */
  72128. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  72129. private _subEmitters;
  72130. /**
  72131. * @hidden
  72132. * If the particle systems emitter should be disposed when the particle system is disposed
  72133. */
  72134. _disposeEmitterOnDispose: boolean;
  72135. /**
  72136. * The current active Sub-systems, this property is used by the root particle system only.
  72137. */
  72138. activeSubSystems: Array<ParticleSystem>;
  72139. private _rootParticleSystem;
  72140. /**
  72141. * Gets the current list of active particles
  72142. */
  72143. readonly particles: Particle[];
  72144. /**
  72145. * Returns the string "ParticleSystem"
  72146. * @returns a string containing the class name
  72147. */
  72148. getClassName(): string;
  72149. /**
  72150. * Instantiates a particle system.
  72151. * 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.
  72152. * @param name The name of the particle system
  72153. * @param capacity The max number of particles alive at the same time
  72154. * @param scene The scene the particle system belongs to
  72155. * @param customEffect a custom effect used to change the way particles are rendered by default
  72156. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72157. * @param epsilon Offset used to render the particles
  72158. */
  72159. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  72160. private _addFactorGradient;
  72161. private _removeFactorGradient;
  72162. /**
  72163. * Adds a new life time gradient
  72164. * @param gradient defines the gradient to use (between 0 and 1)
  72165. * @param factor defines the life time factor to affect to the specified gradient
  72166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72167. * @returns the current particle system
  72168. */
  72169. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72170. /**
  72171. * Remove a specific life time gradient
  72172. * @param gradient defines the gradient to remove
  72173. * @returns the current particle system
  72174. */
  72175. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72176. /**
  72177. * Adds a new size gradient
  72178. * @param gradient defines the gradient to use (between 0 and 1)
  72179. * @param factor defines the size factor to affect to the specified gradient
  72180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72181. * @returns the current particle system
  72182. */
  72183. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72184. /**
  72185. * Remove a specific size gradient
  72186. * @param gradient defines the gradient to remove
  72187. * @returns the current particle system
  72188. */
  72189. removeSizeGradient(gradient: number): IParticleSystem;
  72190. /**
  72191. * Adds a new color remap gradient
  72192. * @param gradient defines the gradient to use (between 0 and 1)
  72193. * @param min defines the color remap minimal range
  72194. * @param max defines the color remap maximal range
  72195. * @returns the current particle system
  72196. */
  72197. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72198. /**
  72199. * Remove a specific color remap gradient
  72200. * @param gradient defines the gradient to remove
  72201. * @returns the current particle system
  72202. */
  72203. removeColorRemapGradient(gradient: number): IParticleSystem;
  72204. /**
  72205. * Adds a new alpha remap gradient
  72206. * @param gradient defines the gradient to use (between 0 and 1)
  72207. * @param min defines the alpha remap minimal range
  72208. * @param max defines the alpha remap maximal range
  72209. * @returns the current particle system
  72210. */
  72211. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72212. /**
  72213. * Remove a specific alpha remap gradient
  72214. * @param gradient defines the gradient to remove
  72215. * @returns the current particle system
  72216. */
  72217. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72218. /**
  72219. * Adds a new angular speed gradient
  72220. * @param gradient defines the gradient to use (between 0 and 1)
  72221. * @param factor defines the angular speed to affect to the specified gradient
  72222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72223. * @returns the current particle system
  72224. */
  72225. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72226. /**
  72227. * Remove a specific angular speed gradient
  72228. * @param gradient defines the gradient to remove
  72229. * @returns the current particle system
  72230. */
  72231. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72232. /**
  72233. * Adds a new velocity gradient
  72234. * @param gradient defines the gradient to use (between 0 and 1)
  72235. * @param factor defines the velocity to affect to the specified gradient
  72236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72237. * @returns the current particle system
  72238. */
  72239. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72240. /**
  72241. * Remove a specific velocity gradient
  72242. * @param gradient defines the gradient to remove
  72243. * @returns the current particle system
  72244. */
  72245. removeVelocityGradient(gradient: number): IParticleSystem;
  72246. /**
  72247. * Adds a new limit velocity gradient
  72248. * @param gradient defines the gradient to use (between 0 and 1)
  72249. * @param factor defines the limit velocity value to affect to the specified gradient
  72250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72251. * @returns the current particle system
  72252. */
  72253. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72254. /**
  72255. * Remove a specific limit velocity gradient
  72256. * @param gradient defines the gradient to remove
  72257. * @returns the current particle system
  72258. */
  72259. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72260. /**
  72261. * Adds a new drag gradient
  72262. * @param gradient defines the gradient to use (between 0 and 1)
  72263. * @param factor defines the drag value to affect to the specified gradient
  72264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72265. * @returns the current particle system
  72266. */
  72267. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72268. /**
  72269. * Remove a specific drag gradient
  72270. * @param gradient defines the gradient to remove
  72271. * @returns the current particle system
  72272. */
  72273. removeDragGradient(gradient: number): IParticleSystem;
  72274. /**
  72275. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72276. * @param gradient defines the gradient to use (between 0 and 1)
  72277. * @param factor defines the emit rate value to affect to the specified gradient
  72278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72279. * @returns the current particle system
  72280. */
  72281. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72282. /**
  72283. * Remove a specific emit rate gradient
  72284. * @param gradient defines the gradient to remove
  72285. * @returns the current particle system
  72286. */
  72287. removeEmitRateGradient(gradient: number): IParticleSystem;
  72288. /**
  72289. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72290. * @param gradient defines the gradient to use (between 0 and 1)
  72291. * @param factor defines the start size value to affect to the specified gradient
  72292. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72293. * @returns the current particle system
  72294. */
  72295. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72296. /**
  72297. * Remove a specific start size gradient
  72298. * @param gradient defines the gradient to remove
  72299. * @returns the current particle system
  72300. */
  72301. removeStartSizeGradient(gradient: number): IParticleSystem;
  72302. private _createRampGradientTexture;
  72303. /**
  72304. * Gets the current list of ramp gradients.
  72305. * You must use addRampGradient and removeRampGradient to udpate this list
  72306. * @returns the list of ramp gradients
  72307. */
  72308. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72309. /**
  72310. * Adds a new ramp gradient used to remap particle colors
  72311. * @param gradient defines the gradient to use (between 0 and 1)
  72312. * @param color defines the color to affect to the specified gradient
  72313. * @returns the current particle system
  72314. */
  72315. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72316. /**
  72317. * Remove a specific ramp gradient
  72318. * @param gradient defines the gradient to remove
  72319. * @returns the current particle system
  72320. */
  72321. removeRampGradient(gradient: number): ParticleSystem;
  72322. /**
  72323. * Adds a new color gradient
  72324. * @param gradient defines the gradient to use (between 0 and 1)
  72325. * @param color1 defines the color to affect to the specified gradient
  72326. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72327. * @returns this particle system
  72328. */
  72329. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72330. /**
  72331. * Remove a specific color gradient
  72332. * @param gradient defines the gradient to remove
  72333. * @returns this particle system
  72334. */
  72335. removeColorGradient(gradient: number): IParticleSystem;
  72336. private _fetchR;
  72337. protected _reset(): void;
  72338. private _resetEffect;
  72339. private _createVertexBuffers;
  72340. private _createIndexBuffer;
  72341. /**
  72342. * Gets the maximum number of particles active at the same time.
  72343. * @returns The max number of active particles.
  72344. */
  72345. getCapacity(): number;
  72346. /**
  72347. * Gets whether there are still active particles in the system.
  72348. * @returns True if it is alive, otherwise false.
  72349. */
  72350. isAlive(): boolean;
  72351. /**
  72352. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72353. * @returns True if it has been started, otherwise false.
  72354. */
  72355. isStarted(): boolean;
  72356. private _prepareSubEmitterInternalArray;
  72357. /**
  72358. * Starts the particle system and begins to emit
  72359. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72360. */
  72361. start(delay?: number): void;
  72362. /**
  72363. * Stops the particle system.
  72364. * @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.
  72365. */
  72366. stop(stopSubEmitters?: boolean): void;
  72367. /**
  72368. * Remove all active particles
  72369. */
  72370. reset(): void;
  72371. /**
  72372. * @hidden (for internal use only)
  72373. */
  72374. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72375. /**
  72376. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72377. * Its lifetime will start back at 0.
  72378. */
  72379. recycleParticle: (particle: Particle) => void;
  72380. private _stopSubEmitters;
  72381. private _createParticle;
  72382. private _removeFromRoot;
  72383. private _emitFromParticle;
  72384. private _update;
  72385. /** @hidden */
  72386. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72387. /** @hidden */
  72388. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72389. /** @hidden */
  72390. private _getEffect;
  72391. /**
  72392. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72393. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72394. */
  72395. animate(preWarmOnly?: boolean): void;
  72396. private _appendParticleVertices;
  72397. /**
  72398. * Rebuilds the particle system.
  72399. */
  72400. rebuild(): void;
  72401. /**
  72402. * Is this system ready to be used/rendered
  72403. * @return true if the system is ready
  72404. */
  72405. isReady(): boolean;
  72406. private _render;
  72407. /**
  72408. * Renders the particle system in its current state.
  72409. * @returns the current number of particles
  72410. */
  72411. render(): number;
  72412. /**
  72413. * Disposes the particle system and free the associated resources
  72414. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72415. */
  72416. dispose(disposeTexture?: boolean): void;
  72417. /**
  72418. * Clones the particle system.
  72419. * @param name The name of the cloned object
  72420. * @param newEmitter The new emitter to use
  72421. * @returns the cloned particle system
  72422. */
  72423. clone(name: string, newEmitter: any): ParticleSystem;
  72424. /**
  72425. * Serializes the particle system to a JSON object.
  72426. * @returns the JSON object
  72427. */
  72428. serialize(): any;
  72429. /** @hidden */
  72430. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72431. /** @hidden */
  72432. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72433. /**
  72434. * Parses a JSON object to create a particle system.
  72435. * @param parsedParticleSystem The JSON object to parse
  72436. * @param scene The scene to create the particle system in
  72437. * @param rootUrl The root url to use to load external dependencies like texture
  72438. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72439. * @returns the Parsed particle system
  72440. */
  72441. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72442. }
  72443. }
  72444. declare module BABYLON {
  72445. /**
  72446. * A particle represents one of the element emitted by a particle system.
  72447. * This is mainly define by its coordinates, direction, velocity and age.
  72448. */
  72449. export class Particle {
  72450. /**
  72451. * The particle system the particle belongs to.
  72452. */
  72453. particleSystem: ParticleSystem;
  72454. private static _Count;
  72455. /**
  72456. * Unique ID of the particle
  72457. */
  72458. id: number;
  72459. /**
  72460. * The world position of the particle in the scene.
  72461. */
  72462. position: Vector3;
  72463. /**
  72464. * The world direction of the particle in the scene.
  72465. */
  72466. direction: Vector3;
  72467. /**
  72468. * The color of the particle.
  72469. */
  72470. color: Color4;
  72471. /**
  72472. * The color change of the particle per step.
  72473. */
  72474. colorStep: Color4;
  72475. /**
  72476. * Defines how long will the life of the particle be.
  72477. */
  72478. lifeTime: number;
  72479. /**
  72480. * The current age of the particle.
  72481. */
  72482. age: number;
  72483. /**
  72484. * The current size of the particle.
  72485. */
  72486. size: number;
  72487. /**
  72488. * The current scale of the particle.
  72489. */
  72490. scale: Vector2;
  72491. /**
  72492. * The current angle of the particle.
  72493. */
  72494. angle: number;
  72495. /**
  72496. * Defines how fast is the angle changing.
  72497. */
  72498. angularSpeed: number;
  72499. /**
  72500. * Defines the cell index used by the particle to be rendered from a sprite.
  72501. */
  72502. cellIndex: number;
  72503. /**
  72504. * The information required to support color remapping
  72505. */
  72506. remapData: Vector4;
  72507. /** @hidden */
  72508. _randomCellOffset?: number;
  72509. /** @hidden */
  72510. _initialDirection: Nullable<Vector3>;
  72511. /** @hidden */
  72512. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72513. /** @hidden */
  72514. _initialStartSpriteCellID: number;
  72515. /** @hidden */
  72516. _initialEndSpriteCellID: number;
  72517. /** @hidden */
  72518. _currentColorGradient: Nullable<ColorGradient>;
  72519. /** @hidden */
  72520. _currentColor1: Color4;
  72521. /** @hidden */
  72522. _currentColor2: Color4;
  72523. /** @hidden */
  72524. _currentSizeGradient: Nullable<FactorGradient>;
  72525. /** @hidden */
  72526. _currentSize1: number;
  72527. /** @hidden */
  72528. _currentSize2: number;
  72529. /** @hidden */
  72530. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72531. /** @hidden */
  72532. _currentAngularSpeed1: number;
  72533. /** @hidden */
  72534. _currentAngularSpeed2: number;
  72535. /** @hidden */
  72536. _currentVelocityGradient: Nullable<FactorGradient>;
  72537. /** @hidden */
  72538. _currentVelocity1: number;
  72539. /** @hidden */
  72540. _currentVelocity2: number;
  72541. /** @hidden */
  72542. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72543. /** @hidden */
  72544. _currentLimitVelocity1: number;
  72545. /** @hidden */
  72546. _currentLimitVelocity2: number;
  72547. /** @hidden */
  72548. _currentDragGradient: Nullable<FactorGradient>;
  72549. /** @hidden */
  72550. _currentDrag1: number;
  72551. /** @hidden */
  72552. _currentDrag2: number;
  72553. /** @hidden */
  72554. _randomNoiseCoordinates1: Vector3;
  72555. /** @hidden */
  72556. _randomNoiseCoordinates2: Vector3;
  72557. /**
  72558. * Creates a new instance Particle
  72559. * @param particleSystem the particle system the particle belongs to
  72560. */
  72561. constructor(
  72562. /**
  72563. * The particle system the particle belongs to.
  72564. */
  72565. particleSystem: ParticleSystem);
  72566. private updateCellInfoFromSystem;
  72567. /**
  72568. * Defines how the sprite cell index is updated for the particle
  72569. */
  72570. updateCellIndex(): void;
  72571. /** @hidden */
  72572. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72573. /** @hidden */
  72574. _inheritParticleInfoToSubEmitters(): void;
  72575. /** @hidden */
  72576. _reset(): void;
  72577. /**
  72578. * Copy the properties of particle to another one.
  72579. * @param other the particle to copy the information to.
  72580. */
  72581. copyTo(other: Particle): void;
  72582. }
  72583. }
  72584. declare module BABYLON {
  72585. /**
  72586. * Particle emitter represents a volume emitting particles.
  72587. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72588. */
  72589. export interface IParticleEmitterType {
  72590. /**
  72591. * Called by the particle System when the direction is computed for the created particle.
  72592. * @param worldMatrix is the world matrix of the particle system
  72593. * @param directionToUpdate is the direction vector to update with the result
  72594. * @param particle is the particle we are computed the direction for
  72595. */
  72596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72597. /**
  72598. * Called by the particle System when the position is computed for the created particle.
  72599. * @param worldMatrix is the world matrix of the particle system
  72600. * @param positionToUpdate is the position vector to update with the result
  72601. * @param particle is the particle we are computed the position for
  72602. */
  72603. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72604. /**
  72605. * Clones the current emitter and returns a copy of it
  72606. * @returns the new emitter
  72607. */
  72608. clone(): IParticleEmitterType;
  72609. /**
  72610. * Called by the GPUParticleSystem to setup the update shader
  72611. * @param effect defines the update shader
  72612. */
  72613. applyToShader(effect: Effect): void;
  72614. /**
  72615. * Returns a string to use to update the GPU particles update shader
  72616. * @returns the effect defines string
  72617. */
  72618. getEffectDefines(): string;
  72619. /**
  72620. * Returns a string representing the class name
  72621. * @returns a string containing the class name
  72622. */
  72623. getClassName(): string;
  72624. /**
  72625. * Serializes the particle system to a JSON object.
  72626. * @returns the JSON object
  72627. */
  72628. serialize(): any;
  72629. /**
  72630. * Parse properties from a JSON object
  72631. * @param serializationObject defines the JSON object
  72632. */
  72633. parse(serializationObject: any): void;
  72634. }
  72635. }
  72636. declare module BABYLON {
  72637. /**
  72638. * Particle emitter emitting particles from the inside of a box.
  72639. * It emits the particles randomly between 2 given directions.
  72640. */
  72641. export class BoxParticleEmitter implements IParticleEmitterType {
  72642. /**
  72643. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72644. */
  72645. direction1: Vector3;
  72646. /**
  72647. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72648. */
  72649. direction2: Vector3;
  72650. /**
  72651. * 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.
  72652. */
  72653. minEmitBox: Vector3;
  72654. /**
  72655. * 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.
  72656. */
  72657. maxEmitBox: Vector3;
  72658. /**
  72659. * Creates a new instance BoxParticleEmitter
  72660. */
  72661. constructor();
  72662. /**
  72663. * Called by the particle System when the direction is computed for the created particle.
  72664. * @param worldMatrix is the world matrix of the particle system
  72665. * @param directionToUpdate is the direction vector to update with the result
  72666. * @param particle is the particle we are computed the direction for
  72667. */
  72668. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72669. /**
  72670. * Called by the particle System when the position is computed for the created particle.
  72671. * @param worldMatrix is the world matrix of the particle system
  72672. * @param positionToUpdate is the position vector to update with the result
  72673. * @param particle is the particle we are computed the position for
  72674. */
  72675. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72676. /**
  72677. * Clones the current emitter and returns a copy of it
  72678. * @returns the new emitter
  72679. */
  72680. clone(): BoxParticleEmitter;
  72681. /**
  72682. * Called by the GPUParticleSystem to setup the update shader
  72683. * @param effect defines the update shader
  72684. */
  72685. applyToShader(effect: Effect): void;
  72686. /**
  72687. * Returns a string to use to update the GPU particles update shader
  72688. * @returns a string containng the defines string
  72689. */
  72690. getEffectDefines(): string;
  72691. /**
  72692. * Returns the string "BoxParticleEmitter"
  72693. * @returns a string containing the class name
  72694. */
  72695. getClassName(): string;
  72696. /**
  72697. * Serializes the particle system to a JSON object.
  72698. * @returns the JSON object
  72699. */
  72700. serialize(): any;
  72701. /**
  72702. * Parse properties from a JSON object
  72703. * @param serializationObject defines the JSON object
  72704. */
  72705. parse(serializationObject: any): void;
  72706. }
  72707. }
  72708. declare module BABYLON {
  72709. /**
  72710. * Particle emitter emitting particles from the inside of a cone.
  72711. * It emits the particles alongside the cone volume from the base to the particle.
  72712. * The emission direction might be randomized.
  72713. */
  72714. export class ConeParticleEmitter implements IParticleEmitterType {
  72715. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72716. directionRandomizer: number;
  72717. private _radius;
  72718. private _angle;
  72719. private _height;
  72720. /**
  72721. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72722. */
  72723. radiusRange: number;
  72724. /**
  72725. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72726. */
  72727. heightRange: number;
  72728. /**
  72729. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72730. */
  72731. emitFromSpawnPointOnly: boolean;
  72732. /**
  72733. * Gets or sets the radius of the emission cone
  72734. */
  72735. radius: number;
  72736. /**
  72737. * Gets or sets the angle of the emission cone
  72738. */
  72739. angle: number;
  72740. private _buildHeight;
  72741. /**
  72742. * Creates a new instance ConeParticleEmitter
  72743. * @param radius the radius of the emission cone (1 by default)
  72744. * @param angle the cone base angle (PI by default)
  72745. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72746. */
  72747. constructor(radius?: number, angle?: number,
  72748. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72749. directionRandomizer?: number);
  72750. /**
  72751. * Called by the particle System when the direction is computed for the created particle.
  72752. * @param worldMatrix is the world matrix of the particle system
  72753. * @param directionToUpdate is the direction vector to update with the result
  72754. * @param particle is the particle we are computed the direction for
  72755. */
  72756. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72757. /**
  72758. * Called by the particle System when the position is computed for the created particle.
  72759. * @param worldMatrix is the world matrix of the particle system
  72760. * @param positionToUpdate is the position vector to update with the result
  72761. * @param particle is the particle we are computed the position for
  72762. */
  72763. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72764. /**
  72765. * Clones the current emitter and returns a copy of it
  72766. * @returns the new emitter
  72767. */
  72768. clone(): ConeParticleEmitter;
  72769. /**
  72770. * Called by the GPUParticleSystem to setup the update shader
  72771. * @param effect defines the update shader
  72772. */
  72773. applyToShader(effect: Effect): void;
  72774. /**
  72775. * Returns a string to use to update the GPU particles update shader
  72776. * @returns a string containng the defines string
  72777. */
  72778. getEffectDefines(): string;
  72779. /**
  72780. * Returns the string "ConeParticleEmitter"
  72781. * @returns a string containing the class name
  72782. */
  72783. getClassName(): string;
  72784. /**
  72785. * Serializes the particle system to a JSON object.
  72786. * @returns the JSON object
  72787. */
  72788. serialize(): any;
  72789. /**
  72790. * Parse properties from a JSON object
  72791. * @param serializationObject defines the JSON object
  72792. */
  72793. parse(serializationObject: any): void;
  72794. }
  72795. }
  72796. declare module BABYLON {
  72797. /**
  72798. * Particle emitter emitting particles from the inside of a cylinder.
  72799. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72800. */
  72801. export class CylinderParticleEmitter implements IParticleEmitterType {
  72802. /**
  72803. * The radius of the emission cylinder.
  72804. */
  72805. radius: number;
  72806. /**
  72807. * The height of the emission cylinder.
  72808. */
  72809. height: number;
  72810. /**
  72811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72812. */
  72813. radiusRange: number;
  72814. /**
  72815. * How much to randomize the particle direction [0-1].
  72816. */
  72817. directionRandomizer: number;
  72818. /**
  72819. * Creates a new instance CylinderParticleEmitter
  72820. * @param radius the radius of the emission cylinder (1 by default)
  72821. * @param height the height of the emission cylinder (1 by default)
  72822. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72823. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72824. */
  72825. constructor(
  72826. /**
  72827. * The radius of the emission cylinder.
  72828. */
  72829. radius?: number,
  72830. /**
  72831. * The height of the emission cylinder.
  72832. */
  72833. height?: number,
  72834. /**
  72835. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72836. */
  72837. radiusRange?: number,
  72838. /**
  72839. * How much to randomize the particle direction [0-1].
  72840. */
  72841. directionRandomizer?: number);
  72842. /**
  72843. * Called by the particle System when the direction is computed for the created particle.
  72844. * @param worldMatrix is the world matrix of the particle system
  72845. * @param directionToUpdate is the direction vector to update with the result
  72846. * @param particle is the particle we are computed the direction for
  72847. */
  72848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72849. /**
  72850. * Called by the particle System when the position is computed for the created particle.
  72851. * @param worldMatrix is the world matrix of the particle system
  72852. * @param positionToUpdate is the position vector to update with the result
  72853. * @param particle is the particle we are computed the position for
  72854. */
  72855. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72856. /**
  72857. * Clones the current emitter and returns a copy of it
  72858. * @returns the new emitter
  72859. */
  72860. clone(): CylinderParticleEmitter;
  72861. /**
  72862. * Called by the GPUParticleSystem to setup the update shader
  72863. * @param effect defines the update shader
  72864. */
  72865. applyToShader(effect: Effect): void;
  72866. /**
  72867. * Returns a string to use to update the GPU particles update shader
  72868. * @returns a string containng the defines string
  72869. */
  72870. getEffectDefines(): string;
  72871. /**
  72872. * Returns the string "CylinderParticleEmitter"
  72873. * @returns a string containing the class name
  72874. */
  72875. getClassName(): string;
  72876. /**
  72877. * Serializes the particle system to a JSON object.
  72878. * @returns the JSON object
  72879. */
  72880. serialize(): any;
  72881. /**
  72882. * Parse properties from a JSON object
  72883. * @param serializationObject defines the JSON object
  72884. */
  72885. parse(serializationObject: any): void;
  72886. }
  72887. /**
  72888. * Particle emitter emitting particles from the inside of a cylinder.
  72889. * It emits the particles randomly between two vectors.
  72890. */
  72891. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72892. /**
  72893. * The min limit of the emission direction.
  72894. */
  72895. direction1: Vector3;
  72896. /**
  72897. * The max limit of the emission direction.
  72898. */
  72899. direction2: Vector3;
  72900. /**
  72901. * Creates a new instance CylinderDirectedParticleEmitter
  72902. * @param radius the radius of the emission cylinder (1 by default)
  72903. * @param height the height of the emission cylinder (1 by default)
  72904. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72905. * @param direction1 the min limit of the emission direction (up vector by default)
  72906. * @param direction2 the max limit of the emission direction (up vector by default)
  72907. */
  72908. constructor(radius?: number, height?: number, radiusRange?: number,
  72909. /**
  72910. * The min limit of the emission direction.
  72911. */
  72912. direction1?: Vector3,
  72913. /**
  72914. * The max limit of the emission direction.
  72915. */
  72916. direction2?: Vector3);
  72917. /**
  72918. * Called by the particle System when the direction is computed for the created particle.
  72919. * @param worldMatrix is the world matrix of the particle system
  72920. * @param directionToUpdate is the direction vector to update with the result
  72921. * @param particle is the particle we are computed the direction for
  72922. */
  72923. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72924. /**
  72925. * Clones the current emitter and returns a copy of it
  72926. * @returns the new emitter
  72927. */
  72928. clone(): CylinderDirectedParticleEmitter;
  72929. /**
  72930. * Called by the GPUParticleSystem to setup the update shader
  72931. * @param effect defines the update shader
  72932. */
  72933. applyToShader(effect: Effect): void;
  72934. /**
  72935. * Returns a string to use to update the GPU particles update shader
  72936. * @returns a string containng the defines string
  72937. */
  72938. getEffectDefines(): string;
  72939. /**
  72940. * Returns the string "CylinderDirectedParticleEmitter"
  72941. * @returns a string containing the class name
  72942. */
  72943. getClassName(): string;
  72944. /**
  72945. * Serializes the particle system to a JSON object.
  72946. * @returns the JSON object
  72947. */
  72948. serialize(): any;
  72949. /**
  72950. * Parse properties from a JSON object
  72951. * @param serializationObject defines the JSON object
  72952. */
  72953. parse(serializationObject: any): void;
  72954. }
  72955. }
  72956. declare module BABYLON {
  72957. /**
  72958. * Particle emitter emitting particles from the inside of a hemisphere.
  72959. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72960. */
  72961. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72962. /**
  72963. * The radius of the emission hemisphere.
  72964. */
  72965. radius: number;
  72966. /**
  72967. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72968. */
  72969. radiusRange: number;
  72970. /**
  72971. * How much to randomize the particle direction [0-1].
  72972. */
  72973. directionRandomizer: number;
  72974. /**
  72975. * Creates a new instance HemisphericParticleEmitter
  72976. * @param radius the radius of the emission hemisphere (1 by default)
  72977. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72978. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72979. */
  72980. constructor(
  72981. /**
  72982. * The radius of the emission hemisphere.
  72983. */
  72984. radius?: number,
  72985. /**
  72986. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72987. */
  72988. radiusRange?: number,
  72989. /**
  72990. * How much to randomize the particle direction [0-1].
  72991. */
  72992. directionRandomizer?: number);
  72993. /**
  72994. * Called by the particle System when the direction is computed for the created particle.
  72995. * @param worldMatrix is the world matrix of the particle system
  72996. * @param directionToUpdate is the direction vector to update with the result
  72997. * @param particle is the particle we are computed the direction for
  72998. */
  72999. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73000. /**
  73001. * Called by the particle System when the position is computed for the created particle.
  73002. * @param worldMatrix is the world matrix of the particle system
  73003. * @param positionToUpdate is the position vector to update with the result
  73004. * @param particle is the particle we are computed the position for
  73005. */
  73006. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73007. /**
  73008. * Clones the current emitter and returns a copy of it
  73009. * @returns the new emitter
  73010. */
  73011. clone(): HemisphericParticleEmitter;
  73012. /**
  73013. * Called by the GPUParticleSystem to setup the update shader
  73014. * @param effect defines the update shader
  73015. */
  73016. applyToShader(effect: Effect): void;
  73017. /**
  73018. * Returns a string to use to update the GPU particles update shader
  73019. * @returns a string containng the defines string
  73020. */
  73021. getEffectDefines(): string;
  73022. /**
  73023. * Returns the string "HemisphericParticleEmitter"
  73024. * @returns a string containing the class name
  73025. */
  73026. getClassName(): string;
  73027. /**
  73028. * Serializes the particle system to a JSON object.
  73029. * @returns the JSON object
  73030. */
  73031. serialize(): any;
  73032. /**
  73033. * Parse properties from a JSON object
  73034. * @param serializationObject defines the JSON object
  73035. */
  73036. parse(serializationObject: any): void;
  73037. }
  73038. }
  73039. declare module BABYLON {
  73040. /**
  73041. * Particle emitter emitting particles from a point.
  73042. * It emits the particles randomly between 2 given directions.
  73043. */
  73044. export class PointParticleEmitter implements IParticleEmitterType {
  73045. /**
  73046. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73047. */
  73048. direction1: Vector3;
  73049. /**
  73050. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73051. */
  73052. direction2: Vector3;
  73053. /**
  73054. * Creates a new instance PointParticleEmitter
  73055. */
  73056. constructor();
  73057. /**
  73058. * Called by the particle System when the direction is computed for the created particle.
  73059. * @param worldMatrix is the world matrix of the particle system
  73060. * @param directionToUpdate is the direction vector to update with the result
  73061. * @param particle is the particle we are computed the direction for
  73062. */
  73063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73064. /**
  73065. * Called by the particle System when the position is computed for the created particle.
  73066. * @param worldMatrix is the world matrix of the particle system
  73067. * @param positionToUpdate is the position vector to update with the result
  73068. * @param particle is the particle we are computed the position for
  73069. */
  73070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73071. /**
  73072. * Clones the current emitter and returns a copy of it
  73073. * @returns the new emitter
  73074. */
  73075. clone(): PointParticleEmitter;
  73076. /**
  73077. * Called by the GPUParticleSystem to setup the update shader
  73078. * @param effect defines the update shader
  73079. */
  73080. applyToShader(effect: Effect): void;
  73081. /**
  73082. * Returns a string to use to update the GPU particles update shader
  73083. * @returns a string containng the defines string
  73084. */
  73085. getEffectDefines(): string;
  73086. /**
  73087. * Returns the string "PointParticleEmitter"
  73088. * @returns a string containing the class name
  73089. */
  73090. getClassName(): string;
  73091. /**
  73092. * Serializes the particle system to a JSON object.
  73093. * @returns the JSON object
  73094. */
  73095. serialize(): any;
  73096. /**
  73097. * Parse properties from a JSON object
  73098. * @param serializationObject defines the JSON object
  73099. */
  73100. parse(serializationObject: any): void;
  73101. }
  73102. }
  73103. declare module BABYLON {
  73104. /**
  73105. * Particle emitter emitting particles from the inside of a sphere.
  73106. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73107. */
  73108. export class SphereParticleEmitter implements IParticleEmitterType {
  73109. /**
  73110. * The radius of the emission sphere.
  73111. */
  73112. radius: number;
  73113. /**
  73114. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73115. */
  73116. radiusRange: number;
  73117. /**
  73118. * How much to randomize the particle direction [0-1].
  73119. */
  73120. directionRandomizer: number;
  73121. /**
  73122. * Creates a new instance SphereParticleEmitter
  73123. * @param radius the radius of the emission sphere (1 by default)
  73124. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73125. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73126. */
  73127. constructor(
  73128. /**
  73129. * The radius of the emission sphere.
  73130. */
  73131. radius?: number,
  73132. /**
  73133. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73134. */
  73135. radiusRange?: number,
  73136. /**
  73137. * How much to randomize the particle direction [0-1].
  73138. */
  73139. directionRandomizer?: number);
  73140. /**
  73141. * Called by the particle System when the direction is computed for the created particle.
  73142. * @param worldMatrix is the world matrix of the particle system
  73143. * @param directionToUpdate is the direction vector to update with the result
  73144. * @param particle is the particle we are computed the direction for
  73145. */
  73146. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73147. /**
  73148. * Called by the particle System when the position is computed for the created particle.
  73149. * @param worldMatrix is the world matrix of the particle system
  73150. * @param positionToUpdate is the position vector to update with the result
  73151. * @param particle is the particle we are computed the position for
  73152. */
  73153. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73154. /**
  73155. * Clones the current emitter and returns a copy of it
  73156. * @returns the new emitter
  73157. */
  73158. clone(): SphereParticleEmitter;
  73159. /**
  73160. * Called by the GPUParticleSystem to setup the update shader
  73161. * @param effect defines the update shader
  73162. */
  73163. applyToShader(effect: Effect): void;
  73164. /**
  73165. * Returns a string to use to update the GPU particles update shader
  73166. * @returns a string containng the defines string
  73167. */
  73168. getEffectDefines(): string;
  73169. /**
  73170. * Returns the string "SphereParticleEmitter"
  73171. * @returns a string containing the class name
  73172. */
  73173. getClassName(): string;
  73174. /**
  73175. * Serializes the particle system to a JSON object.
  73176. * @returns the JSON object
  73177. */
  73178. serialize(): any;
  73179. /**
  73180. * Parse properties from a JSON object
  73181. * @param serializationObject defines the JSON object
  73182. */
  73183. parse(serializationObject: any): void;
  73184. }
  73185. /**
  73186. * Particle emitter emitting particles from the inside of a sphere.
  73187. * It emits the particles randomly between two vectors.
  73188. */
  73189. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  73190. /**
  73191. * The min limit of the emission direction.
  73192. */
  73193. direction1: Vector3;
  73194. /**
  73195. * The max limit of the emission direction.
  73196. */
  73197. direction2: Vector3;
  73198. /**
  73199. * Creates a new instance SphereDirectedParticleEmitter
  73200. * @param radius the radius of the emission sphere (1 by default)
  73201. * @param direction1 the min limit of the emission direction (up vector by default)
  73202. * @param direction2 the max limit of the emission direction (up vector by default)
  73203. */
  73204. constructor(radius?: number,
  73205. /**
  73206. * The min limit of the emission direction.
  73207. */
  73208. direction1?: Vector3,
  73209. /**
  73210. * The max limit of the emission direction.
  73211. */
  73212. direction2?: Vector3);
  73213. /**
  73214. * Called by the particle System when the direction is computed for the created particle.
  73215. * @param worldMatrix is the world matrix of the particle system
  73216. * @param directionToUpdate is the direction vector to update with the result
  73217. * @param particle is the particle we are computed the direction for
  73218. */
  73219. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73220. /**
  73221. * Clones the current emitter and returns a copy of it
  73222. * @returns the new emitter
  73223. */
  73224. clone(): SphereDirectedParticleEmitter;
  73225. /**
  73226. * Called by the GPUParticleSystem to setup the update shader
  73227. * @param effect defines the update shader
  73228. */
  73229. applyToShader(effect: Effect): void;
  73230. /**
  73231. * Returns a string to use to update the GPU particles update shader
  73232. * @returns a string containng the defines string
  73233. */
  73234. getEffectDefines(): string;
  73235. /**
  73236. * Returns the string "SphereDirectedParticleEmitter"
  73237. * @returns a string containing the class name
  73238. */
  73239. getClassName(): string;
  73240. /**
  73241. * Serializes the particle system to a JSON object.
  73242. * @returns the JSON object
  73243. */
  73244. serialize(): any;
  73245. /**
  73246. * Parse properties from a JSON object
  73247. * @param serializationObject defines the JSON object
  73248. */
  73249. parse(serializationObject: any): void;
  73250. }
  73251. }
  73252. declare module BABYLON {
  73253. /**
  73254. * Interface representing a particle system in Babylon.js.
  73255. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73256. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73257. */
  73258. export interface IParticleSystem {
  73259. /**
  73260. * List of animations used by the particle system.
  73261. */
  73262. animations: Animation[];
  73263. /**
  73264. * The id of the Particle system.
  73265. */
  73266. id: string;
  73267. /**
  73268. * The name of the Particle system.
  73269. */
  73270. name: string;
  73271. /**
  73272. * The emitter represents the Mesh or position we are attaching the particle system to.
  73273. */
  73274. emitter: Nullable<AbstractMesh | Vector3>;
  73275. /**
  73276. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73277. */
  73278. isBillboardBased: boolean;
  73279. /**
  73280. * The rendering group used by the Particle system to chose when to render.
  73281. */
  73282. renderingGroupId: number;
  73283. /**
  73284. * The layer mask we are rendering the particles through.
  73285. */
  73286. layerMask: number;
  73287. /**
  73288. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73289. */
  73290. updateSpeed: number;
  73291. /**
  73292. * The amount of time the particle system is running (depends of the overall update speed).
  73293. */
  73294. targetStopDuration: number;
  73295. /**
  73296. * The texture used to render each particle. (this can be a spritesheet)
  73297. */
  73298. particleTexture: Nullable<Texture>;
  73299. /**
  73300. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73301. */
  73302. blendMode: number;
  73303. /**
  73304. * Minimum life time of emitting particles.
  73305. */
  73306. minLifeTime: number;
  73307. /**
  73308. * Maximum life time of emitting particles.
  73309. */
  73310. maxLifeTime: number;
  73311. /**
  73312. * Minimum Size of emitting particles.
  73313. */
  73314. minSize: number;
  73315. /**
  73316. * Maximum Size of emitting particles.
  73317. */
  73318. maxSize: number;
  73319. /**
  73320. * Minimum scale of emitting particles on X axis.
  73321. */
  73322. minScaleX: number;
  73323. /**
  73324. * Maximum scale of emitting particles on X axis.
  73325. */
  73326. maxScaleX: number;
  73327. /**
  73328. * Minimum scale of emitting particles on Y axis.
  73329. */
  73330. minScaleY: number;
  73331. /**
  73332. * Maximum scale of emitting particles on Y axis.
  73333. */
  73334. maxScaleY: number;
  73335. /**
  73336. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73337. */
  73338. color1: Color4;
  73339. /**
  73340. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73341. */
  73342. color2: Color4;
  73343. /**
  73344. * Color the particle will have at the end of its lifetime.
  73345. */
  73346. colorDead: Color4;
  73347. /**
  73348. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73349. */
  73350. emitRate: number;
  73351. /**
  73352. * You can use gravity if you want to give an orientation to your particles.
  73353. */
  73354. gravity: Vector3;
  73355. /**
  73356. * Minimum power of emitting particles.
  73357. */
  73358. minEmitPower: number;
  73359. /**
  73360. * Maximum power of emitting particles.
  73361. */
  73362. maxEmitPower: number;
  73363. /**
  73364. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73365. */
  73366. minAngularSpeed: number;
  73367. /**
  73368. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73369. */
  73370. maxAngularSpeed: number;
  73371. /**
  73372. * Gets or sets the minimal initial rotation in radians.
  73373. */
  73374. minInitialRotation: number;
  73375. /**
  73376. * Gets or sets the maximal initial rotation in radians.
  73377. */
  73378. maxInitialRotation: number;
  73379. /**
  73380. * The particle emitter type defines the emitter used by the particle system.
  73381. * It can be for example box, sphere, or cone...
  73382. */
  73383. particleEmitterType: Nullable<IParticleEmitterType>;
  73384. /**
  73385. * Defines the delay in milliseconds before starting the system (0 by default)
  73386. */
  73387. startDelay: number;
  73388. /**
  73389. * 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
  73390. */
  73391. preWarmCycles: number;
  73392. /**
  73393. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73394. */
  73395. preWarmStepOffset: number;
  73396. /**
  73397. * 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)
  73398. */
  73399. spriteCellChangeSpeed: number;
  73400. /**
  73401. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73402. */
  73403. startSpriteCellID: number;
  73404. /**
  73405. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73406. */
  73407. endSpriteCellID: number;
  73408. /**
  73409. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73410. */
  73411. spriteCellWidth: number;
  73412. /**
  73413. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73414. */
  73415. spriteCellHeight: number;
  73416. /**
  73417. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73418. */
  73419. spriteRandomStartCell: boolean;
  73420. /**
  73421. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73422. */
  73423. isAnimationSheetEnabled: boolean;
  73424. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73425. translationPivot: Vector2;
  73426. /**
  73427. * Gets or sets a texture used to add random noise to particle positions
  73428. */
  73429. noiseTexture: Nullable<BaseTexture>;
  73430. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73431. noiseStrength: Vector3;
  73432. /**
  73433. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73434. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73435. */
  73436. billboardMode: number;
  73437. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73438. limitVelocityDamping: number;
  73439. /**
  73440. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73441. */
  73442. beginAnimationOnStart: boolean;
  73443. /**
  73444. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73445. */
  73446. beginAnimationFrom: number;
  73447. /**
  73448. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73449. */
  73450. beginAnimationTo: number;
  73451. /**
  73452. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73453. */
  73454. beginAnimationLoop: boolean;
  73455. /**
  73456. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73457. */
  73458. disposeOnStop: boolean;
  73459. /**
  73460. * Gets the maximum number of particles active at the same time.
  73461. * @returns The max number of active particles.
  73462. */
  73463. getCapacity(): number;
  73464. /**
  73465. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73466. * @returns True if it has been started, otherwise false.
  73467. */
  73468. isStarted(): boolean;
  73469. /**
  73470. * Animates the particle system for this frame.
  73471. */
  73472. animate(): void;
  73473. /**
  73474. * Renders the particle system in its current state.
  73475. * @returns the current number of particles
  73476. */
  73477. render(): number;
  73478. /**
  73479. * Dispose the particle system and frees its associated resources.
  73480. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73481. */
  73482. dispose(disposeTexture?: boolean): void;
  73483. /**
  73484. * Clones the particle system.
  73485. * @param name The name of the cloned object
  73486. * @param newEmitter The new emitter to use
  73487. * @returns the cloned particle system
  73488. */
  73489. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73490. /**
  73491. * Serializes the particle system to a JSON object.
  73492. * @returns the JSON object
  73493. */
  73494. serialize(): any;
  73495. /**
  73496. * Rebuild the particle system
  73497. */
  73498. rebuild(): void;
  73499. /**
  73500. * Starts the particle system and begins to emit
  73501. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73502. */
  73503. start(delay?: number): void;
  73504. /**
  73505. * Stops the particle system.
  73506. */
  73507. stop(): void;
  73508. /**
  73509. * Remove all active particles
  73510. */
  73511. reset(): void;
  73512. /**
  73513. * Is this system ready to be used/rendered
  73514. * @return true if the system is ready
  73515. */
  73516. isReady(): boolean;
  73517. /**
  73518. * Adds a new color gradient
  73519. * @param gradient defines the gradient to use (between 0 and 1)
  73520. * @param color1 defines the color to affect to the specified gradient
  73521. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73522. * @returns the current particle system
  73523. */
  73524. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73525. /**
  73526. * Remove a specific color gradient
  73527. * @param gradient defines the gradient to remove
  73528. * @returns the current particle system
  73529. */
  73530. removeColorGradient(gradient: number): IParticleSystem;
  73531. /**
  73532. * Adds a new size gradient
  73533. * @param gradient defines the gradient to use (between 0 and 1)
  73534. * @param factor defines the size factor to affect to the specified gradient
  73535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73536. * @returns the current particle system
  73537. */
  73538. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73539. /**
  73540. * Remove a specific size gradient
  73541. * @param gradient defines the gradient to remove
  73542. * @returns the current particle system
  73543. */
  73544. removeSizeGradient(gradient: number): IParticleSystem;
  73545. /**
  73546. * Gets the current list of color gradients.
  73547. * You must use addColorGradient and removeColorGradient to udpate this list
  73548. * @returns the list of color gradients
  73549. */
  73550. getColorGradients(): Nullable<Array<ColorGradient>>;
  73551. /**
  73552. * Gets the current list of size gradients.
  73553. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73554. * @returns the list of size gradients
  73555. */
  73556. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73557. /**
  73558. * Gets the current list of angular speed gradients.
  73559. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73560. * @returns the list of angular speed gradients
  73561. */
  73562. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73563. /**
  73564. * Adds a new angular speed gradient
  73565. * @param gradient defines the gradient to use (between 0 and 1)
  73566. * @param factor defines the angular speed to affect to the specified gradient
  73567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73568. * @returns the current particle system
  73569. */
  73570. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73571. /**
  73572. * Remove a specific angular speed gradient
  73573. * @param gradient defines the gradient to remove
  73574. * @returns the current particle system
  73575. */
  73576. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73577. /**
  73578. * Gets the current list of velocity gradients.
  73579. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73580. * @returns the list of velocity gradients
  73581. */
  73582. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73583. /**
  73584. * Adds a new velocity gradient
  73585. * @param gradient defines the gradient to use (between 0 and 1)
  73586. * @param factor defines the velocity to affect to the specified gradient
  73587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73588. * @returns the current particle system
  73589. */
  73590. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73591. /**
  73592. * Remove a specific velocity gradient
  73593. * @param gradient defines the gradient to remove
  73594. * @returns the current particle system
  73595. */
  73596. removeVelocityGradient(gradient: number): IParticleSystem;
  73597. /**
  73598. * Gets the current list of limit velocity gradients.
  73599. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73600. * @returns the list of limit velocity gradients
  73601. */
  73602. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73603. /**
  73604. * Adds a new limit velocity gradient
  73605. * @param gradient defines the gradient to use (between 0 and 1)
  73606. * @param factor defines the limit velocity to affect to the specified gradient
  73607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73608. * @returns the current particle system
  73609. */
  73610. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73611. /**
  73612. * Remove a specific limit velocity gradient
  73613. * @param gradient defines the gradient to remove
  73614. * @returns the current particle system
  73615. */
  73616. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73617. /**
  73618. * Adds a new drag gradient
  73619. * @param gradient defines the gradient to use (between 0 and 1)
  73620. * @param factor defines the drag to affect to the specified gradient
  73621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73622. * @returns the current particle system
  73623. */
  73624. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73625. /**
  73626. * Remove a specific drag gradient
  73627. * @param gradient defines the gradient to remove
  73628. * @returns the current particle system
  73629. */
  73630. removeDragGradient(gradient: number): IParticleSystem;
  73631. /**
  73632. * Gets the current list of drag gradients.
  73633. * You must use addDragGradient and removeDragGradient to udpate this list
  73634. * @returns the list of drag gradients
  73635. */
  73636. getDragGradients(): Nullable<Array<FactorGradient>>;
  73637. /**
  73638. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73639. * @param gradient defines the gradient to use (between 0 and 1)
  73640. * @param factor defines the emit rate to affect to the specified gradient
  73641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73642. * @returns the current particle system
  73643. */
  73644. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73645. /**
  73646. * Remove a specific emit rate gradient
  73647. * @param gradient defines the gradient to remove
  73648. * @returns the current particle system
  73649. */
  73650. removeEmitRateGradient(gradient: number): IParticleSystem;
  73651. /**
  73652. * Gets the current list of emit rate gradients.
  73653. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73654. * @returns the list of emit rate gradients
  73655. */
  73656. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73657. /**
  73658. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73659. * @param gradient defines the gradient to use (between 0 and 1)
  73660. * @param factor defines the start size to affect to the specified gradient
  73661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73662. * @returns the current particle system
  73663. */
  73664. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73665. /**
  73666. * Remove a specific start size gradient
  73667. * @param gradient defines the gradient to remove
  73668. * @returns the current particle system
  73669. */
  73670. removeStartSizeGradient(gradient: number): IParticleSystem;
  73671. /**
  73672. * Gets the current list of start size gradients.
  73673. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73674. * @returns the list of start size gradients
  73675. */
  73676. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73677. /**
  73678. * Adds a new life time gradient
  73679. * @param gradient defines the gradient to use (between 0 and 1)
  73680. * @param factor defines the life time factor to affect to the specified gradient
  73681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73682. * @returns the current particle system
  73683. */
  73684. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73685. /**
  73686. * Remove a specific life time gradient
  73687. * @param gradient defines the gradient to remove
  73688. * @returns the current particle system
  73689. */
  73690. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73691. /**
  73692. * Gets the current list of life time gradients.
  73693. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73694. * @returns the list of life time gradients
  73695. */
  73696. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73697. /**
  73698. * Gets the current list of color gradients.
  73699. * You must use addColorGradient and removeColorGradient to udpate this list
  73700. * @returns the list of color gradients
  73701. */
  73702. getColorGradients(): Nullable<Array<ColorGradient>>;
  73703. /**
  73704. * Adds a new ramp gradient used to remap particle colors
  73705. * @param gradient defines the gradient to use (between 0 and 1)
  73706. * @param color defines the color to affect to the specified gradient
  73707. * @returns the current particle system
  73708. */
  73709. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73710. /**
  73711. * Gets the current list of ramp gradients.
  73712. * You must use addRampGradient and removeRampGradient to udpate this list
  73713. * @returns the list of ramp gradients
  73714. */
  73715. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73716. /** Gets or sets a boolean indicating that ramp gradients must be used
  73717. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73718. */
  73719. useRampGradients: boolean;
  73720. /**
  73721. * Adds a new color remap gradient
  73722. * @param gradient defines the gradient to use (between 0 and 1)
  73723. * @param min defines the color remap minimal range
  73724. * @param max defines the color remap maximal range
  73725. * @returns the current particle system
  73726. */
  73727. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73728. /**
  73729. * Gets the current list of color remap gradients.
  73730. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73731. * @returns the list of color remap gradients
  73732. */
  73733. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73734. /**
  73735. * Adds a new alpha remap gradient
  73736. * @param gradient defines the gradient to use (between 0 and 1)
  73737. * @param min defines the alpha remap minimal range
  73738. * @param max defines the alpha remap maximal range
  73739. * @returns the current particle system
  73740. */
  73741. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73742. /**
  73743. * Gets the current list of alpha remap gradients.
  73744. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73745. * @returns the list of alpha remap gradients
  73746. */
  73747. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73748. /**
  73749. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73750. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73751. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73752. * @returns the emitter
  73753. */
  73754. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73755. /**
  73756. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73757. * @param radius The radius of the hemisphere to emit from
  73758. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73759. * @returns the emitter
  73760. */
  73761. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73762. /**
  73763. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73764. * @param radius The radius of the sphere to emit from
  73765. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73766. * @returns the emitter
  73767. */
  73768. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73769. /**
  73770. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73771. * @param radius The radius of the sphere to emit from
  73772. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73773. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73774. * @returns the emitter
  73775. */
  73776. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73777. /**
  73778. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73779. * @param radius The radius of the emission cylinder
  73780. * @param height The height of the emission cylinder
  73781. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73782. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73783. * @returns the emitter
  73784. */
  73785. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73786. /**
  73787. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73788. * @param radius The radius of the cylinder to emit from
  73789. * @param height The height of the emission cylinder
  73790. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73791. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73792. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73793. * @returns the emitter
  73794. */
  73795. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73796. /**
  73797. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73798. * @param radius The radius of the cone to emit from
  73799. * @param angle The base angle of the cone
  73800. * @returns the emitter
  73801. */
  73802. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73803. /**
  73804. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73805. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73806. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73807. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73808. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73809. * @returns the emitter
  73810. */
  73811. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73812. /**
  73813. * Get hosting scene
  73814. * @returns the scene
  73815. */
  73816. getScene(): Scene;
  73817. }
  73818. }
  73819. declare module BABYLON {
  73820. /**
  73821. * Creates an instance based on a source mesh.
  73822. */
  73823. export class InstancedMesh extends AbstractMesh {
  73824. private _sourceMesh;
  73825. private _currentLOD;
  73826. /** @hidden */
  73827. _indexInSourceMeshInstanceArray: number;
  73828. constructor(name: string, source: Mesh);
  73829. /**
  73830. * Returns the string "InstancedMesh".
  73831. */
  73832. getClassName(): string;
  73833. /**
  73834. * If the source mesh receives shadows
  73835. */
  73836. readonly receiveShadows: boolean;
  73837. /**
  73838. * The material of the source mesh
  73839. */
  73840. readonly material: Nullable<Material>;
  73841. /**
  73842. * Visibility of the source mesh
  73843. */
  73844. readonly visibility: number;
  73845. /**
  73846. * Skeleton of the source mesh
  73847. */
  73848. readonly skeleton: Nullable<Skeleton>;
  73849. /**
  73850. * Rendering ground id of the source mesh
  73851. */
  73852. renderingGroupId: number;
  73853. /**
  73854. * Returns the total number of vertices (integer).
  73855. */
  73856. getTotalVertices(): number;
  73857. /**
  73858. * Returns a positive integer : the total number of indices in this mesh geometry.
  73859. * @returns the numner of indices or zero if the mesh has no geometry.
  73860. */
  73861. getTotalIndices(): number;
  73862. /**
  73863. * The source mesh of the instance
  73864. */
  73865. readonly sourceMesh: Mesh;
  73866. /**
  73867. * Is this node ready to be used/rendered
  73868. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73869. * @return {boolean} is it ready
  73870. */
  73871. isReady(completeCheck?: boolean): boolean;
  73872. /**
  73873. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73874. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73875. * @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.
  73876. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73877. */
  73878. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73879. /**
  73880. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73881. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73882. * The `data` are either a numeric array either a Float32Array.
  73883. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73884. * 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).
  73885. * Note that a new underlying VertexBuffer object is created each call.
  73886. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73887. *
  73888. * Possible `kind` values :
  73889. * - VertexBuffer.PositionKind
  73890. * - VertexBuffer.UVKind
  73891. * - VertexBuffer.UV2Kind
  73892. * - VertexBuffer.UV3Kind
  73893. * - VertexBuffer.UV4Kind
  73894. * - VertexBuffer.UV5Kind
  73895. * - VertexBuffer.UV6Kind
  73896. * - VertexBuffer.ColorKind
  73897. * - VertexBuffer.MatricesIndicesKind
  73898. * - VertexBuffer.MatricesIndicesExtraKind
  73899. * - VertexBuffer.MatricesWeightsKind
  73900. * - VertexBuffer.MatricesWeightsExtraKind
  73901. *
  73902. * Returns the Mesh.
  73903. */
  73904. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73905. /**
  73906. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73907. * If the mesh has no geometry, it is simply returned as it is.
  73908. * The `data` are either a numeric array either a Float32Array.
  73909. * No new underlying VertexBuffer object is created.
  73910. * 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.
  73911. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73912. *
  73913. * Possible `kind` values :
  73914. * - VertexBuffer.PositionKind
  73915. * - VertexBuffer.UVKind
  73916. * - VertexBuffer.UV2Kind
  73917. * - VertexBuffer.UV3Kind
  73918. * - VertexBuffer.UV4Kind
  73919. * - VertexBuffer.UV5Kind
  73920. * - VertexBuffer.UV6Kind
  73921. * - VertexBuffer.ColorKind
  73922. * - VertexBuffer.MatricesIndicesKind
  73923. * - VertexBuffer.MatricesIndicesExtraKind
  73924. * - VertexBuffer.MatricesWeightsKind
  73925. * - VertexBuffer.MatricesWeightsExtraKind
  73926. *
  73927. * Returns the Mesh.
  73928. */
  73929. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73930. /**
  73931. * Sets the mesh indices.
  73932. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73933. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73934. * This method creates a new index buffer each call.
  73935. * Returns the Mesh.
  73936. */
  73937. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73938. /**
  73939. * Boolean : True if the mesh owns the requested kind of data.
  73940. */
  73941. isVerticesDataPresent(kind: string): boolean;
  73942. /**
  73943. * Returns an array of indices (IndicesArray).
  73944. */
  73945. getIndices(): Nullable<IndicesArray>;
  73946. readonly _positions: Nullable<Vector3[]>;
  73947. /**
  73948. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73949. * This means the mesh underlying bounding box and sphere are recomputed.
  73950. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73951. * @returns the current mesh
  73952. */
  73953. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73954. /** @hidden */
  73955. _preActivate(): InstancedMesh;
  73956. /** @hidden */
  73957. _activate(renderId: number): InstancedMesh;
  73958. /**
  73959. * Returns the current associated LOD AbstractMesh.
  73960. */
  73961. getLOD(camera: Camera): AbstractMesh;
  73962. /** @hidden */
  73963. _syncSubMeshes(): InstancedMesh;
  73964. /** @hidden */
  73965. _generatePointsArray(): boolean;
  73966. /**
  73967. * Creates a new InstancedMesh from the current mesh.
  73968. * - name (string) : the cloned mesh name
  73969. * - newParent (optional Node) : the optional Node to parent the clone to.
  73970. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73971. *
  73972. * Returns the clone.
  73973. */
  73974. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73975. /**
  73976. * Disposes the InstancedMesh.
  73977. * Returns nothing.
  73978. */
  73979. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73980. }
  73981. }
  73982. declare module BABYLON {
  73983. /**
  73984. * Defines the options associated with the creation of a shader material.
  73985. */
  73986. export interface IShaderMaterialOptions {
  73987. /**
  73988. * Does the material work in alpha blend mode
  73989. */
  73990. needAlphaBlending: boolean;
  73991. /**
  73992. * Does the material work in alpha test mode
  73993. */
  73994. needAlphaTesting: boolean;
  73995. /**
  73996. * The list of attribute names used in the shader
  73997. */
  73998. attributes: string[];
  73999. /**
  74000. * The list of unifrom names used in the shader
  74001. */
  74002. uniforms: string[];
  74003. /**
  74004. * The list of UBO names used in the shader
  74005. */
  74006. uniformBuffers: string[];
  74007. /**
  74008. * The list of sampler names used in the shader
  74009. */
  74010. samplers: string[];
  74011. /**
  74012. * The list of defines used in the shader
  74013. */
  74014. defines: string[];
  74015. }
  74016. /**
  74017. * 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.
  74018. *
  74019. * This returned material effects how the mesh will look based on the code in the shaders.
  74020. *
  74021. * @see http://doc.babylonjs.com/how_to/shader_material
  74022. */
  74023. export class ShaderMaterial extends Material {
  74024. private _shaderPath;
  74025. private _options;
  74026. private _textures;
  74027. private _textureArrays;
  74028. private _floats;
  74029. private _ints;
  74030. private _floatsArrays;
  74031. private _colors3;
  74032. private _colors3Arrays;
  74033. private _colors4;
  74034. private _vectors2;
  74035. private _vectors3;
  74036. private _vectors4;
  74037. private _matrices;
  74038. private _matrices3x3;
  74039. private _matrices2x2;
  74040. private _vectors2Arrays;
  74041. private _vectors3Arrays;
  74042. private _cachedWorldViewMatrix;
  74043. private _renderId;
  74044. /**
  74045. * Instantiate a new shader material.
  74046. * 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.
  74047. * This returned material effects how the mesh will look based on the code in the shaders.
  74048. * @see http://doc.babylonjs.com/how_to/shader_material
  74049. * @param name Define the name of the material in the scene
  74050. * @param scene Define the scene the material belongs to
  74051. * @param shaderPath Defines the route to the shader code in one of three ways:
  74052. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74053. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74054. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74055. * @param options Define the options used to create the shader
  74056. */
  74057. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74058. /**
  74059. * Gets the current class name of the material e.g. "ShaderMaterial"
  74060. * Mainly use in serialization.
  74061. * @returns the class name
  74062. */
  74063. getClassName(): string;
  74064. /**
  74065. * Specifies if the material will require alpha blending
  74066. * @returns a boolean specifying if alpha blending is needed
  74067. */
  74068. needAlphaBlending(): boolean;
  74069. /**
  74070. * Specifies if this material should be rendered in alpha test mode
  74071. * @returns a boolean specifying if an alpha test is needed.
  74072. */
  74073. needAlphaTesting(): boolean;
  74074. private _checkUniform;
  74075. /**
  74076. * Set a texture in the shader.
  74077. * @param name Define the name of the uniform samplers as defined in the shader
  74078. * @param texture Define the texture to bind to this sampler
  74079. * @return the material itself allowing "fluent" like uniform updates
  74080. */
  74081. setTexture(name: string, texture: Texture): ShaderMaterial;
  74082. /**
  74083. * Set a texture array in the shader.
  74084. * @param name Define the name of the uniform sampler array as defined in the shader
  74085. * @param textures Define the list of textures to bind to this sampler
  74086. * @return the material itself allowing "fluent" like uniform updates
  74087. */
  74088. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74089. /**
  74090. * Set a float in the shader.
  74091. * @param name Define the name of the uniform as defined in the shader
  74092. * @param value Define the value to give to the uniform
  74093. * @return the material itself allowing "fluent" like uniform updates
  74094. */
  74095. setFloat(name: string, value: number): ShaderMaterial;
  74096. /**
  74097. * Set a int in the shader.
  74098. * @param name Define the name of the uniform as defined in the shader
  74099. * @param value Define the value to give to the uniform
  74100. * @return the material itself allowing "fluent" like uniform updates
  74101. */
  74102. setInt(name: string, value: number): ShaderMaterial;
  74103. /**
  74104. * Set an array of floats in the shader.
  74105. * @param name Define the name of the uniform as defined in the shader
  74106. * @param value Define the value to give to the uniform
  74107. * @return the material itself allowing "fluent" like uniform updates
  74108. */
  74109. setFloats(name: string, value: number[]): ShaderMaterial;
  74110. /**
  74111. * Set a vec3 in the shader from a Color3.
  74112. * @param name Define the name of the uniform as defined in the shader
  74113. * @param value Define the value to give to the uniform
  74114. * @return the material itself allowing "fluent" like uniform updates
  74115. */
  74116. setColor3(name: string, value: Color3): ShaderMaterial;
  74117. /**
  74118. * Set a vec3 array in the shader from a Color3 array.
  74119. * @param name Define the name of the uniform as defined in the shader
  74120. * @param value Define the value to give to the uniform
  74121. * @return the material itself allowing "fluent" like uniform updates
  74122. */
  74123. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74124. /**
  74125. * Set a vec4 in the shader from a Color4.
  74126. * @param name Define the name of the uniform as defined in the shader
  74127. * @param value Define the value to give to the uniform
  74128. * @return the material itself allowing "fluent" like uniform updates
  74129. */
  74130. setColor4(name: string, value: Color4): ShaderMaterial;
  74131. /**
  74132. * Set a vec2 in the shader from a Vector2.
  74133. * @param name Define the name of the uniform as defined in the shader
  74134. * @param value Define the value to give to the uniform
  74135. * @return the material itself allowing "fluent" like uniform updates
  74136. */
  74137. setVector2(name: string, value: Vector2): ShaderMaterial;
  74138. /**
  74139. * Set a vec3 in the shader from a Vector3.
  74140. * @param name Define the name of the uniform as defined in the shader
  74141. * @param value Define the value to give to the uniform
  74142. * @return the material itself allowing "fluent" like uniform updates
  74143. */
  74144. setVector3(name: string, value: Vector3): ShaderMaterial;
  74145. /**
  74146. * Set a vec4 in the shader from a Vector4.
  74147. * @param name Define the name of the uniform as defined in the shader
  74148. * @param value Define the value to give to the uniform
  74149. * @return the material itself allowing "fluent" like uniform updates
  74150. */
  74151. setVector4(name: string, value: Vector4): ShaderMaterial;
  74152. /**
  74153. * Set a mat4 in the shader from a Matrix.
  74154. * @param name Define the name of the uniform as defined in the shader
  74155. * @param value Define the value to give to the uniform
  74156. * @return the material itself allowing "fluent" like uniform updates
  74157. */
  74158. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74159. /**
  74160. * Set a mat3 in the shader from a Float32Array.
  74161. * @param name Define the name of the uniform as defined in the shader
  74162. * @param value Define the value to give to the uniform
  74163. * @return the material itself allowing "fluent" like uniform updates
  74164. */
  74165. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74166. /**
  74167. * Set a mat2 in the shader from a Float32Array.
  74168. * @param name Define the name of the uniform as defined in the shader
  74169. * @param value Define the value to give to the uniform
  74170. * @return the material itself allowing "fluent" like uniform updates
  74171. */
  74172. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74173. /**
  74174. * Set a vec2 array in the shader from a number array.
  74175. * @param name Define the name of the uniform as defined in the shader
  74176. * @param value Define the value to give to the uniform
  74177. * @return the material itself allowing "fluent" like uniform updates
  74178. */
  74179. setArray2(name: string, value: number[]): ShaderMaterial;
  74180. /**
  74181. * Set a vec3 array in the shader from a number array.
  74182. * @param name Define the name of the uniform as defined in the shader
  74183. * @param value Define the value to give to the uniform
  74184. * @return the material itself allowing "fluent" like uniform updates
  74185. */
  74186. setArray3(name: string, value: number[]): ShaderMaterial;
  74187. private _checkCache;
  74188. /**
  74189. * Checks if the material is ready to render the requested mesh
  74190. * @param mesh Define the mesh to render
  74191. * @param useInstances Define whether or not the material is used with instances
  74192. * @returns true if ready, otherwise false
  74193. */
  74194. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74195. /**
  74196. * Binds the world matrix to the material
  74197. * @param world defines the world transformation matrix
  74198. */
  74199. bindOnlyWorldMatrix(world: Matrix): void;
  74200. /**
  74201. * Binds the material to the mesh
  74202. * @param world defines the world transformation matrix
  74203. * @param mesh defines the mesh to bind the material to
  74204. */
  74205. bind(world: Matrix, mesh?: Mesh): void;
  74206. /**
  74207. * Gets the active textures from the material
  74208. * @returns an array of textures
  74209. */
  74210. getActiveTextures(): BaseTexture[];
  74211. /**
  74212. * Specifies if the material uses a texture
  74213. * @param texture defines the texture to check against the material
  74214. * @returns a boolean specifying if the material uses the texture
  74215. */
  74216. hasTexture(texture: BaseTexture): boolean;
  74217. /**
  74218. * Makes a duplicate of the material, and gives it a new name
  74219. * @param name defines the new name for the duplicated material
  74220. * @returns the cloned material
  74221. */
  74222. clone(name: string): ShaderMaterial;
  74223. /**
  74224. * Disposes the material
  74225. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74226. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74227. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74228. */
  74229. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74230. /**
  74231. * Serializes this material in a JSON representation
  74232. * @returns the serialized material object
  74233. */
  74234. serialize(): any;
  74235. /**
  74236. * Creates a shader material from parsed shader material data
  74237. * @param source defines the JSON represnetation of the material
  74238. * @param scene defines the hosting scene
  74239. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74240. * @returns a new material
  74241. */
  74242. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74243. }
  74244. }
  74245. declare module BABYLON {
  74246. /** @hidden */
  74247. export var colorPixelShader: {
  74248. name: string;
  74249. shader: string;
  74250. };
  74251. }
  74252. declare module BABYLON {
  74253. /** @hidden */
  74254. export var colorVertexShader: {
  74255. name: string;
  74256. shader: string;
  74257. };
  74258. }
  74259. declare module BABYLON {
  74260. /**
  74261. * Line mesh
  74262. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74263. */
  74264. export class LinesMesh extends Mesh {
  74265. /**
  74266. * If vertex color should be applied to the mesh
  74267. */
  74268. useVertexColor?: boolean | undefined;
  74269. /**
  74270. * If vertex alpha should be applied to the mesh
  74271. */
  74272. useVertexAlpha?: boolean | undefined;
  74273. /**
  74274. * Color of the line (Default: White)
  74275. */
  74276. color: Color3;
  74277. /**
  74278. * Alpha of the line (Default: 1)
  74279. */
  74280. alpha: number;
  74281. /**
  74282. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74283. * This margin is expressed in world space coordinates, so its value may vary.
  74284. * Default value is 0.1
  74285. */
  74286. intersectionThreshold: number;
  74287. private _colorShader;
  74288. /**
  74289. * Creates a new LinesMesh
  74290. * @param name defines the name
  74291. * @param scene defines the hosting scene
  74292. * @param parent defines the parent mesh if any
  74293. * @param source defines the optional source LinesMesh used to clone data from
  74294. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74295. * When false, achieved by calling a clone(), also passing False.
  74296. * This will make creation of children, recursive.
  74297. * @param useVertexColor defines if this LinesMesh supports vertex color
  74298. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74299. */
  74300. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74301. /**
  74302. * If vertex color should be applied to the mesh
  74303. */
  74304. useVertexColor?: boolean | undefined,
  74305. /**
  74306. * If vertex alpha should be applied to the mesh
  74307. */
  74308. useVertexAlpha?: boolean | undefined);
  74309. /**
  74310. * Returns the string "LineMesh"
  74311. */
  74312. getClassName(): string;
  74313. /**
  74314. * @hidden
  74315. */
  74316. /**
  74317. * @hidden
  74318. */
  74319. material: Material;
  74320. /**
  74321. * @hidden
  74322. */
  74323. readonly checkCollisions: boolean;
  74324. /** @hidden */
  74325. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74326. /** @hidden */
  74327. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74328. /**
  74329. * Disposes of the line mesh
  74330. * @param doNotRecurse If children should be disposed
  74331. */
  74332. dispose(doNotRecurse?: boolean): void;
  74333. /**
  74334. * Returns a new LineMesh object cloned from the current one.
  74335. */
  74336. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74337. /**
  74338. * Creates a new InstancedLinesMesh object from the mesh model.
  74339. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74340. * @param name defines the name of the new instance
  74341. * @returns a new InstancedLinesMesh
  74342. */
  74343. createInstance(name: string): InstancedLinesMesh;
  74344. }
  74345. /**
  74346. * Creates an instance based on a source LinesMesh
  74347. */
  74348. export class InstancedLinesMesh extends InstancedMesh {
  74349. /**
  74350. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74351. * This margin is expressed in world space coordinates, so its value may vary.
  74352. * Initilized with the intersectionThreshold value of the source LinesMesh
  74353. */
  74354. intersectionThreshold: number;
  74355. constructor(name: string, source: LinesMesh);
  74356. /**
  74357. * Returns the string "InstancedLinesMesh".
  74358. */
  74359. getClassName(): string;
  74360. }
  74361. }
  74362. declare module BABYLON {
  74363. /** @hidden */
  74364. export var linePixelShader: {
  74365. name: string;
  74366. shader: string;
  74367. };
  74368. }
  74369. declare module BABYLON {
  74370. /** @hidden */
  74371. export var lineVertexShader: {
  74372. name: string;
  74373. shader: string;
  74374. };
  74375. }
  74376. declare module BABYLON {
  74377. interface AbstractMesh {
  74378. /**
  74379. * Disables the mesh edge rendering mode
  74380. * @returns the currentAbstractMesh
  74381. */
  74382. disableEdgesRendering(): AbstractMesh;
  74383. /**
  74384. * Enables the edge rendering mode on the mesh.
  74385. * This mode makes the mesh edges visible
  74386. * @param epsilon defines the maximal distance between two angles to detect a face
  74387. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74388. * @returns the currentAbstractMesh
  74389. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74390. */
  74391. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74392. /**
  74393. * Gets the edgesRenderer associated with the mesh
  74394. */
  74395. edgesRenderer: Nullable<EdgesRenderer>;
  74396. }
  74397. interface LinesMesh {
  74398. /**
  74399. * Enables the edge rendering mode on the mesh.
  74400. * This mode makes the mesh edges visible
  74401. * @param epsilon defines the maximal distance between two angles to detect a face
  74402. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74403. * @returns the currentAbstractMesh
  74404. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74405. */
  74406. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74407. }
  74408. interface InstancedLinesMesh {
  74409. /**
  74410. * Enables the edge rendering mode on the mesh.
  74411. * This mode makes the mesh edges visible
  74412. * @param epsilon defines the maximal distance between two angles to detect a face
  74413. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74414. * @returns the current InstancedLinesMesh
  74415. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74416. */
  74417. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74418. }
  74419. /**
  74420. * Defines the minimum contract an Edges renderer should follow.
  74421. */
  74422. export interface IEdgesRenderer extends IDisposable {
  74423. /**
  74424. * Gets or sets a boolean indicating if the edgesRenderer is active
  74425. */
  74426. isEnabled: boolean;
  74427. /**
  74428. * Renders the edges of the attached mesh,
  74429. */
  74430. render(): void;
  74431. /**
  74432. * Checks wether or not the edges renderer is ready to render.
  74433. * @return true if ready, otherwise false.
  74434. */
  74435. isReady(): boolean;
  74436. }
  74437. /**
  74438. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74439. */
  74440. export class EdgesRenderer implements IEdgesRenderer {
  74441. /**
  74442. * Define the size of the edges with an orthographic camera
  74443. */
  74444. edgesWidthScalerForOrthographic: number;
  74445. /**
  74446. * Define the size of the edges with a perspective camera
  74447. */
  74448. edgesWidthScalerForPerspective: number;
  74449. protected _source: AbstractMesh;
  74450. protected _linesPositions: number[];
  74451. protected _linesNormals: number[];
  74452. protected _linesIndices: number[];
  74453. protected _epsilon: number;
  74454. protected _indicesCount: number;
  74455. protected _lineShader: ShaderMaterial;
  74456. protected _ib: WebGLBuffer;
  74457. protected _buffers: {
  74458. [key: string]: Nullable<VertexBuffer>;
  74459. };
  74460. protected _checkVerticesInsteadOfIndices: boolean;
  74461. private _meshRebuildObserver;
  74462. private _meshDisposeObserver;
  74463. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74464. isEnabled: boolean;
  74465. /**
  74466. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74467. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74468. * @param source Mesh used to create edges
  74469. * @param epsilon sum of angles in adjacency to check for edge
  74470. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74471. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74472. */
  74473. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74474. protected _prepareRessources(): void;
  74475. /** @hidden */
  74476. _rebuild(): void;
  74477. /**
  74478. * Releases the required resources for the edges renderer
  74479. */
  74480. dispose(): void;
  74481. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74482. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74483. /**
  74484. * Checks if the pair of p0 and p1 is en edge
  74485. * @param faceIndex
  74486. * @param edge
  74487. * @param faceNormals
  74488. * @param p0
  74489. * @param p1
  74490. * @private
  74491. */
  74492. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74493. /**
  74494. * push line into the position, normal and index buffer
  74495. * @protected
  74496. */
  74497. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74498. /**
  74499. * Generates lines edges from adjacencjes
  74500. * @private
  74501. */
  74502. _generateEdgesLines(): void;
  74503. /**
  74504. * Checks wether or not the edges renderer is ready to render.
  74505. * @return true if ready, otherwise false.
  74506. */
  74507. isReady(): boolean;
  74508. /**
  74509. * Renders the edges of the attached mesh,
  74510. */
  74511. render(): void;
  74512. }
  74513. /**
  74514. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74515. */
  74516. export class LineEdgesRenderer extends EdgesRenderer {
  74517. /**
  74518. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74519. * @param source LineMesh used to generate edges
  74520. * @param epsilon not important (specified angle for edge detection)
  74521. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74522. */
  74523. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74524. /**
  74525. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74526. */
  74527. _generateEdgesLines(): void;
  74528. }
  74529. }
  74530. declare module BABYLON {
  74531. /**
  74532. * This represents the object necessary to create a rendering group.
  74533. * This is exclusively used and created by the rendering manager.
  74534. * To modify the behavior, you use the available helpers in your scene or meshes.
  74535. * @hidden
  74536. */
  74537. export class RenderingGroup {
  74538. index: number;
  74539. private _scene;
  74540. private _opaqueSubMeshes;
  74541. private _transparentSubMeshes;
  74542. private _alphaTestSubMeshes;
  74543. private _depthOnlySubMeshes;
  74544. private _particleSystems;
  74545. private _spriteManagers;
  74546. private _opaqueSortCompareFn;
  74547. private _alphaTestSortCompareFn;
  74548. private _transparentSortCompareFn;
  74549. private _renderOpaque;
  74550. private _renderAlphaTest;
  74551. private _renderTransparent;
  74552. private _edgesRenderers;
  74553. onBeforeTransparentRendering: () => void;
  74554. /**
  74555. * Set the opaque sort comparison function.
  74556. * If null the sub meshes will be render in the order they were created
  74557. */
  74558. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74559. /**
  74560. * Set the alpha test sort comparison function.
  74561. * If null the sub meshes will be render in the order they were created
  74562. */
  74563. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74564. /**
  74565. * Set the transparent sort comparison function.
  74566. * If null the sub meshes will be render in the order they were created
  74567. */
  74568. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74569. /**
  74570. * Creates a new rendering group.
  74571. * @param index The rendering group index
  74572. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74573. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74574. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74575. */
  74576. 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>);
  74577. /**
  74578. * Render all the sub meshes contained in the group.
  74579. * @param customRenderFunction Used to override the default render behaviour of the group.
  74580. * @returns true if rendered some submeshes.
  74581. */
  74582. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74583. /**
  74584. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74585. * @param subMeshes The submeshes to render
  74586. */
  74587. private renderOpaqueSorted;
  74588. /**
  74589. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74590. * @param subMeshes The submeshes to render
  74591. */
  74592. private renderAlphaTestSorted;
  74593. /**
  74594. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74595. * @param subMeshes The submeshes to render
  74596. */
  74597. private renderTransparentSorted;
  74598. /**
  74599. * Renders the submeshes in a specified order.
  74600. * @param subMeshes The submeshes to sort before render
  74601. * @param sortCompareFn The comparison function use to sort
  74602. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74603. * @param transparent Specifies to activate blending if true
  74604. */
  74605. private static renderSorted;
  74606. /**
  74607. * Renders the submeshes in the order they were dispatched (no sort applied).
  74608. * @param subMeshes The submeshes to render
  74609. */
  74610. private static renderUnsorted;
  74611. /**
  74612. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74613. * are rendered back to front if in the same alpha index.
  74614. *
  74615. * @param a The first submesh
  74616. * @param b The second submesh
  74617. * @returns The result of the comparison
  74618. */
  74619. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74620. /**
  74621. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74622. * are rendered back to front.
  74623. *
  74624. * @param a The first submesh
  74625. * @param b The second submesh
  74626. * @returns The result of the comparison
  74627. */
  74628. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74629. /**
  74630. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74631. * are rendered front to back (prevent overdraw).
  74632. *
  74633. * @param a The first submesh
  74634. * @param b The second submesh
  74635. * @returns The result of the comparison
  74636. */
  74637. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74638. /**
  74639. * Resets the different lists of submeshes to prepare a new frame.
  74640. */
  74641. prepare(): void;
  74642. dispose(): void;
  74643. /**
  74644. * Inserts the submesh in its correct queue depending on its material.
  74645. * @param subMesh The submesh to dispatch
  74646. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74647. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74648. */
  74649. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74650. dispatchSprites(spriteManager: ISpriteManager): void;
  74651. dispatchParticles(particleSystem: IParticleSystem): void;
  74652. private _renderParticles;
  74653. private _renderSprites;
  74654. }
  74655. }
  74656. declare module BABYLON {
  74657. /**
  74658. * Interface describing the different options available in the rendering manager
  74659. * regarding Auto Clear between groups.
  74660. */
  74661. export interface IRenderingManagerAutoClearSetup {
  74662. /**
  74663. * Defines whether or not autoclear is enable.
  74664. */
  74665. autoClear: boolean;
  74666. /**
  74667. * Defines whether or not to autoclear the depth buffer.
  74668. */
  74669. depth: boolean;
  74670. /**
  74671. * Defines whether or not to autoclear the stencil buffer.
  74672. */
  74673. stencil: boolean;
  74674. }
  74675. /**
  74676. * This class is used by the onRenderingGroupObservable
  74677. */
  74678. export class RenderingGroupInfo {
  74679. /**
  74680. * The Scene that being rendered
  74681. */
  74682. scene: Scene;
  74683. /**
  74684. * The camera currently used for the rendering pass
  74685. */
  74686. camera: Nullable<Camera>;
  74687. /**
  74688. * The ID of the renderingGroup being processed
  74689. */
  74690. renderingGroupId: number;
  74691. }
  74692. /**
  74693. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74694. * It is enable to manage the different groups as well as the different necessary sort functions.
  74695. * This should not be used directly aside of the few static configurations
  74696. */
  74697. export class RenderingManager {
  74698. /**
  74699. * The max id used for rendering groups (not included)
  74700. */
  74701. static MAX_RENDERINGGROUPS: number;
  74702. /**
  74703. * The min id used for rendering groups (included)
  74704. */
  74705. static MIN_RENDERINGGROUPS: number;
  74706. /**
  74707. * Used to globally prevent autoclearing scenes.
  74708. */
  74709. static AUTOCLEAR: boolean;
  74710. /**
  74711. * @hidden
  74712. */
  74713. _useSceneAutoClearSetup: boolean;
  74714. private _scene;
  74715. private _renderingGroups;
  74716. private _depthStencilBufferAlreadyCleaned;
  74717. private _autoClearDepthStencil;
  74718. private _customOpaqueSortCompareFn;
  74719. private _customAlphaTestSortCompareFn;
  74720. private _customTransparentSortCompareFn;
  74721. private _renderingGroupInfo;
  74722. /**
  74723. * Instantiates a new rendering group for a particular scene
  74724. * @param scene Defines the scene the groups belongs to
  74725. */
  74726. constructor(scene: Scene);
  74727. private _clearDepthStencilBuffer;
  74728. /**
  74729. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74730. * @hidden
  74731. */
  74732. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74733. /**
  74734. * Resets the different information of the group to prepare a new frame
  74735. * @hidden
  74736. */
  74737. reset(): void;
  74738. /**
  74739. * Dispose and release the group and its associated resources.
  74740. * @hidden
  74741. */
  74742. dispose(): void;
  74743. /**
  74744. * Clear the info related to rendering groups preventing retention points during dispose.
  74745. */
  74746. freeRenderingGroups(): void;
  74747. private _prepareRenderingGroup;
  74748. /**
  74749. * Add a sprite manager to the rendering manager in order to render it this frame.
  74750. * @param spriteManager Define the sprite manager to render
  74751. */
  74752. dispatchSprites(spriteManager: ISpriteManager): void;
  74753. /**
  74754. * Add a particle system to the rendering manager in order to render it this frame.
  74755. * @param particleSystem Define the particle system to render
  74756. */
  74757. dispatchParticles(particleSystem: IParticleSystem): void;
  74758. /**
  74759. * Add a submesh to the manager in order to render it this frame
  74760. * @param subMesh The submesh to dispatch
  74761. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74762. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74763. */
  74764. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74765. /**
  74766. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74767. * This allowed control for front to back rendering or reversly depending of the special needs.
  74768. *
  74769. * @param renderingGroupId The rendering group id corresponding to its index
  74770. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74771. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74772. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74773. */
  74774. 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;
  74775. /**
  74776. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74777. *
  74778. * @param renderingGroupId The rendering group id corresponding to its index
  74779. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74780. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74781. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74782. */
  74783. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74784. /**
  74785. * Gets the current auto clear configuration for one rendering group of the rendering
  74786. * manager.
  74787. * @param index the rendering group index to get the information for
  74788. * @returns The auto clear setup for the requested rendering group
  74789. */
  74790. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74791. }
  74792. }
  74793. declare module BABYLON {
  74794. /**
  74795. * This Helps creating a texture that will be created from a camera in your scene.
  74796. * It is basically a dynamic texture that could be used to create special effects for instance.
  74797. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74798. */
  74799. export class RenderTargetTexture extends Texture {
  74800. isCube: boolean;
  74801. /**
  74802. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74803. */
  74804. static readonly REFRESHRATE_RENDER_ONCE: number;
  74805. /**
  74806. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74807. */
  74808. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74809. /**
  74810. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74811. * the central point of your effect and can save a lot of performances.
  74812. */
  74813. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74814. /**
  74815. * Use this predicate to dynamically define the list of mesh you want to render.
  74816. * If set, the renderList property will be overwritten.
  74817. */
  74818. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74819. private _renderList;
  74820. /**
  74821. * Use this list to define the list of mesh you want to render.
  74822. */
  74823. renderList: Nullable<Array<AbstractMesh>>;
  74824. private _hookArray;
  74825. /**
  74826. * Define if particles should be rendered in your texture.
  74827. */
  74828. renderParticles: boolean;
  74829. /**
  74830. * Define if sprites should be rendered in your texture.
  74831. */
  74832. renderSprites: boolean;
  74833. /**
  74834. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74835. */
  74836. coordinatesMode: number;
  74837. /**
  74838. * Define the camera used to render the texture.
  74839. */
  74840. activeCamera: Nullable<Camera>;
  74841. /**
  74842. * Override the render function of the texture with your own one.
  74843. */
  74844. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74845. /**
  74846. * Define if camera post processes should be use while rendering the texture.
  74847. */
  74848. useCameraPostProcesses: boolean;
  74849. /**
  74850. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74851. */
  74852. ignoreCameraViewport: boolean;
  74853. private _postProcessManager;
  74854. private _postProcesses;
  74855. private _resizeObserver;
  74856. /**
  74857. * An event triggered when the texture is unbind.
  74858. */
  74859. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74860. /**
  74861. * An event triggered when the texture is unbind.
  74862. */
  74863. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74864. private _onAfterUnbindObserver;
  74865. /**
  74866. * Set a after unbind callback in the texture.
  74867. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74868. */
  74869. onAfterUnbind: () => void;
  74870. /**
  74871. * An event triggered before rendering the texture
  74872. */
  74873. onBeforeRenderObservable: Observable<number>;
  74874. private _onBeforeRenderObserver;
  74875. /**
  74876. * Set a before render callback in the texture.
  74877. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74878. */
  74879. onBeforeRender: (faceIndex: number) => void;
  74880. /**
  74881. * An event triggered after rendering the texture
  74882. */
  74883. onAfterRenderObservable: Observable<number>;
  74884. private _onAfterRenderObserver;
  74885. /**
  74886. * Set a after render callback in the texture.
  74887. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74888. */
  74889. onAfterRender: (faceIndex: number) => void;
  74890. /**
  74891. * An event triggered after the texture clear
  74892. */
  74893. onClearObservable: Observable<Engine>;
  74894. private _onClearObserver;
  74895. /**
  74896. * Set a clear callback in the texture.
  74897. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74898. */
  74899. onClear: (Engine: Engine) => void;
  74900. /**
  74901. * Define the clear color of the Render Target if it should be different from the scene.
  74902. */
  74903. clearColor: Color4;
  74904. protected _size: number | {
  74905. width: number;
  74906. height: number;
  74907. };
  74908. protected _initialSizeParameter: number | {
  74909. width: number;
  74910. height: number;
  74911. } | {
  74912. ratio: number;
  74913. };
  74914. protected _sizeRatio: Nullable<number>;
  74915. /** @hidden */
  74916. _generateMipMaps: boolean;
  74917. protected _renderingManager: RenderingManager;
  74918. /** @hidden */
  74919. _waitingRenderList: string[];
  74920. protected _doNotChangeAspectRatio: boolean;
  74921. protected _currentRefreshId: number;
  74922. protected _refreshRate: number;
  74923. protected _textureMatrix: Matrix;
  74924. protected _samples: number;
  74925. protected _renderTargetOptions: RenderTargetCreationOptions;
  74926. /**
  74927. * Gets render target creation options that were used.
  74928. */
  74929. readonly renderTargetOptions: RenderTargetCreationOptions;
  74930. protected _engine: Engine;
  74931. protected _onRatioRescale(): void;
  74932. /**
  74933. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74934. * It must define where the camera used to render the texture is set
  74935. */
  74936. boundingBoxPosition: Vector3;
  74937. private _boundingBoxSize;
  74938. /**
  74939. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74940. * When defined, the cubemap will switch to local mode
  74941. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74942. * @example https://www.babylonjs-playground.com/#RNASML
  74943. */
  74944. boundingBoxSize: Vector3;
  74945. /**
  74946. * In case the RTT has been created with a depth texture, get the associated
  74947. * depth texture.
  74948. * Otherwise, return null.
  74949. */
  74950. depthStencilTexture: Nullable<InternalTexture>;
  74951. /**
  74952. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74953. * or used a shadow, depth texture...
  74954. * @param name The friendly name of the texture
  74955. * @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)
  74956. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74957. * @param generateMipMaps True if mip maps need to be generated after render.
  74958. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74959. * @param type The type of the buffer in the RTT (int, half float, float...)
  74960. * @param isCube True if a cube texture needs to be created
  74961. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74962. * @param generateDepthBuffer True to generate a depth buffer
  74963. * @param generateStencilBuffer True to generate a stencil buffer
  74964. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74965. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74966. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74967. */
  74968. constructor(name: string, size: number | {
  74969. width: number;
  74970. height: number;
  74971. } | {
  74972. ratio: number;
  74973. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74974. /**
  74975. * Creates a depth stencil texture.
  74976. * This is only available in WebGL 2 or with the depth texture extension available.
  74977. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74978. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74979. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74980. */
  74981. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74982. private _processSizeParameter;
  74983. /**
  74984. * Define the number of samples to use in case of MSAA.
  74985. * It defaults to one meaning no MSAA has been enabled.
  74986. */
  74987. samples: number;
  74988. /**
  74989. * Resets the refresh counter of the texture and start bak from scratch.
  74990. * Could be useful to regenerate the texture if it is setup to render only once.
  74991. */
  74992. resetRefreshCounter(): void;
  74993. /**
  74994. * Define the refresh rate of the texture or the rendering frequency.
  74995. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74996. */
  74997. refreshRate: number;
  74998. /**
  74999. * Adds a post process to the render target rendering passes.
  75000. * @param postProcess define the post process to add
  75001. */
  75002. addPostProcess(postProcess: PostProcess): void;
  75003. /**
  75004. * Clear all the post processes attached to the render target
  75005. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75006. */
  75007. clearPostProcesses(dispose?: boolean): void;
  75008. /**
  75009. * Remove one of the post process from the list of attached post processes to the texture
  75010. * @param postProcess define the post process to remove from the list
  75011. */
  75012. removePostProcess(postProcess: PostProcess): void;
  75013. /** @hidden */
  75014. _shouldRender(): boolean;
  75015. /**
  75016. * Gets the actual render size of the texture.
  75017. * @returns the width of the render size
  75018. */
  75019. getRenderSize(): number;
  75020. /**
  75021. * Gets the actual render width of the texture.
  75022. * @returns the width of the render size
  75023. */
  75024. getRenderWidth(): number;
  75025. /**
  75026. * Gets the actual render height of the texture.
  75027. * @returns the height of the render size
  75028. */
  75029. getRenderHeight(): number;
  75030. /**
  75031. * Get if the texture can be rescaled or not.
  75032. */
  75033. readonly canRescale: boolean;
  75034. /**
  75035. * Resize the texture using a ratio.
  75036. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75037. */
  75038. scale(ratio: number): void;
  75039. /**
  75040. * Get the texture reflection matrix used to rotate/transform the reflection.
  75041. * @returns the reflection matrix
  75042. */
  75043. getReflectionTextureMatrix(): Matrix;
  75044. /**
  75045. * Resize the texture to a new desired size.
  75046. * Be carrefull as it will recreate all the data in the new texture.
  75047. * @param size Define the new size. It can be:
  75048. * - a number for squared texture,
  75049. * - an object containing { width: number, height: number }
  75050. * - or an object containing a ratio { ratio: number }
  75051. */
  75052. resize(size: number | {
  75053. width: number;
  75054. height: number;
  75055. } | {
  75056. ratio: number;
  75057. }): void;
  75058. /**
  75059. * Renders all the objects from the render list into the texture.
  75060. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75061. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75062. */
  75063. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75064. private _bestReflectionRenderTargetDimension;
  75065. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75066. private renderToTarget;
  75067. /**
  75068. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75069. * This allowed control for front to back rendering or reversly depending of the special needs.
  75070. *
  75071. * @param renderingGroupId The rendering group id corresponding to its index
  75072. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75073. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75074. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75075. */
  75076. 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;
  75077. /**
  75078. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75079. *
  75080. * @param renderingGroupId The rendering group id corresponding to its index
  75081. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75082. */
  75083. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75084. /**
  75085. * Clones the texture.
  75086. * @returns the cloned texture
  75087. */
  75088. clone(): RenderTargetTexture;
  75089. /**
  75090. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75091. * @returns The JSON representation of the texture
  75092. */
  75093. serialize(): any;
  75094. /**
  75095. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75096. */
  75097. disposeFramebufferObjects(): void;
  75098. /**
  75099. * Dispose the texture and release its associated resources.
  75100. */
  75101. dispose(): void;
  75102. /** @hidden */
  75103. _rebuild(): void;
  75104. /**
  75105. * Clear the info related to rendering groups preventing retention point in material dispose.
  75106. */
  75107. freeRenderingGroups(): void;
  75108. }
  75109. }
  75110. declare module BABYLON {
  75111. /**
  75112. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75113. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75114. * You can then easily use it as a reflectionTexture on a flat surface.
  75115. * In case the surface is not a plane, please consider relying on reflection probes.
  75116. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75117. */
  75118. export class MirrorTexture extends RenderTargetTexture {
  75119. private scene;
  75120. /**
  75121. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  75122. * 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.
  75123. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75124. */
  75125. mirrorPlane: Plane;
  75126. /**
  75127. * Define the blur ratio used to blur the reflection if needed.
  75128. */
  75129. blurRatio: number;
  75130. /**
  75131. * Define the adaptive blur kernel used to blur the reflection if needed.
  75132. * This will autocompute the closest best match for the `blurKernel`
  75133. */
  75134. adaptiveBlurKernel: number;
  75135. /**
  75136. * Define the blur kernel used to blur the reflection if needed.
  75137. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75138. */
  75139. blurKernel: number;
  75140. /**
  75141. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  75142. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75143. */
  75144. blurKernelX: number;
  75145. /**
  75146. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  75147. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75148. */
  75149. blurKernelY: number;
  75150. private _autoComputeBlurKernel;
  75151. protected _onRatioRescale(): void;
  75152. private _updateGammaSpace;
  75153. private _imageProcessingConfigChangeObserver;
  75154. private _transformMatrix;
  75155. private _mirrorMatrix;
  75156. private _savedViewMatrix;
  75157. private _blurX;
  75158. private _blurY;
  75159. private _adaptiveBlurKernel;
  75160. private _blurKernelX;
  75161. private _blurKernelY;
  75162. private _blurRatio;
  75163. /**
  75164. * Instantiates a Mirror Texture.
  75165. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75166. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75167. * You can then easily use it as a reflectionTexture on a flat surface.
  75168. * In case the surface is not a plane, please consider relying on reflection probes.
  75169. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75170. * @param name
  75171. * @param size
  75172. * @param scene
  75173. * @param generateMipMaps
  75174. * @param type
  75175. * @param samplingMode
  75176. * @param generateDepthBuffer
  75177. */
  75178. constructor(name: string, size: number | {
  75179. width: number;
  75180. height: number;
  75181. } | {
  75182. ratio: number;
  75183. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  75184. private _preparePostProcesses;
  75185. /**
  75186. * Clone the mirror texture.
  75187. * @returns the cloned texture
  75188. */
  75189. clone(): MirrorTexture;
  75190. /**
  75191. * Serialize the texture to a JSON representation you could use in Parse later on
  75192. * @returns the serialized JSON representation
  75193. */
  75194. serialize(): any;
  75195. /**
  75196. * Dispose the texture and release its associated resources.
  75197. */
  75198. dispose(): void;
  75199. }
  75200. }
  75201. declare module BABYLON {
  75202. /**
  75203. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75204. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75205. */
  75206. export class Texture extends BaseTexture {
  75207. /** @hidden */
  75208. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  75209. /** @hidden */
  75210. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  75211. /** @hidden */
  75212. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  75213. /** nearest is mag = nearest and min = nearest and mip = linear */
  75214. static readonly NEAREST_SAMPLINGMODE: number;
  75215. /** nearest is mag = nearest and min = nearest and mip = linear */
  75216. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  75217. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75218. static readonly BILINEAR_SAMPLINGMODE: number;
  75219. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75220. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75221. /** Trilinear is mag = linear and min = linear and mip = linear */
  75222. static readonly TRILINEAR_SAMPLINGMODE: number;
  75223. /** Trilinear is mag = linear and min = linear and mip = linear */
  75224. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75225. /** mag = nearest and min = nearest and mip = nearest */
  75226. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75227. /** mag = nearest and min = linear and mip = nearest */
  75228. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75229. /** mag = nearest and min = linear and mip = linear */
  75230. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75231. /** mag = nearest and min = linear and mip = none */
  75232. static readonly NEAREST_LINEAR: number;
  75233. /** mag = nearest and min = nearest and mip = none */
  75234. static readonly NEAREST_NEAREST: number;
  75235. /** mag = linear and min = nearest and mip = nearest */
  75236. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75237. /** mag = linear and min = nearest and mip = linear */
  75238. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75239. /** mag = linear and min = linear and mip = none */
  75240. static readonly LINEAR_LINEAR: number;
  75241. /** mag = linear and min = nearest and mip = none */
  75242. static readonly LINEAR_NEAREST: number;
  75243. /** Explicit coordinates mode */
  75244. static readonly EXPLICIT_MODE: number;
  75245. /** Spherical coordinates mode */
  75246. static readonly SPHERICAL_MODE: number;
  75247. /** Planar coordinates mode */
  75248. static readonly PLANAR_MODE: number;
  75249. /** Cubic coordinates mode */
  75250. static readonly CUBIC_MODE: number;
  75251. /** Projection coordinates mode */
  75252. static readonly PROJECTION_MODE: number;
  75253. /** Inverse Cubic coordinates mode */
  75254. static readonly SKYBOX_MODE: number;
  75255. /** Inverse Cubic coordinates mode */
  75256. static readonly INVCUBIC_MODE: number;
  75257. /** Equirectangular coordinates mode */
  75258. static readonly EQUIRECTANGULAR_MODE: number;
  75259. /** Equirectangular Fixed coordinates mode */
  75260. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75261. /** Equirectangular Fixed Mirrored coordinates mode */
  75262. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75263. /** Texture is not repeating outside of 0..1 UVs */
  75264. static readonly CLAMP_ADDRESSMODE: number;
  75265. /** Texture is repeating outside of 0..1 UVs */
  75266. static readonly WRAP_ADDRESSMODE: number;
  75267. /** Texture is repeating and mirrored */
  75268. static readonly MIRROR_ADDRESSMODE: number;
  75269. /**
  75270. * 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
  75271. */
  75272. static UseSerializedUrlIfAny: boolean;
  75273. /**
  75274. * Define the url of the texture.
  75275. */
  75276. url: Nullable<string>;
  75277. /**
  75278. * Define an offset on the texture to offset the u coordinates of the UVs
  75279. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75280. */
  75281. uOffset: number;
  75282. /**
  75283. * Define an offset on the texture to offset the v coordinates of the UVs
  75284. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75285. */
  75286. vOffset: number;
  75287. /**
  75288. * Define an offset on the texture to scale the u coordinates of the UVs
  75289. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75290. */
  75291. uScale: number;
  75292. /**
  75293. * Define an offset on the texture to scale the v coordinates of the UVs
  75294. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75295. */
  75296. vScale: number;
  75297. /**
  75298. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75299. * @see http://doc.babylonjs.com/how_to/more_materials
  75300. */
  75301. uAng: number;
  75302. /**
  75303. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75304. * @see http://doc.babylonjs.com/how_to/more_materials
  75305. */
  75306. vAng: number;
  75307. /**
  75308. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75309. * @see http://doc.babylonjs.com/how_to/more_materials
  75310. */
  75311. wAng: number;
  75312. /**
  75313. * Defines the center of rotation (U)
  75314. */
  75315. uRotationCenter: number;
  75316. /**
  75317. * Defines the center of rotation (V)
  75318. */
  75319. vRotationCenter: number;
  75320. /**
  75321. * Defines the center of rotation (W)
  75322. */
  75323. wRotationCenter: number;
  75324. /**
  75325. * Are mip maps generated for this texture or not.
  75326. */
  75327. readonly noMipmap: boolean;
  75328. private _noMipmap;
  75329. /** @hidden */
  75330. _invertY: boolean;
  75331. private _rowGenerationMatrix;
  75332. private _cachedTextureMatrix;
  75333. private _projectionModeMatrix;
  75334. private _t0;
  75335. private _t1;
  75336. private _t2;
  75337. private _cachedUOffset;
  75338. private _cachedVOffset;
  75339. private _cachedUScale;
  75340. private _cachedVScale;
  75341. private _cachedUAng;
  75342. private _cachedVAng;
  75343. private _cachedWAng;
  75344. private _cachedProjectionMatrixId;
  75345. private _cachedCoordinatesMode;
  75346. /** @hidden */
  75347. protected _initialSamplingMode: number;
  75348. /** @hidden */
  75349. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75350. private _deleteBuffer;
  75351. protected _format: Nullable<number>;
  75352. private _delayedOnLoad;
  75353. private _delayedOnError;
  75354. /**
  75355. * Observable triggered once the texture has been loaded.
  75356. */
  75357. onLoadObservable: Observable<Texture>;
  75358. protected _isBlocking: boolean;
  75359. /**
  75360. * Is the texture preventing material to render while loading.
  75361. * If false, a default texture will be used instead of the loading one during the preparation step.
  75362. */
  75363. isBlocking: boolean;
  75364. /**
  75365. * Get the current sampling mode associated with the texture.
  75366. */
  75367. readonly samplingMode: number;
  75368. /**
  75369. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75370. */
  75371. readonly invertY: boolean;
  75372. /**
  75373. * Instantiates a new texture.
  75374. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75375. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75376. * @param url define the url of the picture to load as a texture
  75377. * @param scene define the scene the texture will belong to
  75378. * @param noMipmap define if the texture will require mip maps or not
  75379. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75380. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75381. * @param onLoad define a callback triggered when the texture has been loaded
  75382. * @param onError define a callback triggered when an error occurred during the loading session
  75383. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75384. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75385. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75386. */
  75387. 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);
  75388. /**
  75389. * Update the url (and optional buffer) of this texture if url was null during construction.
  75390. * @param url the url of the texture
  75391. * @param buffer the buffer of the texture (defaults to null)
  75392. * @param onLoad callback called when the texture is loaded (defaults to null)
  75393. */
  75394. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75395. /**
  75396. * Finish the loading sequence of a texture flagged as delayed load.
  75397. * @hidden
  75398. */
  75399. delayLoad(): void;
  75400. private _prepareRowForTextureGeneration;
  75401. /**
  75402. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75403. * @returns the transform matrix of the texture.
  75404. */
  75405. getTextureMatrix(): Matrix;
  75406. /**
  75407. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75408. * @returns The reflection texture transform
  75409. */
  75410. getReflectionTextureMatrix(): Matrix;
  75411. /**
  75412. * Clones the texture.
  75413. * @returns the cloned texture
  75414. */
  75415. clone(): Texture;
  75416. /**
  75417. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75418. * @returns The JSON representation of the texture
  75419. */
  75420. serialize(): any;
  75421. /**
  75422. * Get the current class name of the texture useful for serialization or dynamic coding.
  75423. * @returns "Texture"
  75424. */
  75425. getClassName(): string;
  75426. /**
  75427. * Dispose the texture and release its associated resources.
  75428. */
  75429. dispose(): void;
  75430. /**
  75431. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75432. * @param parsedTexture Define the JSON representation of the texture
  75433. * @param scene Define the scene the parsed texture should be instantiated in
  75434. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75435. * @returns The parsed texture if successful
  75436. */
  75437. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75438. /**
  75439. * Creates a texture from its base 64 representation.
  75440. * @param data Define the base64 payload without the data: prefix
  75441. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75442. * @param scene Define the scene the texture should belong to
  75443. * @param noMipmap Forces the texture to not create mip map information if true
  75444. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75445. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75446. * @param onLoad define a callback triggered when the texture has been loaded
  75447. * @param onError define a callback triggered when an error occurred during the loading session
  75448. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75449. * @returns the created texture
  75450. */
  75451. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75452. /**
  75453. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75454. * @param data Define the base64 payload without the data: prefix
  75455. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75456. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75457. * @param scene Define the scene the texture should belong to
  75458. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75459. * @param noMipmap Forces the texture to not create mip map information if true
  75460. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75461. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75462. * @param onLoad define a callback triggered when the texture has been loaded
  75463. * @param onError define a callback triggered when an error occurred during the loading session
  75464. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75465. * @returns the created texture
  75466. */
  75467. 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;
  75468. }
  75469. }
  75470. declare module BABYLON {
  75471. /**
  75472. * Raw texture can help creating a texture directly from an array of data.
  75473. * This can be super useful if you either get the data from an uncompressed source or
  75474. * if you wish to create your texture pixel by pixel.
  75475. */
  75476. export class RawTexture extends Texture {
  75477. /**
  75478. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75479. */
  75480. format: number;
  75481. private _engine;
  75482. /**
  75483. * Instantiates a new RawTexture.
  75484. * Raw texture can help creating a texture directly from an array of data.
  75485. * This can be super useful if you either get the data from an uncompressed source or
  75486. * if you wish to create your texture pixel by pixel.
  75487. * @param data define the array of data to use to create the texture
  75488. * @param width define the width of the texture
  75489. * @param height define the height of the texture
  75490. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75491. * @param scene define the scene the texture belongs to
  75492. * @param generateMipMaps define whether mip maps should be generated or not
  75493. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75494. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75495. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75496. */
  75497. constructor(data: ArrayBufferView, width: number, height: number,
  75498. /**
  75499. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75500. */
  75501. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75502. /**
  75503. * Updates the texture underlying data.
  75504. * @param data Define the new data of the texture
  75505. */
  75506. update(data: ArrayBufferView): void;
  75507. /**
  75508. * Creates a luminance texture from some data.
  75509. * @param data Define the texture data
  75510. * @param width Define the width of the texture
  75511. * @param height Define the height of the texture
  75512. * @param scene Define the scene the texture belongs to
  75513. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75514. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75515. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75516. * @returns the luminance texture
  75517. */
  75518. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75519. /**
  75520. * Creates a luminance alpha texture from some data.
  75521. * @param data Define the texture data
  75522. * @param width Define the width of the texture
  75523. * @param height Define the height of the texture
  75524. * @param scene Define the scene the texture belongs to
  75525. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75526. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75527. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75528. * @returns the luminance alpha texture
  75529. */
  75530. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75531. /**
  75532. * Creates an alpha texture from some data.
  75533. * @param data Define the texture data
  75534. * @param width Define the width of the texture
  75535. * @param height Define the height of the texture
  75536. * @param scene Define the scene the texture belongs to
  75537. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75538. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75539. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75540. * @returns the alpha texture
  75541. */
  75542. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75543. /**
  75544. * Creates a RGB texture from some data.
  75545. * @param data Define the texture data
  75546. * @param width Define the width of the texture
  75547. * @param height Define the height of the texture
  75548. * @param scene Define the scene the texture belongs to
  75549. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75550. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75551. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75552. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75553. * @returns the RGB alpha texture
  75554. */
  75555. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75556. /**
  75557. * Creates a RGBA texture from some data.
  75558. * @param data Define the texture data
  75559. * @param width Define the width of the texture
  75560. * @param height Define the height of the texture
  75561. * @param scene Define the scene the texture belongs to
  75562. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75563. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75564. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75565. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75566. * @returns the RGBA texture
  75567. */
  75568. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75569. /**
  75570. * Creates a R texture from some data.
  75571. * @param data Define the texture data
  75572. * @param width Define the width of the texture
  75573. * @param height Define the height of the texture
  75574. * @param scene Define the scene the texture belongs to
  75575. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75576. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75577. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75578. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75579. * @returns the R texture
  75580. */
  75581. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75582. }
  75583. }
  75584. declare module BABYLON {
  75585. /**
  75586. * Defines a runtime animation
  75587. */
  75588. export class RuntimeAnimation {
  75589. private _events;
  75590. /**
  75591. * The current frame of the runtime animation
  75592. */
  75593. private _currentFrame;
  75594. /**
  75595. * The animation used by the runtime animation
  75596. */
  75597. private _animation;
  75598. /**
  75599. * The target of the runtime animation
  75600. */
  75601. private _target;
  75602. /**
  75603. * The initiating animatable
  75604. */
  75605. private _host;
  75606. /**
  75607. * The original value of the runtime animation
  75608. */
  75609. private _originalValue;
  75610. /**
  75611. * The original blend value of the runtime animation
  75612. */
  75613. private _originalBlendValue;
  75614. /**
  75615. * The offsets cache of the runtime animation
  75616. */
  75617. private _offsetsCache;
  75618. /**
  75619. * The high limits cache of the runtime animation
  75620. */
  75621. private _highLimitsCache;
  75622. /**
  75623. * Specifies if the runtime animation has been stopped
  75624. */
  75625. private _stopped;
  75626. /**
  75627. * The blending factor of the runtime animation
  75628. */
  75629. private _blendingFactor;
  75630. /**
  75631. * The BabylonJS scene
  75632. */
  75633. private _scene;
  75634. /**
  75635. * The current value of the runtime animation
  75636. */
  75637. private _currentValue;
  75638. /** @hidden */
  75639. _workValue: any;
  75640. /**
  75641. * The active target of the runtime animation
  75642. */
  75643. private _activeTarget;
  75644. /**
  75645. * The target path of the runtime animation
  75646. */
  75647. private _targetPath;
  75648. /**
  75649. * The weight of the runtime animation
  75650. */
  75651. private _weight;
  75652. /**
  75653. * The ratio offset of the runtime animation
  75654. */
  75655. private _ratioOffset;
  75656. /**
  75657. * The previous delay of the runtime animation
  75658. */
  75659. private _previousDelay;
  75660. /**
  75661. * The previous ratio of the runtime animation
  75662. */
  75663. private _previousRatio;
  75664. /**
  75665. * Gets the current frame of the runtime animation
  75666. */
  75667. readonly currentFrame: number;
  75668. /**
  75669. * Gets the weight of the runtime animation
  75670. */
  75671. readonly weight: number;
  75672. /**
  75673. * Gets the current value of the runtime animation
  75674. */
  75675. readonly currentValue: any;
  75676. /**
  75677. * Gets the target path of the runtime animation
  75678. */
  75679. readonly targetPath: string;
  75680. /**
  75681. * Gets the actual target of the runtime animation
  75682. */
  75683. readonly target: any;
  75684. /**
  75685. * Create a new RuntimeAnimation object
  75686. * @param target defines the target of the animation
  75687. * @param animation defines the source animation object
  75688. * @param scene defines the hosting scene
  75689. * @param host defines the initiating Animatable
  75690. */
  75691. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75692. /**
  75693. * Gets the animation from the runtime animation
  75694. */
  75695. readonly animation: Animation;
  75696. /**
  75697. * Resets the runtime animation to the beginning
  75698. * @param restoreOriginal defines whether to restore the target property to the original value
  75699. */
  75700. reset(restoreOriginal?: boolean): void;
  75701. /**
  75702. * Specifies if the runtime animation is stopped
  75703. * @returns Boolean specifying if the runtime animation is stopped
  75704. */
  75705. isStopped(): boolean;
  75706. /**
  75707. * Disposes of the runtime animation
  75708. */
  75709. dispose(): void;
  75710. /**
  75711. * Interpolates the animation from the current frame
  75712. * @param currentFrame The frame to interpolate the animation to
  75713. * @param repeatCount The number of times that the animation should loop
  75714. * @param loopMode The type of looping mode to use
  75715. * @param offsetValue Animation offset value
  75716. * @param highLimitValue The high limit value
  75717. * @returns The interpolated value
  75718. */
  75719. private _interpolate;
  75720. /**
  75721. * Apply the interpolated value to the target
  75722. * @param currentValue defines the value computed by the animation
  75723. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75724. */
  75725. setValue(currentValue: any, weight?: number): void;
  75726. private _setValue;
  75727. /**
  75728. * Gets the loop pmode of the runtime animation
  75729. * @returns Loop Mode
  75730. */
  75731. private _getCorrectLoopMode;
  75732. /**
  75733. * Move the current animation to a given frame
  75734. * @param frame defines the frame to move to
  75735. */
  75736. goToFrame(frame: number): void;
  75737. /**
  75738. * @hidden Internal use only
  75739. */
  75740. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75741. /**
  75742. * Execute the current animation
  75743. * @param delay defines the delay to add to the current frame
  75744. * @param from defines the lower bound of the animation range
  75745. * @param to defines the upper bound of the animation range
  75746. * @param loop defines if the current animation must loop
  75747. * @param speedRatio defines the current speed ratio
  75748. * @param weight defines the weight of the animation (default is -1 so no weight)
  75749. * @param onLoop optional callback called when animation loops
  75750. * @returns a boolean indicating if the animation is running
  75751. */
  75752. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75753. }
  75754. }
  75755. declare module BABYLON {
  75756. /**
  75757. * Class used to store an actual running animation
  75758. */
  75759. export class Animatable {
  75760. /** defines the target object */
  75761. target: any;
  75762. /** defines the starting frame number (default is 0) */
  75763. fromFrame: number;
  75764. /** defines the ending frame number (default is 100) */
  75765. toFrame: number;
  75766. /** defines if the animation must loop (default is false) */
  75767. loopAnimation: boolean;
  75768. /** defines a callback to call when animation ends if it is not looping */
  75769. onAnimationEnd?: (() => void) | null | undefined;
  75770. /** defines a callback to call when animation loops */
  75771. onAnimationLoop?: (() => void) | null | undefined;
  75772. private _localDelayOffset;
  75773. private _pausedDelay;
  75774. private _runtimeAnimations;
  75775. private _paused;
  75776. private _scene;
  75777. private _speedRatio;
  75778. private _weight;
  75779. private _syncRoot;
  75780. /**
  75781. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75782. * This will only apply for non looping animation (default is true)
  75783. */
  75784. disposeOnEnd: boolean;
  75785. /**
  75786. * Gets a boolean indicating if the animation has started
  75787. */
  75788. animationStarted: boolean;
  75789. /**
  75790. * Observer raised when the animation ends
  75791. */
  75792. onAnimationEndObservable: Observable<Animatable>;
  75793. /**
  75794. * Observer raised when the animation loops
  75795. */
  75796. onAnimationLoopObservable: Observable<Animatable>;
  75797. /**
  75798. * Gets the root Animatable used to synchronize and normalize animations
  75799. */
  75800. readonly syncRoot: Animatable;
  75801. /**
  75802. * Gets the current frame of the first RuntimeAnimation
  75803. * Used to synchronize Animatables
  75804. */
  75805. readonly masterFrame: number;
  75806. /**
  75807. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75808. */
  75809. weight: number;
  75810. /**
  75811. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75812. */
  75813. speedRatio: number;
  75814. /**
  75815. * Creates a new Animatable
  75816. * @param scene defines the hosting scene
  75817. * @param target defines the target object
  75818. * @param fromFrame defines the starting frame number (default is 0)
  75819. * @param toFrame defines the ending frame number (default is 100)
  75820. * @param loopAnimation defines if the animation must loop (default is false)
  75821. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75822. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75823. * @param animations defines a group of animation to add to the new Animatable
  75824. * @param onAnimationLoop defines a callback to call when animation loops
  75825. */
  75826. constructor(scene: Scene,
  75827. /** defines the target object */
  75828. target: any,
  75829. /** defines the starting frame number (default is 0) */
  75830. fromFrame?: number,
  75831. /** defines the ending frame number (default is 100) */
  75832. toFrame?: number,
  75833. /** defines if the animation must loop (default is false) */
  75834. loopAnimation?: boolean, speedRatio?: number,
  75835. /** defines a callback to call when animation ends if it is not looping */
  75836. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75837. /** defines a callback to call when animation loops */
  75838. onAnimationLoop?: (() => void) | null | undefined);
  75839. /**
  75840. * Synchronize and normalize current Animatable with a source Animatable
  75841. * This is useful when using animation weights and when animations are not of the same length
  75842. * @param root defines the root Animatable to synchronize with
  75843. * @returns the current Animatable
  75844. */
  75845. syncWith(root: Animatable): Animatable;
  75846. /**
  75847. * Gets the list of runtime animations
  75848. * @returns an array of RuntimeAnimation
  75849. */
  75850. getAnimations(): RuntimeAnimation[];
  75851. /**
  75852. * Adds more animations to the current animatable
  75853. * @param target defines the target of the animations
  75854. * @param animations defines the new animations to add
  75855. */
  75856. appendAnimations(target: any, animations: Animation[]): void;
  75857. /**
  75858. * Gets the source animation for a specific property
  75859. * @param property defines the propertyu to look for
  75860. * @returns null or the source animation for the given property
  75861. */
  75862. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75863. /**
  75864. * Gets the runtime animation for a specific property
  75865. * @param property defines the propertyu to look for
  75866. * @returns null or the runtime animation for the given property
  75867. */
  75868. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75869. /**
  75870. * Resets the animatable to its original state
  75871. */
  75872. reset(): void;
  75873. /**
  75874. * Allows the animatable to blend with current running animations
  75875. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75876. * @param blendingSpeed defines the blending speed to use
  75877. */
  75878. enableBlending(blendingSpeed: number): void;
  75879. /**
  75880. * Disable animation blending
  75881. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75882. */
  75883. disableBlending(): void;
  75884. /**
  75885. * Jump directly to a given frame
  75886. * @param frame defines the frame to jump to
  75887. */
  75888. goToFrame(frame: number): void;
  75889. /**
  75890. * Pause the animation
  75891. */
  75892. pause(): void;
  75893. /**
  75894. * Restart the animation
  75895. */
  75896. restart(): void;
  75897. private _raiseOnAnimationEnd;
  75898. /**
  75899. * Stop and delete the current animation
  75900. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75901. * @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)
  75902. */
  75903. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75904. /**
  75905. * Wait asynchronously for the animation to end
  75906. * @returns a promise which will be fullfilled when the animation ends
  75907. */
  75908. waitAsync(): Promise<Animatable>;
  75909. /** @hidden */
  75910. _animate(delay: number): boolean;
  75911. }
  75912. interface Scene {
  75913. /** @hidden */
  75914. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75915. /** @hidden */
  75916. _processLateAnimationBindingsForMatrices(holder: {
  75917. totalWeight: number;
  75918. animations: RuntimeAnimation[];
  75919. originalValue: Matrix;
  75920. }): any;
  75921. /** @hidden */
  75922. _processLateAnimationBindingsForQuaternions(holder: {
  75923. totalWeight: number;
  75924. animations: RuntimeAnimation[];
  75925. originalValue: Quaternion;
  75926. }, refQuaternion: Quaternion): Quaternion;
  75927. /** @hidden */
  75928. _processLateAnimationBindings(): void;
  75929. /**
  75930. * Will start the animation sequence of a given target
  75931. * @param target defines the target
  75932. * @param from defines from which frame should animation start
  75933. * @param to defines until which frame should animation run.
  75934. * @param weight defines the weight to apply to the animation (1.0 by default)
  75935. * @param loop defines if the animation loops
  75936. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75937. * @param onAnimationEnd defines the function to be executed when the animation ends
  75938. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75939. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75940. * @param onAnimationLoop defines the callback to call when an animation loops
  75941. * @returns the animatable object created for this animation
  75942. */
  75943. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75944. /**
  75945. * Will start the animation sequence of a given target
  75946. * @param target defines the target
  75947. * @param from defines from which frame should animation start
  75948. * @param to defines until which frame should animation run.
  75949. * @param loop defines if the animation loops
  75950. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75951. * @param onAnimationEnd defines the function to be executed when the animation ends
  75952. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75953. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75954. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75955. * @param onAnimationLoop defines the callback to call when an animation loops
  75956. * @returns the animatable object created for this animation
  75957. */
  75958. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75959. /**
  75960. * Will start the animation sequence of a given target and its hierarchy
  75961. * @param target defines the target
  75962. * @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.
  75963. * @param from defines from which frame should animation start
  75964. * @param to defines until which frame should animation run.
  75965. * @param loop defines if the animation loops
  75966. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75967. * @param onAnimationEnd defines the function to be executed when the animation ends
  75968. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75969. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75970. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75971. * @param onAnimationLoop defines the callback to call when an animation loops
  75972. * @returns the list of created animatables
  75973. */
  75974. 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[];
  75975. /**
  75976. * Begin a new animation on a given node
  75977. * @param target defines the target where the animation will take place
  75978. * @param animations defines the list of animations to start
  75979. * @param from defines the initial value
  75980. * @param to defines the final value
  75981. * @param loop defines if you want animation to loop (off by default)
  75982. * @param speedRatio defines the speed ratio to apply to all animations
  75983. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75984. * @param onAnimationLoop defines the callback to call when an animation loops
  75985. * @returns the list of created animatables
  75986. */
  75987. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75988. /**
  75989. * Begin a new animation on a given node and its hierarchy
  75990. * @param target defines the root node where the animation will take place
  75991. * @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.
  75992. * @param animations defines the list of animations to start
  75993. * @param from defines the initial value
  75994. * @param to defines the final value
  75995. * @param loop defines if you want animation to loop (off by default)
  75996. * @param speedRatio defines the speed ratio to apply to all animations
  75997. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75998. * @param onAnimationLoop defines the callback to call when an animation loops
  75999. * @returns the list of animatables created for all nodes
  76000. */
  76001. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76002. /**
  76003. * Gets the animatable associated with a specific target
  76004. * @param target defines the target of the animatable
  76005. * @returns the required animatable if found
  76006. */
  76007. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76008. /**
  76009. * Gets all animatables associated with a given target
  76010. * @param target defines the target to look animatables for
  76011. * @returns an array of Animatables
  76012. */
  76013. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76014. /**
  76015. * Will stop the animation of the given target
  76016. * @param target - the target
  76017. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76018. * @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)
  76019. */
  76020. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76021. /**
  76022. * Stops and removes all animations that have been applied to the scene
  76023. */
  76024. stopAllAnimations(): void;
  76025. }
  76026. interface Bone {
  76027. /**
  76028. * Copy an animation range from another bone
  76029. * @param source defines the source bone
  76030. * @param rangeName defines the range name to copy
  76031. * @param frameOffset defines the frame offset
  76032. * @param rescaleAsRequired defines if rescaling must be applied if required
  76033. * @param skelDimensionsRatio defines the scaling ratio
  76034. * @returns true if operation was successful
  76035. */
  76036. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76037. }
  76038. }
  76039. declare module BABYLON {
  76040. /**
  76041. * Class used to handle skinning animations
  76042. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76043. */
  76044. export class Skeleton implements IAnimatable {
  76045. /** defines the skeleton name */
  76046. name: string;
  76047. /** defines the skeleton Id */
  76048. id: string;
  76049. /**
  76050. * Defines the list of child bones
  76051. */
  76052. bones: Bone[];
  76053. /**
  76054. * Defines an estimate of the dimension of the skeleton at rest
  76055. */
  76056. dimensionsAtRest: Vector3;
  76057. /**
  76058. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76059. */
  76060. needInitialSkinMatrix: boolean;
  76061. /**
  76062. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76063. */
  76064. overrideMesh: Nullable<AbstractMesh>;
  76065. /**
  76066. * Gets the list of animations attached to this skeleton
  76067. */
  76068. animations: Array<Animation>;
  76069. private _scene;
  76070. private _isDirty;
  76071. private _transformMatrices;
  76072. private _transformMatrixTexture;
  76073. private _meshesWithPoseMatrix;
  76074. private _animatables;
  76075. private _identity;
  76076. private _synchronizedWithMesh;
  76077. private _ranges;
  76078. private _lastAbsoluteTransformsUpdateId;
  76079. private _canUseTextureForBones;
  76080. /** @hidden */
  76081. _numBonesWithLinkedTransformNode: number;
  76082. /**
  76083. * Specifies if the skeleton should be serialized
  76084. */
  76085. doNotSerialize: boolean;
  76086. /**
  76087. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76088. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76089. */
  76090. useTextureToStoreBoneMatrices: boolean;
  76091. private _animationPropertiesOverride;
  76092. /**
  76093. * Gets or sets the animation properties override
  76094. */
  76095. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76096. /**
  76097. * An observable triggered before computing the skeleton's matrices
  76098. */
  76099. onBeforeComputeObservable: Observable<Skeleton>;
  76100. /**
  76101. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76102. */
  76103. readonly isUsingTextureForMatrices: boolean;
  76104. /**
  76105. * Creates a new skeleton
  76106. * @param name defines the skeleton name
  76107. * @param id defines the skeleton Id
  76108. * @param scene defines the hosting scene
  76109. */
  76110. constructor(
  76111. /** defines the skeleton name */
  76112. name: string,
  76113. /** defines the skeleton Id */
  76114. id: string, scene: Scene);
  76115. /**
  76116. * Gets the current object class name.
  76117. * @return the class name
  76118. */
  76119. getClassName(): string;
  76120. /**
  76121. * Returns an array containing the root bones
  76122. * @returns an array containing the root bones
  76123. */
  76124. getChildren(): Array<Bone>;
  76125. /**
  76126. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76127. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76128. * @returns a Float32Array containing matrices data
  76129. */
  76130. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76131. /**
  76132. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76133. * @returns a raw texture containing the data
  76134. */
  76135. getTransformMatrixTexture(): Nullable<RawTexture>;
  76136. /**
  76137. * Gets the current hosting scene
  76138. * @returns a scene object
  76139. */
  76140. getScene(): Scene;
  76141. /**
  76142. * Gets a string representing the current skeleton data
  76143. * @param fullDetails defines a boolean indicating if we want a verbose version
  76144. * @returns a string representing the current skeleton data
  76145. */
  76146. toString(fullDetails?: boolean): string;
  76147. /**
  76148. * Get bone's index searching by name
  76149. * @param name defines bone's name to search for
  76150. * @return the indice of the bone. Returns -1 if not found
  76151. */
  76152. getBoneIndexByName(name: string): number;
  76153. /**
  76154. * Creater a new animation range
  76155. * @param name defines the name of the range
  76156. * @param from defines the start key
  76157. * @param to defines the end key
  76158. */
  76159. createAnimationRange(name: string, from: number, to: number): void;
  76160. /**
  76161. * Delete a specific animation range
  76162. * @param name defines the name of the range
  76163. * @param deleteFrames defines if frames must be removed as well
  76164. */
  76165. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76166. /**
  76167. * Gets a specific animation range
  76168. * @param name defines the name of the range to look for
  76169. * @returns the requested animation range or null if not found
  76170. */
  76171. getAnimationRange(name: string): Nullable<AnimationRange>;
  76172. /**
  76173. * Gets the list of all animation ranges defined on this skeleton
  76174. * @returns an array
  76175. */
  76176. getAnimationRanges(): Nullable<AnimationRange>[];
  76177. /**
  76178. * Copy animation range from a source skeleton.
  76179. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76180. * @param source defines the source skeleton
  76181. * @param name defines the name of the range to copy
  76182. * @param rescaleAsRequired defines if rescaling must be applied if required
  76183. * @returns true if operation was successful
  76184. */
  76185. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76186. /**
  76187. * Forces the skeleton to go to rest pose
  76188. */
  76189. returnToRest(): void;
  76190. private _getHighestAnimationFrame;
  76191. /**
  76192. * Begin a specific animation range
  76193. * @param name defines the name of the range to start
  76194. * @param loop defines if looping must be turned on (false by default)
  76195. * @param speedRatio defines the speed ratio to apply (1 by default)
  76196. * @param onAnimationEnd defines a callback which will be called when animation will end
  76197. * @returns a new animatable
  76198. */
  76199. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76200. /** @hidden */
  76201. _markAsDirty(): void;
  76202. /** @hidden */
  76203. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76204. /** @hidden */
  76205. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76206. private _computeTransformMatrices;
  76207. /**
  76208. * Build all resources required to render a skeleton
  76209. */
  76210. prepare(): void;
  76211. /**
  76212. * Gets the list of animatables currently running for this skeleton
  76213. * @returns an array of animatables
  76214. */
  76215. getAnimatables(): IAnimatable[];
  76216. /**
  76217. * Clone the current skeleton
  76218. * @param name defines the name of the new skeleton
  76219. * @param id defines the id of the enw skeleton
  76220. * @returns the new skeleton
  76221. */
  76222. clone(name: string, id: string): Skeleton;
  76223. /**
  76224. * Enable animation blending for this skeleton
  76225. * @param blendingSpeed defines the blending speed to apply
  76226. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76227. */
  76228. enableBlending(blendingSpeed?: number): void;
  76229. /**
  76230. * Releases all resources associated with the current skeleton
  76231. */
  76232. dispose(): void;
  76233. /**
  76234. * Serialize the skeleton in a JSON object
  76235. * @returns a JSON object
  76236. */
  76237. serialize(): any;
  76238. /**
  76239. * Creates a new skeleton from serialized data
  76240. * @param parsedSkeleton defines the serialized data
  76241. * @param scene defines the hosting scene
  76242. * @returns a new skeleton
  76243. */
  76244. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76245. /**
  76246. * Compute all node absolute transforms
  76247. * @param forceUpdate defines if computation must be done even if cache is up to date
  76248. */
  76249. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76250. /**
  76251. * Gets the root pose matrix
  76252. * @returns a matrix
  76253. */
  76254. getPoseMatrix(): Nullable<Matrix>;
  76255. /**
  76256. * Sorts bones per internal index
  76257. */
  76258. sortBones(): void;
  76259. private _sortBones;
  76260. }
  76261. }
  76262. declare module BABYLON {
  76263. /**
  76264. * Defines a target to use with MorphTargetManager
  76265. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76266. */
  76267. export class MorphTarget implements IAnimatable {
  76268. /** defines the name of the target */
  76269. name: string;
  76270. /**
  76271. * Gets or sets the list of animations
  76272. */
  76273. animations: Animation[];
  76274. private _scene;
  76275. private _positions;
  76276. private _normals;
  76277. private _tangents;
  76278. private _influence;
  76279. /**
  76280. * Observable raised when the influence changes
  76281. */
  76282. onInfluenceChanged: Observable<boolean>;
  76283. /** @hidden */
  76284. _onDataLayoutChanged: Observable<void>;
  76285. /**
  76286. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76287. */
  76288. influence: number;
  76289. /**
  76290. * Gets or sets the id of the morph Target
  76291. */
  76292. id: string;
  76293. private _animationPropertiesOverride;
  76294. /**
  76295. * Gets or sets the animation properties override
  76296. */
  76297. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76298. /**
  76299. * Creates a new MorphTarget
  76300. * @param name defines the name of the target
  76301. * @param influence defines the influence to use
  76302. * @param scene defines the scene the morphtarget belongs to
  76303. */
  76304. constructor(
  76305. /** defines the name of the target */
  76306. name: string, influence?: number, scene?: Nullable<Scene>);
  76307. /**
  76308. * Gets a boolean defining if the target contains position data
  76309. */
  76310. readonly hasPositions: boolean;
  76311. /**
  76312. * Gets a boolean defining if the target contains normal data
  76313. */
  76314. readonly hasNormals: boolean;
  76315. /**
  76316. * Gets a boolean defining if the target contains tangent data
  76317. */
  76318. readonly hasTangents: boolean;
  76319. /**
  76320. * Affects position data to this target
  76321. * @param data defines the position data to use
  76322. */
  76323. setPositions(data: Nullable<FloatArray>): void;
  76324. /**
  76325. * Gets the position data stored in this target
  76326. * @returns a FloatArray containing the position data (or null if not present)
  76327. */
  76328. getPositions(): Nullable<FloatArray>;
  76329. /**
  76330. * Affects normal data to this target
  76331. * @param data defines the normal data to use
  76332. */
  76333. setNormals(data: Nullable<FloatArray>): void;
  76334. /**
  76335. * Gets the normal data stored in this target
  76336. * @returns a FloatArray containing the normal data (or null if not present)
  76337. */
  76338. getNormals(): Nullable<FloatArray>;
  76339. /**
  76340. * Affects tangent data to this target
  76341. * @param data defines the tangent data to use
  76342. */
  76343. setTangents(data: Nullable<FloatArray>): void;
  76344. /**
  76345. * Gets the tangent data stored in this target
  76346. * @returns a FloatArray containing the tangent data (or null if not present)
  76347. */
  76348. getTangents(): Nullable<FloatArray>;
  76349. /**
  76350. * Serializes the current target into a Serialization object
  76351. * @returns the serialized object
  76352. */
  76353. serialize(): any;
  76354. /**
  76355. * Returns the string "MorphTarget"
  76356. * @returns "MorphTarget"
  76357. */
  76358. getClassName(): string;
  76359. /**
  76360. * Creates a new target from serialized data
  76361. * @param serializationObject defines the serialized data to use
  76362. * @returns a new MorphTarget
  76363. */
  76364. static Parse(serializationObject: any): MorphTarget;
  76365. /**
  76366. * Creates a MorphTarget from mesh data
  76367. * @param mesh defines the source mesh
  76368. * @param name defines the name to use for the new target
  76369. * @param influence defines the influence to attach to the target
  76370. * @returns a new MorphTarget
  76371. */
  76372. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76373. }
  76374. }
  76375. declare module BABYLON {
  76376. /**
  76377. * This class is used to deform meshes using morphing between different targets
  76378. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76379. */
  76380. export class MorphTargetManager {
  76381. private _targets;
  76382. private _targetInfluenceChangedObservers;
  76383. private _targetDataLayoutChangedObservers;
  76384. private _activeTargets;
  76385. private _scene;
  76386. private _influences;
  76387. private _supportsNormals;
  76388. private _supportsTangents;
  76389. private _vertexCount;
  76390. private _uniqueId;
  76391. private _tempInfluences;
  76392. /**
  76393. * Creates a new MorphTargetManager
  76394. * @param scene defines the current scene
  76395. */
  76396. constructor(scene?: Nullable<Scene>);
  76397. /**
  76398. * Gets the unique ID of this manager
  76399. */
  76400. readonly uniqueId: number;
  76401. /**
  76402. * Gets the number of vertices handled by this manager
  76403. */
  76404. readonly vertexCount: number;
  76405. /**
  76406. * Gets a boolean indicating if this manager supports morphing of normals
  76407. */
  76408. readonly supportsNormals: boolean;
  76409. /**
  76410. * Gets a boolean indicating if this manager supports morphing of tangents
  76411. */
  76412. readonly supportsTangents: boolean;
  76413. /**
  76414. * Gets the number of targets stored in this manager
  76415. */
  76416. readonly numTargets: number;
  76417. /**
  76418. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76419. */
  76420. readonly numInfluencers: number;
  76421. /**
  76422. * Gets the list of influences (one per target)
  76423. */
  76424. readonly influences: Float32Array;
  76425. /**
  76426. * Gets the active target at specified index. An active target is a target with an influence > 0
  76427. * @param index defines the index to check
  76428. * @returns the requested target
  76429. */
  76430. getActiveTarget(index: number): MorphTarget;
  76431. /**
  76432. * Gets the target at specified index
  76433. * @param index defines the index to check
  76434. * @returns the requested target
  76435. */
  76436. getTarget(index: number): MorphTarget;
  76437. /**
  76438. * Add a new target to this manager
  76439. * @param target defines the target to add
  76440. */
  76441. addTarget(target: MorphTarget): void;
  76442. /**
  76443. * Removes a target from the manager
  76444. * @param target defines the target to remove
  76445. */
  76446. removeTarget(target: MorphTarget): void;
  76447. /**
  76448. * Serializes the current manager into a Serialization object
  76449. * @returns the serialized object
  76450. */
  76451. serialize(): any;
  76452. private _syncActiveTargets;
  76453. /**
  76454. * Syncrhonize the targets with all the meshes using this morph target manager
  76455. */
  76456. synchronize(): void;
  76457. /**
  76458. * Creates a new MorphTargetManager from serialized data
  76459. * @param serializationObject defines the serialized data
  76460. * @param scene defines the hosting scene
  76461. * @returns the new MorphTargetManager
  76462. */
  76463. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76464. }
  76465. }
  76466. declare module BABYLON {
  76467. /**
  76468. * Mesh representing the gorund
  76469. */
  76470. export class GroundMesh extends Mesh {
  76471. /** If octree should be generated */
  76472. generateOctree: boolean;
  76473. private _heightQuads;
  76474. /** @hidden */
  76475. _subdivisionsX: number;
  76476. /** @hidden */
  76477. _subdivisionsY: number;
  76478. /** @hidden */
  76479. _width: number;
  76480. /** @hidden */
  76481. _height: number;
  76482. /** @hidden */
  76483. _minX: number;
  76484. /** @hidden */
  76485. _maxX: number;
  76486. /** @hidden */
  76487. _minZ: number;
  76488. /** @hidden */
  76489. _maxZ: number;
  76490. constructor(name: string, scene: Scene);
  76491. /**
  76492. * "GroundMesh"
  76493. * @returns "GroundMesh"
  76494. */
  76495. getClassName(): string;
  76496. /**
  76497. * The minimum of x and y subdivisions
  76498. */
  76499. readonly subdivisions: number;
  76500. /**
  76501. * X subdivisions
  76502. */
  76503. readonly subdivisionsX: number;
  76504. /**
  76505. * Y subdivisions
  76506. */
  76507. readonly subdivisionsY: number;
  76508. /**
  76509. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76510. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76511. * @param chunksCount the number of subdivisions for x and y
  76512. * @param octreeBlocksSize (Default: 32)
  76513. */
  76514. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76515. /**
  76516. * Returns a height (y) value in the Worl system :
  76517. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76518. * @param x x coordinate
  76519. * @param z z coordinate
  76520. * @returns the ground y position if (x, z) are outside the ground surface.
  76521. */
  76522. getHeightAtCoordinates(x: number, z: number): number;
  76523. /**
  76524. * Returns a normalized vector (Vector3) orthogonal to the ground
  76525. * at the ground coordinates (x, z) expressed in the World system.
  76526. * @param x x coordinate
  76527. * @param z z coordinate
  76528. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76529. */
  76530. getNormalAtCoordinates(x: number, z: number): Vector3;
  76531. /**
  76532. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76533. * at the ground coordinates (x, z) expressed in the World system.
  76534. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76535. * @param x x coordinate
  76536. * @param z z coordinate
  76537. * @param ref vector to store the result
  76538. * @returns the GroundMesh.
  76539. */
  76540. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76541. /**
  76542. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76543. * if the ground has been updated.
  76544. * This can be used in the render loop.
  76545. * @returns the GroundMesh.
  76546. */
  76547. updateCoordinateHeights(): GroundMesh;
  76548. private _getFacetAt;
  76549. private _initHeightQuads;
  76550. private _computeHeightQuads;
  76551. /**
  76552. * Serializes this ground mesh
  76553. * @param serializationObject object to write serialization to
  76554. */
  76555. serialize(serializationObject: any): void;
  76556. /**
  76557. * Parses a serialized ground mesh
  76558. * @param parsedMesh the serialized mesh
  76559. * @param scene the scene to create the ground mesh in
  76560. * @returns the created ground mesh
  76561. */
  76562. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76563. }
  76564. }
  76565. declare module BABYLON {
  76566. /**
  76567. * Interface for Physics-Joint data
  76568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76569. */
  76570. export interface PhysicsJointData {
  76571. /**
  76572. * The main pivot of the joint
  76573. */
  76574. mainPivot?: Vector3;
  76575. /**
  76576. * The connected pivot of the joint
  76577. */
  76578. connectedPivot?: Vector3;
  76579. /**
  76580. * The main axis of the joint
  76581. */
  76582. mainAxis?: Vector3;
  76583. /**
  76584. * The connected axis of the joint
  76585. */
  76586. connectedAxis?: Vector3;
  76587. /**
  76588. * The collision of the joint
  76589. */
  76590. collision?: boolean;
  76591. /**
  76592. * Native Oimo/Cannon/Energy data
  76593. */
  76594. nativeParams?: any;
  76595. }
  76596. /**
  76597. * This is a holder class for the physics joint created by the physics plugin
  76598. * It holds a set of functions to control the underlying joint
  76599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76600. */
  76601. export class PhysicsJoint {
  76602. /**
  76603. * The type of the physics joint
  76604. */
  76605. type: number;
  76606. /**
  76607. * The data for the physics joint
  76608. */
  76609. jointData: PhysicsJointData;
  76610. private _physicsJoint;
  76611. protected _physicsPlugin: IPhysicsEnginePlugin;
  76612. /**
  76613. * Initializes the physics joint
  76614. * @param type The type of the physics joint
  76615. * @param jointData The data for the physics joint
  76616. */
  76617. constructor(
  76618. /**
  76619. * The type of the physics joint
  76620. */
  76621. type: number,
  76622. /**
  76623. * The data for the physics joint
  76624. */
  76625. jointData: PhysicsJointData);
  76626. /**
  76627. * Gets the physics joint
  76628. */
  76629. /**
  76630. * Sets the physics joint
  76631. */
  76632. physicsJoint: any;
  76633. /**
  76634. * Sets the physics plugin
  76635. */
  76636. physicsPlugin: IPhysicsEnginePlugin;
  76637. /**
  76638. * Execute a function that is physics-plugin specific.
  76639. * @param {Function} func the function that will be executed.
  76640. * It accepts two parameters: the physics world and the physics joint
  76641. */
  76642. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76643. /**
  76644. * Distance-Joint type
  76645. */
  76646. static DistanceJoint: number;
  76647. /**
  76648. * Hinge-Joint type
  76649. */
  76650. static HingeJoint: number;
  76651. /**
  76652. * Ball-and-Socket joint type
  76653. */
  76654. static BallAndSocketJoint: number;
  76655. /**
  76656. * Wheel-Joint type
  76657. */
  76658. static WheelJoint: number;
  76659. /**
  76660. * Slider-Joint type
  76661. */
  76662. static SliderJoint: number;
  76663. /**
  76664. * Prismatic-Joint type
  76665. */
  76666. static PrismaticJoint: number;
  76667. /**
  76668. * Universal-Joint type
  76669. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76670. */
  76671. static UniversalJoint: number;
  76672. /**
  76673. * Hinge-Joint 2 type
  76674. */
  76675. static Hinge2Joint: number;
  76676. /**
  76677. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76678. */
  76679. static PointToPointJoint: number;
  76680. /**
  76681. * Spring-Joint type
  76682. */
  76683. static SpringJoint: number;
  76684. /**
  76685. * Lock-Joint type
  76686. */
  76687. static LockJoint: number;
  76688. }
  76689. /**
  76690. * A class representing a physics distance joint
  76691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76692. */
  76693. export class DistanceJoint extends PhysicsJoint {
  76694. /**
  76695. *
  76696. * @param jointData The data for the Distance-Joint
  76697. */
  76698. constructor(jointData: DistanceJointData);
  76699. /**
  76700. * Update the predefined distance.
  76701. * @param maxDistance The maximum preferred distance
  76702. * @param minDistance The minimum preferred distance
  76703. */
  76704. updateDistance(maxDistance: number, minDistance?: number): void;
  76705. }
  76706. /**
  76707. * Represents a Motor-Enabled Joint
  76708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76709. */
  76710. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76711. /**
  76712. * Initializes the Motor-Enabled Joint
  76713. * @param type The type of the joint
  76714. * @param jointData The physica joint data for the joint
  76715. */
  76716. constructor(type: number, jointData: PhysicsJointData);
  76717. /**
  76718. * Set the motor values.
  76719. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76720. * @param force the force to apply
  76721. * @param maxForce max force for this motor.
  76722. */
  76723. setMotor(force?: number, maxForce?: number): void;
  76724. /**
  76725. * Set the motor's limits.
  76726. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76727. * @param upperLimit The upper limit of the motor
  76728. * @param lowerLimit The lower limit of the motor
  76729. */
  76730. setLimit(upperLimit: number, lowerLimit?: number): void;
  76731. }
  76732. /**
  76733. * This class represents a single physics Hinge-Joint
  76734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76735. */
  76736. export class HingeJoint extends MotorEnabledJoint {
  76737. /**
  76738. * Initializes the Hinge-Joint
  76739. * @param jointData The joint data for the Hinge-Joint
  76740. */
  76741. constructor(jointData: PhysicsJointData);
  76742. /**
  76743. * Set the motor values.
  76744. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76745. * @param {number} force the force to apply
  76746. * @param {number} maxForce max force for this motor.
  76747. */
  76748. setMotor(force?: number, maxForce?: number): void;
  76749. /**
  76750. * Set the motor's limits.
  76751. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76752. * @param upperLimit The upper limit of the motor
  76753. * @param lowerLimit The lower limit of the motor
  76754. */
  76755. setLimit(upperLimit: number, lowerLimit?: number): void;
  76756. }
  76757. /**
  76758. * This class represents a dual hinge physics joint (same as wheel joint)
  76759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76760. */
  76761. export class Hinge2Joint extends MotorEnabledJoint {
  76762. /**
  76763. * Initializes the Hinge2-Joint
  76764. * @param jointData The joint data for the Hinge2-Joint
  76765. */
  76766. constructor(jointData: PhysicsJointData);
  76767. /**
  76768. * Set the motor values.
  76769. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76770. * @param {number} targetSpeed the speed the motor is to reach
  76771. * @param {number} maxForce max force for this motor.
  76772. * @param {motorIndex} the motor's index, 0 or 1.
  76773. */
  76774. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76775. /**
  76776. * Set the motor limits.
  76777. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76778. * @param {number} upperLimit the upper limit
  76779. * @param {number} lowerLimit lower limit
  76780. * @param {motorIndex} the motor's index, 0 or 1.
  76781. */
  76782. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76783. }
  76784. /**
  76785. * Interface for a motor enabled joint
  76786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76787. */
  76788. export interface IMotorEnabledJoint {
  76789. /**
  76790. * Physics joint
  76791. */
  76792. physicsJoint: any;
  76793. /**
  76794. * Sets the motor of the motor-enabled joint
  76795. * @param force The force of the motor
  76796. * @param maxForce The maximum force of the motor
  76797. * @param motorIndex The index of the motor
  76798. */
  76799. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76800. /**
  76801. * Sets the limit of the motor
  76802. * @param upperLimit The upper limit of the motor
  76803. * @param lowerLimit The lower limit of the motor
  76804. * @param motorIndex The index of the motor
  76805. */
  76806. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76807. }
  76808. /**
  76809. * Joint data for a Distance-Joint
  76810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76811. */
  76812. export interface DistanceJointData extends PhysicsJointData {
  76813. /**
  76814. * Max distance the 2 joint objects can be apart
  76815. */
  76816. maxDistance: number;
  76817. }
  76818. /**
  76819. * Joint data from a spring joint
  76820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76821. */
  76822. export interface SpringJointData extends PhysicsJointData {
  76823. /**
  76824. * Length of the spring
  76825. */
  76826. length: number;
  76827. /**
  76828. * Stiffness of the spring
  76829. */
  76830. stiffness: number;
  76831. /**
  76832. * Damping of the spring
  76833. */
  76834. damping: number;
  76835. /** this callback will be called when applying the force to the impostors. */
  76836. forceApplicationCallback: () => void;
  76837. }
  76838. }
  76839. declare module BABYLON {
  76840. /**
  76841. * Interface used to describe a physics joint
  76842. */
  76843. export interface PhysicsImpostorJoint {
  76844. /** Defines the main impostor to which the joint is linked */
  76845. mainImpostor: PhysicsImpostor;
  76846. /** Defines the impostor that is connected to the main impostor using this joint */
  76847. connectedImpostor: PhysicsImpostor;
  76848. /** Defines the joint itself */
  76849. joint: PhysicsJoint;
  76850. }
  76851. /** @hidden */
  76852. export interface IPhysicsEnginePlugin {
  76853. world: any;
  76854. name: string;
  76855. setGravity(gravity: Vector3): void;
  76856. setTimeStep(timeStep: number): void;
  76857. getTimeStep(): number;
  76858. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76859. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76860. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76861. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76862. removePhysicsBody(impostor: PhysicsImpostor): void;
  76863. generateJoint(joint: PhysicsImpostorJoint): void;
  76864. removeJoint(joint: PhysicsImpostorJoint): void;
  76865. isSupported(): boolean;
  76866. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76867. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76868. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76869. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76870. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76871. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76872. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76873. getBodyMass(impostor: PhysicsImpostor): number;
  76874. getBodyFriction(impostor: PhysicsImpostor): number;
  76875. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76876. getBodyRestitution(impostor: PhysicsImpostor): number;
  76877. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76878. sleepBody(impostor: PhysicsImpostor): void;
  76879. wakeUpBody(impostor: PhysicsImpostor): void;
  76880. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76881. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76882. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76883. getRadius(impostor: PhysicsImpostor): number;
  76884. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76885. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76886. dispose(): void;
  76887. }
  76888. /**
  76889. * Interface used to define a physics engine
  76890. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76891. */
  76892. export interface IPhysicsEngine {
  76893. /**
  76894. * Gets the gravity vector used by the simulation
  76895. */
  76896. gravity: Vector3;
  76897. /**
  76898. * Sets the gravity vector used by the simulation
  76899. * @param gravity defines the gravity vector to use
  76900. */
  76901. setGravity(gravity: Vector3): void;
  76902. /**
  76903. * Set the time step of the physics engine.
  76904. * Default is 1/60.
  76905. * To slow it down, enter 1/600 for example.
  76906. * To speed it up, 1/30
  76907. * @param newTimeStep the new timestep to apply to this world.
  76908. */
  76909. setTimeStep(newTimeStep: number): void;
  76910. /**
  76911. * Get the time step of the physics engine.
  76912. * @returns the current time step
  76913. */
  76914. getTimeStep(): number;
  76915. /**
  76916. * Release all resources
  76917. */
  76918. dispose(): void;
  76919. /**
  76920. * Gets the name of the current physics plugin
  76921. * @returns the name of the plugin
  76922. */
  76923. getPhysicsPluginName(): string;
  76924. /**
  76925. * Adding a new impostor for the impostor tracking.
  76926. * This will be done by the impostor itself.
  76927. * @param impostor the impostor to add
  76928. */
  76929. addImpostor(impostor: PhysicsImpostor): void;
  76930. /**
  76931. * Remove an impostor from the engine.
  76932. * This impostor and its mesh will not longer be updated by the physics engine.
  76933. * @param impostor the impostor to remove
  76934. */
  76935. removeImpostor(impostor: PhysicsImpostor): void;
  76936. /**
  76937. * Add a joint to the physics engine
  76938. * @param mainImpostor defines the main impostor to which the joint is added.
  76939. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76940. * @param joint defines the joint that will connect both impostors.
  76941. */
  76942. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76943. /**
  76944. * Removes a joint from the simulation
  76945. * @param mainImpostor defines the impostor used with the joint
  76946. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76947. * @param joint defines the joint to remove
  76948. */
  76949. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76950. /**
  76951. * Gets the current plugin used to run the simulation
  76952. * @returns current plugin
  76953. */
  76954. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76955. /**
  76956. * Gets the list of physic impostors
  76957. * @returns an array of PhysicsImpostor
  76958. */
  76959. getImpostors(): Array<PhysicsImpostor>;
  76960. /**
  76961. * Gets the impostor for a physics enabled object
  76962. * @param object defines the object impersonated by the impostor
  76963. * @returns the PhysicsImpostor or null if not found
  76964. */
  76965. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76966. /**
  76967. * Gets the impostor for a physics body object
  76968. * @param body defines physics body used by the impostor
  76969. * @returns the PhysicsImpostor or null if not found
  76970. */
  76971. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76972. /**
  76973. * Called by the scene. No need to call it.
  76974. * @param delta defines the timespam between frames
  76975. */
  76976. _step(delta: number): void;
  76977. }
  76978. }
  76979. declare module BABYLON {
  76980. /**
  76981. * The interface for the physics imposter parameters
  76982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76983. */
  76984. export interface PhysicsImpostorParameters {
  76985. /**
  76986. * The mass of the physics imposter
  76987. */
  76988. mass: number;
  76989. /**
  76990. * The friction of the physics imposter
  76991. */
  76992. friction?: number;
  76993. /**
  76994. * The coefficient of restitution of the physics imposter
  76995. */
  76996. restitution?: number;
  76997. /**
  76998. * The native options of the physics imposter
  76999. */
  77000. nativeOptions?: any;
  77001. /**
  77002. * Specifies if the parent should be ignored
  77003. */
  77004. ignoreParent?: boolean;
  77005. /**
  77006. * Specifies if bi-directional transformations should be disabled
  77007. */
  77008. disableBidirectionalTransformation?: boolean;
  77009. }
  77010. /**
  77011. * Interface for a physics-enabled object
  77012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77013. */
  77014. export interface IPhysicsEnabledObject {
  77015. /**
  77016. * The position of the physics-enabled object
  77017. */
  77018. position: Vector3;
  77019. /**
  77020. * The rotation of the physics-enabled object
  77021. */
  77022. rotationQuaternion: Nullable<Quaternion>;
  77023. /**
  77024. * The scale of the physics-enabled object
  77025. */
  77026. scaling: Vector3;
  77027. /**
  77028. * The rotation of the physics-enabled object
  77029. */
  77030. rotation?: Vector3;
  77031. /**
  77032. * The parent of the physics-enabled object
  77033. */
  77034. parent?: any;
  77035. /**
  77036. * The bounding info of the physics-enabled object
  77037. * @returns The bounding info of the physics-enabled object
  77038. */
  77039. getBoundingInfo(): BoundingInfo;
  77040. /**
  77041. * Computes the world matrix
  77042. * @param force Specifies if the world matrix should be computed by force
  77043. * @returns A world matrix
  77044. */
  77045. computeWorldMatrix(force: boolean): Matrix;
  77046. /**
  77047. * Gets the world matrix
  77048. * @returns A world matrix
  77049. */
  77050. getWorldMatrix?(): Matrix;
  77051. /**
  77052. * Gets the child meshes
  77053. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  77054. * @returns An array of abstract meshes
  77055. */
  77056. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  77057. /**
  77058. * Gets the vertex data
  77059. * @param kind The type of vertex data
  77060. * @returns A nullable array of numbers, or a float32 array
  77061. */
  77062. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  77063. /**
  77064. * Gets the indices from the mesh
  77065. * @returns A nullable array of index arrays
  77066. */
  77067. getIndices?(): Nullable<IndicesArray>;
  77068. /**
  77069. * Gets the scene from the mesh
  77070. * @returns the indices array or null
  77071. */
  77072. getScene?(): Scene;
  77073. /**
  77074. * Gets the absolute position from the mesh
  77075. * @returns the absolute position
  77076. */
  77077. getAbsolutePosition(): Vector3;
  77078. /**
  77079. * Gets the absolute pivot point from the mesh
  77080. * @returns the absolute pivot point
  77081. */
  77082. getAbsolutePivotPoint(): Vector3;
  77083. /**
  77084. * Rotates the mesh
  77085. * @param axis The axis of rotation
  77086. * @param amount The amount of rotation
  77087. * @param space The space of the rotation
  77088. * @returns The rotation transform node
  77089. */
  77090. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77091. /**
  77092. * Translates the mesh
  77093. * @param axis The axis of translation
  77094. * @param distance The distance of translation
  77095. * @param space The space of the translation
  77096. * @returns The transform node
  77097. */
  77098. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77099. /**
  77100. * Sets the absolute position of the mesh
  77101. * @param absolutePosition The absolute position of the mesh
  77102. * @returns The transform node
  77103. */
  77104. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77105. /**
  77106. * Gets the class name of the mesh
  77107. * @returns The class name
  77108. */
  77109. getClassName(): string;
  77110. }
  77111. /**
  77112. * Represents a physics imposter
  77113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77114. */
  77115. export class PhysicsImpostor {
  77116. /**
  77117. * The physics-enabled object used as the physics imposter
  77118. */
  77119. object: IPhysicsEnabledObject;
  77120. /**
  77121. * The type of the physics imposter
  77122. */
  77123. type: number;
  77124. private _options;
  77125. private _scene?;
  77126. /**
  77127. * The default object size of the imposter
  77128. */
  77129. static DEFAULT_OBJECT_SIZE: Vector3;
  77130. /**
  77131. * The identity quaternion of the imposter
  77132. */
  77133. static IDENTITY_QUATERNION: Quaternion;
  77134. /** @hidden */
  77135. _pluginData: any;
  77136. private _physicsEngine;
  77137. private _physicsBody;
  77138. private _bodyUpdateRequired;
  77139. private _onBeforePhysicsStepCallbacks;
  77140. private _onAfterPhysicsStepCallbacks;
  77141. /** @hidden */
  77142. _onPhysicsCollideCallbacks: Array<{
  77143. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  77144. otherImpostors: Array<PhysicsImpostor>;
  77145. }>;
  77146. private _deltaPosition;
  77147. private _deltaRotation;
  77148. private _deltaRotationConjugated;
  77149. private _parent;
  77150. private _isDisposed;
  77151. private static _tmpVecs;
  77152. private static _tmpQuat;
  77153. /**
  77154. * Specifies if the physics imposter is disposed
  77155. */
  77156. readonly isDisposed: boolean;
  77157. /**
  77158. * Gets the mass of the physics imposter
  77159. */
  77160. mass: number;
  77161. /**
  77162. * Gets the coefficient of friction
  77163. */
  77164. /**
  77165. * Sets the coefficient of friction
  77166. */
  77167. friction: number;
  77168. /**
  77169. * Gets the coefficient of restitution
  77170. */
  77171. /**
  77172. * Sets the coefficient of restitution
  77173. */
  77174. restitution: number;
  77175. /**
  77176. * The unique id of the physics imposter
  77177. * set by the physics engine when adding this impostor to the array
  77178. */
  77179. uniqueId: number;
  77180. private _joints;
  77181. /**
  77182. * Initializes the physics imposter
  77183. * @param object The physics-enabled object used as the physics imposter
  77184. * @param type The type of the physics imposter
  77185. * @param _options The options for the physics imposter
  77186. * @param _scene The Babylon scene
  77187. */
  77188. constructor(
  77189. /**
  77190. * The physics-enabled object used as the physics imposter
  77191. */
  77192. object: IPhysicsEnabledObject,
  77193. /**
  77194. * The type of the physics imposter
  77195. */
  77196. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  77197. /**
  77198. * This function will completly initialize this impostor.
  77199. * It will create a new body - but only if this mesh has no parent.
  77200. * If it has, this impostor will not be used other than to define the impostor
  77201. * of the child mesh.
  77202. * @hidden
  77203. */
  77204. _init(): void;
  77205. private _getPhysicsParent;
  77206. /**
  77207. * Should a new body be generated.
  77208. * @returns boolean specifying if body initialization is required
  77209. */
  77210. isBodyInitRequired(): boolean;
  77211. /**
  77212. * Sets the updated scaling
  77213. * @param updated Specifies if the scaling is updated
  77214. */
  77215. setScalingUpdated(): void;
  77216. /**
  77217. * Force a regeneration of this or the parent's impostor's body.
  77218. * Use under cautious - This will remove all joints already implemented.
  77219. */
  77220. forceUpdate(): void;
  77221. /**
  77222. * Gets the body that holds this impostor. Either its own, or its parent.
  77223. */
  77224. /**
  77225. * Set the physics body. Used mainly by the physics engine/plugin
  77226. */
  77227. physicsBody: any;
  77228. /**
  77229. * Get the parent of the physics imposter
  77230. * @returns Physics imposter or null
  77231. */
  77232. /**
  77233. * Sets the parent of the physics imposter
  77234. */
  77235. parent: Nullable<PhysicsImpostor>;
  77236. /**
  77237. * Resets the update flags
  77238. */
  77239. resetUpdateFlags(): void;
  77240. /**
  77241. * Gets the object extend size
  77242. * @returns the object extend size
  77243. */
  77244. getObjectExtendSize(): Vector3;
  77245. /**
  77246. * Gets the object center
  77247. * @returns The object center
  77248. */
  77249. getObjectCenter(): Vector3;
  77250. /**
  77251. * Get a specific parametes from the options parameter
  77252. * @param paramName The object parameter name
  77253. * @returns The object parameter
  77254. */
  77255. getParam(paramName: string): any;
  77256. /**
  77257. * Sets a specific parameter in the options given to the physics plugin
  77258. * @param paramName The parameter name
  77259. * @param value The value of the parameter
  77260. */
  77261. setParam(paramName: string, value: number): void;
  77262. /**
  77263. * Specifically change the body's mass option. Won't recreate the physics body object
  77264. * @param mass The mass of the physics imposter
  77265. */
  77266. setMass(mass: number): void;
  77267. /**
  77268. * Gets the linear velocity
  77269. * @returns linear velocity or null
  77270. */
  77271. getLinearVelocity(): Nullable<Vector3>;
  77272. /**
  77273. * Sets the linear velocity
  77274. * @param velocity linear velocity or null
  77275. */
  77276. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77277. /**
  77278. * Gets the angular velocity
  77279. * @returns angular velocity or null
  77280. */
  77281. getAngularVelocity(): Nullable<Vector3>;
  77282. /**
  77283. * Sets the angular velocity
  77284. * @param velocity The velocity or null
  77285. */
  77286. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77287. /**
  77288. * Execute a function with the physics plugin native code
  77289. * Provide a function the will have two variables - the world object and the physics body object
  77290. * @param func The function to execute with the physics plugin native code
  77291. */
  77292. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77293. /**
  77294. * Register a function that will be executed before the physics world is stepping forward
  77295. * @param func The function to execute before the physics world is stepped forward
  77296. */
  77297. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77298. /**
  77299. * Unregister a function that will be executed before the physics world is stepping forward
  77300. * @param func The function to execute before the physics world is stepped forward
  77301. */
  77302. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77303. /**
  77304. * Register a function that will be executed after the physics step
  77305. * @param func The function to execute after physics step
  77306. */
  77307. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77308. /**
  77309. * Unregisters a function that will be executed after the physics step
  77310. * @param func The function to execute after physics step
  77311. */
  77312. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77313. /**
  77314. * register a function that will be executed when this impostor collides against a different body
  77315. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77316. * @param func Callback that is executed on collision
  77317. */
  77318. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77319. /**
  77320. * Unregisters the physics imposter on contact
  77321. * @param collideAgainst The physics object to collide against
  77322. * @param func Callback to execute on collision
  77323. */
  77324. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77325. private _tmpQuat;
  77326. private _tmpQuat2;
  77327. /**
  77328. * Get the parent rotation
  77329. * @returns The parent rotation
  77330. */
  77331. getParentsRotation(): Quaternion;
  77332. /**
  77333. * this function is executed by the physics engine.
  77334. */
  77335. beforeStep: () => void;
  77336. /**
  77337. * this function is executed by the physics engine
  77338. */
  77339. afterStep: () => void;
  77340. /**
  77341. * Legacy collision detection event support
  77342. */
  77343. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77344. /**
  77345. * event and body object due to cannon's event-based architecture.
  77346. */
  77347. onCollide: (e: {
  77348. body: any;
  77349. }) => void;
  77350. /**
  77351. * Apply a force
  77352. * @param force The force to apply
  77353. * @param contactPoint The contact point for the force
  77354. * @returns The physics imposter
  77355. */
  77356. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77357. /**
  77358. * Apply an impulse
  77359. * @param force The impulse force
  77360. * @param contactPoint The contact point for the impulse force
  77361. * @returns The physics imposter
  77362. */
  77363. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77364. /**
  77365. * A help function to create a joint
  77366. * @param otherImpostor A physics imposter used to create a joint
  77367. * @param jointType The type of joint
  77368. * @param jointData The data for the joint
  77369. * @returns The physics imposter
  77370. */
  77371. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77372. /**
  77373. * Add a joint to this impostor with a different impostor
  77374. * @param otherImpostor A physics imposter used to add a joint
  77375. * @param joint The joint to add
  77376. * @returns The physics imposter
  77377. */
  77378. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77379. /**
  77380. * Will keep this body still, in a sleep mode.
  77381. * @returns the physics imposter
  77382. */
  77383. sleep(): PhysicsImpostor;
  77384. /**
  77385. * Wake the body up.
  77386. * @returns The physics imposter
  77387. */
  77388. wakeUp(): PhysicsImpostor;
  77389. /**
  77390. * Clones the physics imposter
  77391. * @param newObject The physics imposter clones to this physics-enabled object
  77392. * @returns A nullable physics imposter
  77393. */
  77394. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77395. /**
  77396. * Disposes the physics imposter
  77397. */
  77398. dispose(): void;
  77399. /**
  77400. * Sets the delta position
  77401. * @param position The delta position amount
  77402. */
  77403. setDeltaPosition(position: Vector3): void;
  77404. /**
  77405. * Sets the delta rotation
  77406. * @param rotation The delta rotation amount
  77407. */
  77408. setDeltaRotation(rotation: Quaternion): void;
  77409. /**
  77410. * Gets the box size of the physics imposter and stores the result in the input parameter
  77411. * @param result Stores the box size
  77412. * @returns The physics imposter
  77413. */
  77414. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77415. /**
  77416. * Gets the radius of the physics imposter
  77417. * @returns Radius of the physics imposter
  77418. */
  77419. getRadius(): number;
  77420. /**
  77421. * Sync a bone with this impostor
  77422. * @param bone The bone to sync to the impostor.
  77423. * @param boneMesh The mesh that the bone is influencing.
  77424. * @param jointPivot The pivot of the joint / bone in local space.
  77425. * @param distToJoint Optional distance from the impostor to the joint.
  77426. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77427. */
  77428. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77429. /**
  77430. * Sync impostor to a bone
  77431. * @param bone The bone that the impostor will be synced to.
  77432. * @param boneMesh The mesh that the bone is influencing.
  77433. * @param jointPivot The pivot of the joint / bone in local space.
  77434. * @param distToJoint Optional distance from the impostor to the joint.
  77435. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77436. * @param boneAxis Optional vector3 axis the bone is aligned with
  77437. */
  77438. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77439. /**
  77440. * No-Imposter type
  77441. */
  77442. static NoImpostor: number;
  77443. /**
  77444. * Sphere-Imposter type
  77445. */
  77446. static SphereImpostor: number;
  77447. /**
  77448. * Box-Imposter type
  77449. */
  77450. static BoxImpostor: number;
  77451. /**
  77452. * Plane-Imposter type
  77453. */
  77454. static PlaneImpostor: number;
  77455. /**
  77456. * Mesh-imposter type
  77457. */
  77458. static MeshImpostor: number;
  77459. /**
  77460. * Cylinder-Imposter type
  77461. */
  77462. static CylinderImpostor: number;
  77463. /**
  77464. * Particle-Imposter type
  77465. */
  77466. static ParticleImpostor: number;
  77467. /**
  77468. * Heightmap-Imposter type
  77469. */
  77470. static HeightmapImpostor: number;
  77471. }
  77472. }
  77473. declare module BABYLON {
  77474. /**
  77475. * Class used to represent a specific level of detail of a mesh
  77476. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77477. */
  77478. export class MeshLODLevel {
  77479. /** Defines the distance where this level should star being displayed */
  77480. distance: number;
  77481. /** Defines the mesh to use to render this level */
  77482. mesh: Nullable<Mesh>;
  77483. /**
  77484. * Creates a new LOD level
  77485. * @param distance defines the distance where this level should star being displayed
  77486. * @param mesh defines the mesh to use to render this level
  77487. */
  77488. constructor(
  77489. /** Defines the distance where this level should star being displayed */
  77490. distance: number,
  77491. /** Defines the mesh to use to render this level */
  77492. mesh: Nullable<Mesh>);
  77493. }
  77494. /**
  77495. * @hidden
  77496. **/
  77497. export class _CreationDataStorage {
  77498. closePath?: boolean;
  77499. closeArray?: boolean;
  77500. idx: number[];
  77501. dashSize: number;
  77502. gapSize: number;
  77503. path3D: Path3D;
  77504. pathArray: Vector3[][];
  77505. arc: number;
  77506. radius: number;
  77507. cap: number;
  77508. tessellation: number;
  77509. }
  77510. /**
  77511. * @hidden
  77512. **/
  77513. class _InstanceDataStorage {
  77514. visibleInstances: any;
  77515. renderIdForInstances: number[];
  77516. batchCache: _InstancesBatch;
  77517. instancesBufferSize: number;
  77518. instancesBuffer: Nullable<Buffer>;
  77519. instancesData: Float32Array;
  77520. overridenInstanceCount: number;
  77521. }
  77522. /**
  77523. * @hidden
  77524. **/
  77525. export class _InstancesBatch {
  77526. mustReturn: boolean;
  77527. visibleInstances: Nullable<InstancedMesh[]>[];
  77528. renderSelf: boolean[];
  77529. }
  77530. /**
  77531. * Class used to represent renderable models
  77532. */
  77533. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77534. /**
  77535. * Mesh side orientation : usually the external or front surface
  77536. */
  77537. static readonly FRONTSIDE: number;
  77538. /**
  77539. * Mesh side orientation : usually the internal or back surface
  77540. */
  77541. static readonly BACKSIDE: number;
  77542. /**
  77543. * Mesh side orientation : both internal and external or front and back surfaces
  77544. */
  77545. static readonly DOUBLESIDE: number;
  77546. /**
  77547. * Mesh side orientation : by default, `FRONTSIDE`
  77548. */
  77549. static readonly DEFAULTSIDE: number;
  77550. /**
  77551. * Mesh cap setting : no cap
  77552. */
  77553. static readonly NO_CAP: number;
  77554. /**
  77555. * Mesh cap setting : one cap at the beginning of the mesh
  77556. */
  77557. static readonly CAP_START: number;
  77558. /**
  77559. * Mesh cap setting : one cap at the end of the mesh
  77560. */
  77561. static readonly CAP_END: number;
  77562. /**
  77563. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77564. */
  77565. static readonly CAP_ALL: number;
  77566. /**
  77567. * Gets the default side orientation.
  77568. * @param orientation the orientation to value to attempt to get
  77569. * @returns the default orientation
  77570. * @hidden
  77571. */
  77572. static _GetDefaultSideOrientation(orientation?: number): number;
  77573. private _onBeforeRenderObservable;
  77574. private _onBeforeBindObservable;
  77575. private _onAfterRenderObservable;
  77576. private _onBeforeDrawObservable;
  77577. /**
  77578. * An event triggered before rendering the mesh
  77579. */
  77580. readonly onBeforeRenderObservable: Observable<Mesh>;
  77581. /**
  77582. * An event triggered before binding the mesh
  77583. */
  77584. readonly onBeforeBindObservable: Observable<Mesh>;
  77585. /**
  77586. * An event triggered after rendering the mesh
  77587. */
  77588. readonly onAfterRenderObservable: Observable<Mesh>;
  77589. /**
  77590. * An event triggered before drawing the mesh
  77591. */
  77592. readonly onBeforeDrawObservable: Observable<Mesh>;
  77593. private _onBeforeDrawObserver;
  77594. /**
  77595. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77596. */
  77597. onBeforeDraw: () => void;
  77598. /**
  77599. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77600. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77601. */
  77602. delayLoadState: number;
  77603. /**
  77604. * Gets the list of instances created from this mesh
  77605. * it is not supposed to be modified manually.
  77606. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77607. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77608. */
  77609. instances: InstancedMesh[];
  77610. /**
  77611. * Gets the file containing delay loading data for this mesh
  77612. */
  77613. delayLoadingFile: string;
  77614. /** @hidden */
  77615. _binaryInfo: any;
  77616. private _LODLevels;
  77617. /**
  77618. * User defined function used to change how LOD level selection is done
  77619. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77620. */
  77621. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77622. private _morphTargetManager;
  77623. /**
  77624. * Gets or sets the morph target manager
  77625. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77626. */
  77627. morphTargetManager: Nullable<MorphTargetManager>;
  77628. /** @hidden */
  77629. _creationDataStorage: Nullable<_CreationDataStorage>;
  77630. /** @hidden */
  77631. _geometry: Nullable<Geometry>;
  77632. /** @hidden */
  77633. _delayInfo: Array<string>;
  77634. /** @hidden */
  77635. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77636. /** @hidden */
  77637. _instanceDataStorage: _InstanceDataStorage;
  77638. private _effectiveMaterial;
  77639. /** @hidden */
  77640. _shouldGenerateFlatShading: boolean;
  77641. private _preActivateId;
  77642. /** @hidden */
  77643. _originalBuilderSideOrientation: number;
  77644. /**
  77645. * Use this property to change the original side orientation defined at construction time
  77646. */
  77647. overrideMaterialSideOrientation: Nullable<number>;
  77648. private _areNormalsFrozen;
  77649. private _sourcePositions;
  77650. private _sourceNormals;
  77651. private _source;
  77652. private meshMap;
  77653. /**
  77654. * Gets the source mesh (the one used to clone this one from)
  77655. */
  77656. readonly source: Nullable<Mesh>;
  77657. /**
  77658. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77659. */
  77660. isUnIndexed: boolean;
  77661. /**
  77662. * @constructor
  77663. * @param name The value used by scene.getMeshByName() to do a lookup.
  77664. * @param scene The scene to add this mesh to.
  77665. * @param parent The parent of this mesh, if it has one
  77666. * @param source An optional Mesh from which geometry is shared, cloned.
  77667. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77668. * When false, achieved by calling a clone(), also passing False.
  77669. * This will make creation of children, recursive.
  77670. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77671. */
  77672. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77673. /**
  77674. * Gets the class name
  77675. * @returns the string "Mesh".
  77676. */
  77677. getClassName(): string;
  77678. /** @hidden */
  77679. readonly _isMesh: boolean;
  77680. /**
  77681. * Returns a description of this mesh
  77682. * @param fullDetails define if full details about this mesh must be used
  77683. * @returns a descriptive string representing this mesh
  77684. */
  77685. toString(fullDetails?: boolean): string;
  77686. /** @hidden */
  77687. _unBindEffect(): void;
  77688. /**
  77689. * Gets a boolean indicating if this mesh has LOD
  77690. */
  77691. readonly hasLODLevels: boolean;
  77692. /**
  77693. * Gets the list of MeshLODLevel associated with the current mesh
  77694. * @returns an array of MeshLODLevel
  77695. */
  77696. getLODLevels(): MeshLODLevel[];
  77697. private _sortLODLevels;
  77698. /**
  77699. * Add a mesh as LOD level triggered at the given distance.
  77700. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77701. * @param distance The distance from the center of the object to show this level
  77702. * @param mesh The mesh to be added as LOD level (can be null)
  77703. * @return This mesh (for chaining)
  77704. */
  77705. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77706. /**
  77707. * Returns the LOD level mesh at the passed distance or null if not found.
  77708. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77709. * @param distance The distance from the center of the object to show this level
  77710. * @returns a Mesh or `null`
  77711. */
  77712. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77713. /**
  77714. * Remove a mesh from the LOD array
  77715. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77716. * @param mesh defines the mesh to be removed
  77717. * @return This mesh (for chaining)
  77718. */
  77719. removeLODLevel(mesh: Mesh): Mesh;
  77720. /**
  77721. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77722. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77723. * @param camera defines the camera to use to compute distance
  77724. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77725. * @return This mesh (for chaining)
  77726. */
  77727. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77728. /**
  77729. * Gets the mesh internal Geometry object
  77730. */
  77731. readonly geometry: Nullable<Geometry>;
  77732. /**
  77733. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77734. * @returns the total number of vertices
  77735. */
  77736. getTotalVertices(): number;
  77737. /**
  77738. * Returns the content of an associated vertex buffer
  77739. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77740. * - VertexBuffer.PositionKind
  77741. * - VertexBuffer.UVKind
  77742. * - VertexBuffer.UV2Kind
  77743. * - VertexBuffer.UV3Kind
  77744. * - VertexBuffer.UV4Kind
  77745. * - VertexBuffer.UV5Kind
  77746. * - VertexBuffer.UV6Kind
  77747. * - VertexBuffer.ColorKind
  77748. * - VertexBuffer.MatricesIndicesKind
  77749. * - VertexBuffer.MatricesIndicesExtraKind
  77750. * - VertexBuffer.MatricesWeightsKind
  77751. * - VertexBuffer.MatricesWeightsExtraKind
  77752. * @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
  77753. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77754. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77755. */
  77756. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77757. /**
  77758. * Returns the mesh VertexBuffer object from the requested `kind`
  77759. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77760. * - VertexBuffer.PositionKind
  77761. * - VertexBuffer.UVKind
  77762. * - VertexBuffer.UV2Kind
  77763. * - VertexBuffer.UV3Kind
  77764. * - VertexBuffer.UV4Kind
  77765. * - VertexBuffer.UV5Kind
  77766. * - VertexBuffer.UV6Kind
  77767. * - VertexBuffer.ColorKind
  77768. * - VertexBuffer.MatricesIndicesKind
  77769. * - VertexBuffer.MatricesIndicesExtraKind
  77770. * - VertexBuffer.MatricesWeightsKind
  77771. * - VertexBuffer.MatricesWeightsExtraKind
  77772. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77773. */
  77774. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77775. /**
  77776. * Tests if a specific vertex buffer is associated with this mesh
  77777. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77778. * - VertexBuffer.PositionKind
  77779. * - VertexBuffer.UVKind
  77780. * - VertexBuffer.UV2Kind
  77781. * - VertexBuffer.UV3Kind
  77782. * - VertexBuffer.UV4Kind
  77783. * - VertexBuffer.UV5Kind
  77784. * - VertexBuffer.UV6Kind
  77785. * - VertexBuffer.ColorKind
  77786. * - VertexBuffer.MatricesIndicesKind
  77787. * - VertexBuffer.MatricesIndicesExtraKind
  77788. * - VertexBuffer.MatricesWeightsKind
  77789. * - VertexBuffer.MatricesWeightsExtraKind
  77790. * @returns a boolean
  77791. */
  77792. isVerticesDataPresent(kind: string): boolean;
  77793. /**
  77794. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77795. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77796. * - VertexBuffer.PositionKind
  77797. * - VertexBuffer.UVKind
  77798. * - VertexBuffer.UV2Kind
  77799. * - VertexBuffer.UV3Kind
  77800. * - VertexBuffer.UV4Kind
  77801. * - VertexBuffer.UV5Kind
  77802. * - VertexBuffer.UV6Kind
  77803. * - VertexBuffer.ColorKind
  77804. * - VertexBuffer.MatricesIndicesKind
  77805. * - VertexBuffer.MatricesIndicesExtraKind
  77806. * - VertexBuffer.MatricesWeightsKind
  77807. * - VertexBuffer.MatricesWeightsExtraKind
  77808. * @returns a boolean
  77809. */
  77810. isVertexBufferUpdatable(kind: string): boolean;
  77811. /**
  77812. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77813. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77814. * - VertexBuffer.PositionKind
  77815. * - VertexBuffer.UVKind
  77816. * - VertexBuffer.UV2Kind
  77817. * - VertexBuffer.UV3Kind
  77818. * - VertexBuffer.UV4Kind
  77819. * - VertexBuffer.UV5Kind
  77820. * - VertexBuffer.UV6Kind
  77821. * - VertexBuffer.ColorKind
  77822. * - VertexBuffer.MatricesIndicesKind
  77823. * - VertexBuffer.MatricesIndicesExtraKind
  77824. * - VertexBuffer.MatricesWeightsKind
  77825. * - VertexBuffer.MatricesWeightsExtraKind
  77826. * @returns an array of strings
  77827. */
  77828. getVerticesDataKinds(): string[];
  77829. /**
  77830. * Returns a positive integer : the total number of indices in this mesh geometry.
  77831. * @returns the numner of indices or zero if the mesh has no geometry.
  77832. */
  77833. getTotalIndices(): number;
  77834. /**
  77835. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77836. * @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.
  77837. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77838. * @returns the indices array or an empty array if the mesh has no geometry
  77839. */
  77840. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77841. readonly isBlocked: boolean;
  77842. /**
  77843. * Determine if the current mesh is ready to be rendered
  77844. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77845. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77846. * @returns true if all associated assets are ready (material, textures, shaders)
  77847. */
  77848. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77849. /**
  77850. * 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.
  77851. */
  77852. readonly areNormalsFrozen: boolean;
  77853. /**
  77854. * 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.
  77855. * @returns the current mesh
  77856. */
  77857. freezeNormals(): Mesh;
  77858. /**
  77859. * 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
  77860. * @returns the current mesh
  77861. */
  77862. unfreezeNormals(): Mesh;
  77863. /**
  77864. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77865. */
  77866. overridenInstanceCount: number;
  77867. /** @hidden */
  77868. _preActivate(): Mesh;
  77869. /** @hidden */
  77870. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77871. /** @hidden */
  77872. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77873. /**
  77874. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77875. * This means the mesh underlying bounding box and sphere are recomputed.
  77876. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77877. * @returns the current mesh
  77878. */
  77879. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77880. /** @hidden */
  77881. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77882. /**
  77883. * This function will subdivide the mesh into multiple submeshes
  77884. * @param count defines the expected number of submeshes
  77885. */
  77886. subdivide(count: number): void;
  77887. /**
  77888. * Copy a FloatArray into a specific associated vertex buffer
  77889. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77890. * - VertexBuffer.PositionKind
  77891. * - VertexBuffer.UVKind
  77892. * - VertexBuffer.UV2Kind
  77893. * - VertexBuffer.UV3Kind
  77894. * - VertexBuffer.UV4Kind
  77895. * - VertexBuffer.UV5Kind
  77896. * - VertexBuffer.UV6Kind
  77897. * - VertexBuffer.ColorKind
  77898. * - VertexBuffer.MatricesIndicesKind
  77899. * - VertexBuffer.MatricesIndicesExtraKind
  77900. * - VertexBuffer.MatricesWeightsKind
  77901. * - VertexBuffer.MatricesWeightsExtraKind
  77902. * @param data defines the data source
  77903. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77904. * @param stride defines the data stride size (can be null)
  77905. * @returns the current mesh
  77906. */
  77907. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77908. /**
  77909. * Flags an associated vertex buffer as updatable
  77910. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77911. * - VertexBuffer.PositionKind
  77912. * - VertexBuffer.UVKind
  77913. * - VertexBuffer.UV2Kind
  77914. * - VertexBuffer.UV3Kind
  77915. * - VertexBuffer.UV4Kind
  77916. * - VertexBuffer.UV5Kind
  77917. * - VertexBuffer.UV6Kind
  77918. * - VertexBuffer.ColorKind
  77919. * - VertexBuffer.MatricesIndicesKind
  77920. * - VertexBuffer.MatricesIndicesExtraKind
  77921. * - VertexBuffer.MatricesWeightsKind
  77922. * - VertexBuffer.MatricesWeightsExtraKind
  77923. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77924. */
  77925. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77926. /**
  77927. * Sets the mesh global Vertex Buffer
  77928. * @param buffer defines the buffer to use
  77929. * @returns the current mesh
  77930. */
  77931. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77932. /**
  77933. * Update a specific associated vertex buffer
  77934. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77935. * - VertexBuffer.PositionKind
  77936. * - VertexBuffer.UVKind
  77937. * - VertexBuffer.UV2Kind
  77938. * - VertexBuffer.UV3Kind
  77939. * - VertexBuffer.UV4Kind
  77940. * - VertexBuffer.UV5Kind
  77941. * - VertexBuffer.UV6Kind
  77942. * - VertexBuffer.ColorKind
  77943. * - VertexBuffer.MatricesIndicesKind
  77944. * - VertexBuffer.MatricesIndicesExtraKind
  77945. * - VertexBuffer.MatricesWeightsKind
  77946. * - VertexBuffer.MatricesWeightsExtraKind
  77947. * @param data defines the data source
  77948. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77949. * @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)
  77950. * @returns the current mesh
  77951. */
  77952. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77953. /**
  77954. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77955. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77956. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77957. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77958. * @returns the current mesh
  77959. */
  77960. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77961. /**
  77962. * Creates a un-shared specific occurence of the geometry for the mesh.
  77963. * @returns the current mesh
  77964. */
  77965. makeGeometryUnique(): Mesh;
  77966. /**
  77967. * Set the index buffer of this mesh
  77968. * @param indices defines the source data
  77969. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77970. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77971. * @returns the current mesh
  77972. */
  77973. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77974. /**
  77975. * Update the current index buffer
  77976. * @param indices defines the source data
  77977. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77978. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  77979. * @returns the current mesh
  77980. */
  77981. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77982. /**
  77983. * Invert the geometry to move from a right handed system to a left handed one.
  77984. * @returns the current mesh
  77985. */
  77986. toLeftHanded(): Mesh;
  77987. /** @hidden */
  77988. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77989. /** @hidden */
  77990. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77991. /**
  77992. * Registers for this mesh a javascript function called just before the rendering process
  77993. * @param func defines the function to call before rendering this mesh
  77994. * @returns the current mesh
  77995. */
  77996. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77997. /**
  77998. * Disposes a previously registered javascript function called before the rendering
  77999. * @param func defines the function to remove
  78000. * @returns the current mesh
  78001. */
  78002. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78003. /**
  78004. * Registers for this mesh a javascript function called just after the rendering is complete
  78005. * @param func defines the function to call after rendering this mesh
  78006. * @returns the current mesh
  78007. */
  78008. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78009. /**
  78010. * Disposes a previously registered javascript function called after the rendering.
  78011. * @param func defines the function to remove
  78012. * @returns the current mesh
  78013. */
  78014. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78015. /** @hidden */
  78016. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  78017. /** @hidden */
  78018. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  78019. /** @hidden */
  78020. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  78021. /**
  78022. * 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
  78023. * @param subMesh defines the subMesh to render
  78024. * @param enableAlphaMode defines if alpha mode can be changed
  78025. * @returns the current mesh
  78026. */
  78027. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  78028. private _onBeforeDraw;
  78029. /**
  78030. * Renormalize the mesh and patch it up if there are no weights
  78031. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  78032. * However in the case of zero weights then we set just a single influence to 1.
  78033. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  78034. */
  78035. cleanMatrixWeights(): void;
  78036. private normalizeSkinFourWeights;
  78037. private normalizeSkinWeightsAndExtra;
  78038. /**
  78039. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  78040. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  78041. * the user know there was an issue with importing the mesh
  78042. * @returns a validation object with skinned, valid and report string
  78043. */
  78044. validateSkinning(): {
  78045. skinned: boolean;
  78046. valid: boolean;
  78047. report: string;
  78048. };
  78049. /** @hidden */
  78050. _checkDelayState(): Mesh;
  78051. private _queueLoad;
  78052. /**
  78053. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  78054. * A mesh is in the frustum if its bounding box intersects the frustum
  78055. * @param frustumPlanes defines the frustum to test
  78056. * @returns true if the mesh is in the frustum planes
  78057. */
  78058. isInFrustum(frustumPlanes: Plane[]): boolean;
  78059. /**
  78060. * Sets the mesh material by the material or multiMaterial `id` property
  78061. * @param id is a string identifying the material or the multiMaterial
  78062. * @returns the current mesh
  78063. */
  78064. setMaterialByID(id: string): Mesh;
  78065. /**
  78066. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  78067. * @returns an array of IAnimatable
  78068. */
  78069. getAnimatables(): IAnimatable[];
  78070. /**
  78071. * Modifies the mesh geometry according to the passed transformation matrix.
  78072. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  78073. * The mesh normals are modified using the same transformation.
  78074. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78075. * @param transform defines the transform matrix to use
  78076. * @see http://doc.babylonjs.com/resources/baking_transformations
  78077. * @returns the current mesh
  78078. */
  78079. bakeTransformIntoVertices(transform: Matrix): Mesh;
  78080. /**
  78081. * Modifies the mesh geometry according to its own current World Matrix.
  78082. * The mesh World Matrix is then reset.
  78083. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  78084. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78085. * @see http://doc.babylonjs.com/resources/baking_transformations
  78086. * @returns the current mesh
  78087. */
  78088. bakeCurrentTransformIntoVertices(): Mesh;
  78089. /** @hidden */
  78090. readonly _positions: Nullable<Vector3[]>;
  78091. /** @hidden */
  78092. _resetPointsArrayCache(): Mesh;
  78093. /** @hidden */
  78094. _generatePointsArray(): boolean;
  78095. /**
  78096. * Returns a new Mesh object generated from the current mesh properties.
  78097. * This method must not get confused with createInstance()
  78098. * @param name is a string, the name given to the new mesh
  78099. * @param newParent can be any Node object (default `null`)
  78100. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  78101. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  78102. * @returns a new mesh
  78103. */
  78104. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  78105. /**
  78106. * Releases resources associated with this mesh.
  78107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78109. */
  78110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78111. /**
  78112. * Modifies the mesh geometry according to a displacement map.
  78113. * 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.
  78114. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78115. * @param url is a string, the URL from the image file is to be downloaded.
  78116. * @param minHeight is the lower limit of the displacement.
  78117. * @param maxHeight is the upper limit of the displacement.
  78118. * @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.
  78119. * @param uvOffset is an optional vector2 used to offset UV.
  78120. * @param uvScale is an optional vector2 used to scale UV.
  78121. * @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.
  78122. * @returns the Mesh.
  78123. */
  78124. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78125. /**
  78126. * Modifies the mesh geometry according to a displacementMap buffer.
  78127. * 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.
  78128. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78129. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  78130. * @param heightMapWidth is the width of the buffer image.
  78131. * @param heightMapHeight is the height of the buffer image.
  78132. * @param minHeight is the lower limit of the displacement.
  78133. * @param maxHeight is the upper limit of the displacement.
  78134. * @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.
  78135. * @param uvOffset is an optional vector2 used to offset UV.
  78136. * @param uvScale is an optional vector2 used to scale UV.
  78137. * @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.
  78138. * @returns the Mesh.
  78139. */
  78140. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78141. /**
  78142. * Modify the mesh to get a flat shading rendering.
  78143. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  78144. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  78145. * @returns current mesh
  78146. */
  78147. convertToFlatShadedMesh(): Mesh;
  78148. /**
  78149. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  78150. * In other words, more vertices, no more indices and a single bigger VBO.
  78151. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  78152. * @returns current mesh
  78153. */
  78154. convertToUnIndexedMesh(): Mesh;
  78155. /**
  78156. * Inverses facet orientations.
  78157. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  78158. * @param flipNormals will also inverts the normals
  78159. * @returns current mesh
  78160. */
  78161. flipFaces(flipNormals?: boolean): Mesh;
  78162. /** @hidden */
  78163. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  78164. /** @hidden */
  78165. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  78166. /**
  78167. * Creates a new InstancedMesh object from the mesh model.
  78168. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78169. * @param name defines the name of the new instance
  78170. * @returns a new InstancedMesh
  78171. */
  78172. createInstance(name: string): InstancedMesh;
  78173. /**
  78174. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  78175. * After this call, all the mesh instances have the same submeshes than the current mesh.
  78176. * @returns the current mesh
  78177. */
  78178. synchronizeInstances(): Mesh;
  78179. /**
  78180. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  78181. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  78182. * This should be used together with the simplification to avoid disappearing triangles.
  78183. * @param successCallback an optional success callback to be called after the optimization finished.
  78184. * @returns the current mesh
  78185. */
  78186. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  78187. /**
  78188. * Serialize current mesh
  78189. * @param serializationObject defines the object which will receive the serialization data
  78190. */
  78191. serialize(serializationObject: any): void;
  78192. /** @hidden */
  78193. _syncGeometryWithMorphTargetManager(): void;
  78194. /** @hidden */
  78195. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  78196. /**
  78197. * Returns a new Mesh object parsed from the source provided.
  78198. * @param parsedMesh is the source
  78199. * @param scene defines the hosting scene
  78200. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  78201. * @returns a new Mesh
  78202. */
  78203. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  78204. /**
  78205. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  78206. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78207. * @param name defines the name of the mesh to create
  78208. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  78209. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  78210. * @param closePath creates a seam between the first and the last points of each path of the path array
  78211. * @param offset is taken in account only if the `pathArray` is containing a single path
  78212. * @param scene defines the hosting scene
  78213. * @param updatable defines if the mesh must be flagged as updatable
  78214. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78215. * @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)
  78216. * @returns a new Mesh
  78217. */
  78218. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78219. /**
  78220. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78221. * @param name defines the name of the mesh to create
  78222. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78223. * @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
  78224. * @param scene defines the hosting scene
  78225. * @param updatable defines if the mesh must be flagged as updatable
  78226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78227. * @returns a new Mesh
  78228. */
  78229. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78230. /**
  78231. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78232. * @param name defines the name of the mesh to create
  78233. * @param size sets the size (float) of each box side (default 1)
  78234. * @param scene defines the hosting scene
  78235. * @param updatable defines if the mesh must be flagged as updatable
  78236. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78237. * @returns a new Mesh
  78238. */
  78239. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78240. /**
  78241. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78242. * @param name defines the name of the mesh to create
  78243. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78244. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78245. * @param scene defines the hosting scene
  78246. * @param updatable defines if the mesh must be flagged as updatable
  78247. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78248. * @returns a new Mesh
  78249. */
  78250. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78251. /**
  78252. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78253. * @param name defines the name of the mesh to create
  78254. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78255. * @param diameterTop set the top cap diameter (floats, default 1)
  78256. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78257. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78258. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78259. * @param scene defines the hosting scene
  78260. * @param updatable defines if the mesh must be flagged as updatable
  78261. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78262. * @returns a new Mesh
  78263. */
  78264. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78265. /**
  78266. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78267. * @param name defines the name of the mesh to create
  78268. * @param diameter sets the diameter size (float) of the torus (default 1)
  78269. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78270. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78271. * @param scene defines the hosting scene
  78272. * @param updatable defines if the mesh must be flagged as updatable
  78273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78274. * @returns a new Mesh
  78275. */
  78276. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78277. /**
  78278. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78279. * @param name defines the name of the mesh to create
  78280. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78281. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78282. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78283. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78284. * @param p the number of windings on X axis (positive integers, default 2)
  78285. * @param q the number of windings on Y axis (positive integers, default 3)
  78286. * @param scene defines the hosting scene
  78287. * @param updatable defines if the mesh must be flagged as updatable
  78288. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78289. * @returns a new Mesh
  78290. */
  78291. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78292. /**
  78293. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78294. * @param name defines the name of the mesh to create
  78295. * @param points is an array successive Vector3
  78296. * @param scene defines the hosting scene
  78297. * @param updatable defines if the mesh must be flagged as updatable
  78298. * @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).
  78299. * @returns a new Mesh
  78300. */
  78301. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78302. /**
  78303. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78304. * @param name defines the name of the mesh to create
  78305. * @param points is an array successive Vector3
  78306. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78307. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78308. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78309. * @param scene defines the hosting scene
  78310. * @param updatable defines if the mesh must be flagged as updatable
  78311. * @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)
  78312. * @returns a new Mesh
  78313. */
  78314. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78315. /**
  78316. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78317. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78318. * 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.
  78319. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78320. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78321. * Remember you can only change the shape positions, not their number when updating a polygon.
  78322. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78323. * @param name defines the name of the mesh to create
  78324. * @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
  78325. * @param scene defines the hosting scene
  78326. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78327. * @param updatable defines if the mesh must be flagged as updatable
  78328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78329. * @param earcutInjection can be used to inject your own earcut reference
  78330. * @returns a new Mesh
  78331. */
  78332. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78333. /**
  78334. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78335. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78336. * @param name defines the name of the mesh to create
  78337. * @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
  78338. * @param depth defines the height of extrusion
  78339. * @param scene defines the hosting scene
  78340. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78341. * @param updatable defines if the mesh must be flagged as updatable
  78342. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78343. * @param earcutInjection can be used to inject your own earcut reference
  78344. * @returns a new Mesh
  78345. */
  78346. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78347. /**
  78348. * Creates an extruded shape mesh.
  78349. * 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
  78350. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78351. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78352. * @param name defines the name of the mesh to create
  78353. * @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
  78354. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78355. * @param scale is the value to scale the shape
  78356. * @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
  78357. * @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
  78358. * @param scene defines the hosting scene
  78359. * @param updatable defines if the mesh must be flagged as updatable
  78360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78361. * @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)
  78362. * @returns a new Mesh
  78363. */
  78364. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78365. /**
  78366. * Creates an custom extruded shape mesh.
  78367. * The custom extrusion is a parametric shape.
  78368. * It has no predefined shape. Its final shape will depend on the input parameters.
  78369. * Please consider using the same method from the MeshBuilder class instead
  78370. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78371. * @param name defines the name of the mesh to create
  78372. * @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
  78373. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78374. * @param scaleFunction is a custom Javascript function called on each path point
  78375. * @param rotationFunction is a custom Javascript function called on each path point
  78376. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78377. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78378. * @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
  78379. * @param scene defines the hosting scene
  78380. * @param updatable defines if the mesh must be flagged as updatable
  78381. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78382. * @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)
  78383. * @returns a new Mesh
  78384. */
  78385. 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;
  78386. /**
  78387. * Creates lathe mesh.
  78388. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78389. * Please consider using the same method from the MeshBuilder class instead
  78390. * @param name defines the name of the mesh to create
  78391. * @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
  78392. * @param radius is the radius value of the lathe
  78393. * @param tessellation is the side number of the lathe.
  78394. * @param scene defines the hosting scene
  78395. * @param updatable defines if the mesh must be flagged as updatable
  78396. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78397. * @returns a new Mesh
  78398. */
  78399. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78400. /**
  78401. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78402. * @param name defines the name of the mesh to create
  78403. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78404. * @param scene defines the hosting scene
  78405. * @param updatable defines if the mesh must be flagged as updatable
  78406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78407. * @returns a new Mesh
  78408. */
  78409. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78410. /**
  78411. * Creates a ground mesh.
  78412. * Please consider using the same method from the MeshBuilder class instead
  78413. * @param name defines the name of the mesh to create
  78414. * @param width set the width of the ground
  78415. * @param height set the height of the ground
  78416. * @param subdivisions sets the number of subdivisions per side
  78417. * @param scene defines the hosting scene
  78418. * @param updatable defines if the mesh must be flagged as updatable
  78419. * @returns a new Mesh
  78420. */
  78421. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78422. /**
  78423. * Creates a tiled ground mesh.
  78424. * Please consider using the same method from the MeshBuilder class instead
  78425. * @param name defines the name of the mesh to create
  78426. * @param xmin set the ground minimum X coordinate
  78427. * @param zmin set the ground minimum Y coordinate
  78428. * @param xmax set the ground maximum X coordinate
  78429. * @param zmax set the ground maximum Z coordinate
  78430. * @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
  78431. * @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
  78432. * @param scene defines the hosting scene
  78433. * @param updatable defines if the mesh must be flagged as updatable
  78434. * @returns a new Mesh
  78435. */
  78436. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78437. w: number;
  78438. h: number;
  78439. }, precision: {
  78440. w: number;
  78441. h: number;
  78442. }, scene: Scene, updatable?: boolean): Mesh;
  78443. /**
  78444. * Creates a ground mesh from a height map.
  78445. * Please consider using the same method from the MeshBuilder class instead
  78446. * @see http://doc.babylonjs.com/babylon101/height_map
  78447. * @param name defines the name of the mesh to create
  78448. * @param url sets the URL of the height map image resource
  78449. * @param width set the ground width size
  78450. * @param height set the ground height size
  78451. * @param subdivisions sets the number of subdivision per side
  78452. * @param minHeight is the minimum altitude on the ground
  78453. * @param maxHeight is the maximum altitude on the ground
  78454. * @param scene defines the hosting scene
  78455. * @param updatable defines if the mesh must be flagged as updatable
  78456. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78457. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78458. * @returns a new Mesh
  78459. */
  78460. 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;
  78461. /**
  78462. * Creates a tube mesh.
  78463. * The tube is a parametric shape.
  78464. * It has no predefined shape. Its final shape will depend on the input parameters.
  78465. * Please consider using the same method from the MeshBuilder class instead
  78466. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78467. * @param name defines the name of the mesh to create
  78468. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78469. * @param radius sets the tube radius size
  78470. * @param tessellation is the number of sides on the tubular surface
  78471. * @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
  78472. * @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
  78473. * @param scene defines the hosting scene
  78474. * @param updatable defines if the mesh must be flagged as updatable
  78475. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78476. * @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)
  78477. * @returns a new Mesh
  78478. */
  78479. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78480. (i: number, distance: number): number;
  78481. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78482. /**
  78483. * Creates a polyhedron mesh.
  78484. * Please consider using the same method from the MeshBuilder class instead.
  78485. * * 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
  78486. * * The parameter `size` (positive float, default 1) sets the polygon size
  78487. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78488. * * 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`
  78489. * * 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
  78490. * * 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)`)
  78491. * * 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
  78492. * * 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
  78493. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78494. * * If you create a double-sided mesh, you can choose what parts of 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
  78495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78496. * @param name defines the name of the mesh to create
  78497. * @param options defines the options used to create the mesh
  78498. * @param scene defines the hosting scene
  78499. * @returns a new Mesh
  78500. */
  78501. static CreatePolyhedron(name: string, options: {
  78502. type?: number;
  78503. size?: number;
  78504. sizeX?: number;
  78505. sizeY?: number;
  78506. sizeZ?: number;
  78507. custom?: any;
  78508. faceUV?: Vector4[];
  78509. faceColors?: Color4[];
  78510. updatable?: boolean;
  78511. sideOrientation?: number;
  78512. }, scene: Scene): Mesh;
  78513. /**
  78514. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78515. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78516. * * 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`)
  78517. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78518. * * 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
  78519. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78520. * * If you create a double-sided mesh, you can choose what parts of 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
  78521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78522. * @param name defines the name of the mesh
  78523. * @param options defines the options used to create the mesh
  78524. * @param scene defines the hosting scene
  78525. * @returns a new Mesh
  78526. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78527. */
  78528. static CreateIcoSphere(name: string, options: {
  78529. radius?: number;
  78530. flat?: boolean;
  78531. subdivisions?: number;
  78532. sideOrientation?: number;
  78533. updatable?: boolean;
  78534. }, scene: Scene): Mesh;
  78535. /**
  78536. * Creates a decal mesh.
  78537. * Please consider using the same method from the MeshBuilder class instead.
  78538. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78539. * @param name defines the name of the mesh
  78540. * @param sourceMesh defines the mesh receiving the decal
  78541. * @param position sets the position of the decal in world coordinates
  78542. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78543. * @param size sets the decal scaling
  78544. * @param angle sets the angle to rotate the decal
  78545. * @returns a new Mesh
  78546. */
  78547. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78548. /**
  78549. * Prepare internal position array for software CPU skinning
  78550. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78551. */
  78552. setPositionsForCPUSkinning(): Float32Array;
  78553. /**
  78554. * Prepare internal normal array for software CPU skinning
  78555. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78556. */
  78557. setNormalsForCPUSkinning(): Float32Array;
  78558. /**
  78559. * Updates the vertex buffer by applying transformation from the bones
  78560. * @param skeleton defines the skeleton to apply to current mesh
  78561. * @returns the current mesh
  78562. */
  78563. applySkeleton(skeleton: Skeleton): Mesh;
  78564. /**
  78565. * 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
  78566. * @param meshes defines the list of meshes to scan
  78567. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78568. */
  78569. static MinMax(meshes: AbstractMesh[]): {
  78570. min: Vector3;
  78571. max: Vector3;
  78572. };
  78573. /**
  78574. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78575. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78576. * @returns a vector3
  78577. */
  78578. static Center(meshesOrMinMaxVector: {
  78579. min: Vector3;
  78580. max: Vector3;
  78581. } | AbstractMesh[]): Vector3;
  78582. /**
  78583. * Merge the array of meshes into a single mesh for performance reasons.
  78584. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78585. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78586. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78587. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78588. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78589. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78590. * @returns a new mesh
  78591. */
  78592. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78593. /** @hidden */
  78594. addInstance(instance: InstancedMesh): void;
  78595. /** @hidden */
  78596. removeInstance(instance: InstancedMesh): void;
  78597. }
  78598. }
  78599. declare module BABYLON {
  78600. /**
  78601. * Base class for the main features of a material in Babylon.js
  78602. */
  78603. export class Material implements IAnimatable {
  78604. /**
  78605. * Returns the triangle fill mode
  78606. */
  78607. static readonly TriangleFillMode: number;
  78608. /**
  78609. * Returns the wireframe mode
  78610. */
  78611. static readonly WireFrameFillMode: number;
  78612. /**
  78613. * Returns the point fill mode
  78614. */
  78615. static readonly PointFillMode: number;
  78616. /**
  78617. * Returns the point list draw mode
  78618. */
  78619. static readonly PointListDrawMode: number;
  78620. /**
  78621. * Returns the line list draw mode
  78622. */
  78623. static readonly LineListDrawMode: number;
  78624. /**
  78625. * Returns the line loop draw mode
  78626. */
  78627. static readonly LineLoopDrawMode: number;
  78628. /**
  78629. * Returns the line strip draw mode
  78630. */
  78631. static readonly LineStripDrawMode: number;
  78632. /**
  78633. * Returns the triangle strip draw mode
  78634. */
  78635. static readonly TriangleStripDrawMode: number;
  78636. /**
  78637. * Returns the triangle fan draw mode
  78638. */
  78639. static readonly TriangleFanDrawMode: number;
  78640. /**
  78641. * Stores the clock-wise side orientation
  78642. */
  78643. static readonly ClockWiseSideOrientation: number;
  78644. /**
  78645. * Stores the counter clock-wise side orientation
  78646. */
  78647. static readonly CounterClockWiseSideOrientation: number;
  78648. /**
  78649. * The dirty texture flag value
  78650. */
  78651. static readonly TextureDirtyFlag: number;
  78652. /**
  78653. * The dirty light flag value
  78654. */
  78655. static readonly LightDirtyFlag: number;
  78656. /**
  78657. * The dirty fresnel flag value
  78658. */
  78659. static readonly FresnelDirtyFlag: number;
  78660. /**
  78661. * The dirty attribute flag value
  78662. */
  78663. static readonly AttributesDirtyFlag: number;
  78664. /**
  78665. * The dirty misc flag value
  78666. */
  78667. static readonly MiscDirtyFlag: number;
  78668. /**
  78669. * The all dirty flag value
  78670. */
  78671. static readonly AllDirtyFlag: number;
  78672. /**
  78673. * The ID of the material
  78674. */
  78675. id: string;
  78676. /**
  78677. * Gets or sets the unique id of the material
  78678. */
  78679. uniqueId: number;
  78680. /**
  78681. * The name of the material
  78682. */
  78683. name: string;
  78684. /**
  78685. * Gets or sets user defined metadata
  78686. */
  78687. metadata: any;
  78688. /**
  78689. * For internal use only. Please do not use.
  78690. */
  78691. reservedDataStore: any;
  78692. /**
  78693. * Specifies if the ready state should be checked on each call
  78694. */
  78695. checkReadyOnEveryCall: boolean;
  78696. /**
  78697. * Specifies if the ready state should be checked once
  78698. */
  78699. checkReadyOnlyOnce: boolean;
  78700. /**
  78701. * The state of the material
  78702. */
  78703. state: string;
  78704. /**
  78705. * The alpha value of the material
  78706. */
  78707. protected _alpha: number;
  78708. /**
  78709. * Sets the alpha value of the material
  78710. */
  78711. /**
  78712. * Gets the alpha value of the material
  78713. */
  78714. alpha: number;
  78715. /**
  78716. * Specifies if back face culling is enabled
  78717. */
  78718. protected _backFaceCulling: boolean;
  78719. /**
  78720. * Sets the back-face culling state
  78721. */
  78722. /**
  78723. * Gets the back-face culling state
  78724. */
  78725. backFaceCulling: boolean;
  78726. /**
  78727. * Stores the value for side orientation
  78728. */
  78729. sideOrientation: number;
  78730. /**
  78731. * Callback triggered when the material is compiled
  78732. */
  78733. onCompiled: (effect: Effect) => void;
  78734. /**
  78735. * Callback triggered when an error occurs
  78736. */
  78737. onError: (effect: Effect, errors: string) => void;
  78738. /**
  78739. * Callback triggered to get the render target textures
  78740. */
  78741. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78742. /**
  78743. * Gets a boolean indicating that current material needs to register RTT
  78744. */
  78745. readonly hasRenderTargetTextures: boolean;
  78746. /**
  78747. * Specifies if the material should be serialized
  78748. */
  78749. doNotSerialize: boolean;
  78750. /**
  78751. * @hidden
  78752. */
  78753. _storeEffectOnSubMeshes: boolean;
  78754. /**
  78755. * Stores the animations for the material
  78756. */
  78757. animations: Array<Animation>;
  78758. /**
  78759. * An event triggered when the material is disposed
  78760. */
  78761. onDisposeObservable: Observable<Material>;
  78762. /**
  78763. * An observer which watches for dispose events
  78764. */
  78765. private _onDisposeObserver;
  78766. private _onUnBindObservable;
  78767. /**
  78768. * Called during a dispose event
  78769. */
  78770. onDispose: () => void;
  78771. private _onBindObservable;
  78772. /**
  78773. * An event triggered when the material is bound
  78774. */
  78775. readonly onBindObservable: Observable<AbstractMesh>;
  78776. /**
  78777. * An observer which watches for bind events
  78778. */
  78779. private _onBindObserver;
  78780. /**
  78781. * Called during a bind event
  78782. */
  78783. onBind: (Mesh: AbstractMesh) => void;
  78784. /**
  78785. * An event triggered when the material is unbound
  78786. */
  78787. readonly onUnBindObservable: Observable<Material>;
  78788. /**
  78789. * Stores the value of the alpha mode
  78790. */
  78791. private _alphaMode;
  78792. /**
  78793. * Sets the value of the alpha mode.
  78794. *
  78795. * | Value | Type | Description |
  78796. * | --- | --- | --- |
  78797. * | 0 | ALPHA_DISABLE | |
  78798. * | 1 | ALPHA_ADD | |
  78799. * | 2 | ALPHA_COMBINE | |
  78800. * | 3 | ALPHA_SUBTRACT | |
  78801. * | 4 | ALPHA_MULTIPLY | |
  78802. * | 5 | ALPHA_MAXIMIZED | |
  78803. * | 6 | ALPHA_ONEONE | |
  78804. * | 7 | ALPHA_PREMULTIPLIED | |
  78805. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78806. * | 9 | ALPHA_INTERPOLATE | |
  78807. * | 10 | ALPHA_SCREENMODE | |
  78808. *
  78809. */
  78810. /**
  78811. * Gets the value of the alpha mode
  78812. */
  78813. alphaMode: number;
  78814. /**
  78815. * Stores the state of the need depth pre-pass value
  78816. */
  78817. private _needDepthPrePass;
  78818. /**
  78819. * Sets the need depth pre-pass value
  78820. */
  78821. /**
  78822. * Gets the depth pre-pass value
  78823. */
  78824. needDepthPrePass: boolean;
  78825. /**
  78826. * Specifies if depth writing should be disabled
  78827. */
  78828. disableDepthWrite: boolean;
  78829. /**
  78830. * Specifies if depth writing should be forced
  78831. */
  78832. forceDepthWrite: boolean;
  78833. /**
  78834. * Specifies if there should be a separate pass for culling
  78835. */
  78836. separateCullingPass: boolean;
  78837. /**
  78838. * Stores the state specifing if fog should be enabled
  78839. */
  78840. private _fogEnabled;
  78841. /**
  78842. * Sets the state for enabling fog
  78843. */
  78844. /**
  78845. * Gets the value of the fog enabled state
  78846. */
  78847. fogEnabled: boolean;
  78848. /**
  78849. * Stores the size of points
  78850. */
  78851. pointSize: number;
  78852. /**
  78853. * Stores the z offset value
  78854. */
  78855. zOffset: number;
  78856. /**
  78857. * Gets a value specifying if wireframe mode is enabled
  78858. */
  78859. /**
  78860. * Sets the state of wireframe mode
  78861. */
  78862. wireframe: boolean;
  78863. /**
  78864. * Gets the value specifying if point clouds are enabled
  78865. */
  78866. /**
  78867. * Sets the state of point cloud mode
  78868. */
  78869. pointsCloud: boolean;
  78870. /**
  78871. * Gets the material fill mode
  78872. */
  78873. /**
  78874. * Sets the material fill mode
  78875. */
  78876. fillMode: number;
  78877. /**
  78878. * @hidden
  78879. * Stores the effects for the material
  78880. */
  78881. _effect: Nullable<Effect>;
  78882. /**
  78883. * @hidden
  78884. * Specifies if the material was previously ready
  78885. */
  78886. _wasPreviouslyReady: boolean;
  78887. /**
  78888. * Specifies if uniform buffers should be used
  78889. */
  78890. private _useUBO;
  78891. /**
  78892. * Stores a reference to the scene
  78893. */
  78894. private _scene;
  78895. /**
  78896. * Stores the fill mode state
  78897. */
  78898. private _fillMode;
  78899. /**
  78900. * Specifies if the depth write state should be cached
  78901. */
  78902. private _cachedDepthWriteState;
  78903. /**
  78904. * Stores the uniform buffer
  78905. */
  78906. protected _uniformBuffer: UniformBuffer;
  78907. /** @hidden */
  78908. _indexInSceneMaterialArray: number;
  78909. /** @hidden */
  78910. meshMap: Nullable<{
  78911. [id: string]: AbstractMesh | undefined;
  78912. }>;
  78913. /**
  78914. * Creates a material instance
  78915. * @param name defines the name of the material
  78916. * @param scene defines the scene to reference
  78917. * @param doNotAdd specifies if the material should be added to the scene
  78918. */
  78919. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78920. /**
  78921. * Returns a string representation of the current material
  78922. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78923. * @returns a string with material information
  78924. */
  78925. toString(fullDetails?: boolean): string;
  78926. /**
  78927. * Gets the class name of the material
  78928. * @returns a string with the class name of the material
  78929. */
  78930. getClassName(): string;
  78931. /**
  78932. * Specifies if updates for the material been locked
  78933. */
  78934. readonly isFrozen: boolean;
  78935. /**
  78936. * Locks updates for the material
  78937. */
  78938. freeze(): void;
  78939. /**
  78940. * Unlocks updates for the material
  78941. */
  78942. unfreeze(): void;
  78943. /**
  78944. * Specifies if the material is ready to be used
  78945. * @param mesh defines the mesh to check
  78946. * @param useInstances specifies if instances should be used
  78947. * @returns a boolean indicating if the material is ready to be used
  78948. */
  78949. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78950. /**
  78951. * Specifies that the submesh is ready to be used
  78952. * @param mesh defines the mesh to check
  78953. * @param subMesh defines which submesh to check
  78954. * @param useInstances specifies that instances should be used
  78955. * @returns a boolean indicating that the submesh is ready or not
  78956. */
  78957. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78958. /**
  78959. * Returns the material effect
  78960. * @returns the effect associated with the material
  78961. */
  78962. getEffect(): Nullable<Effect>;
  78963. /**
  78964. * Returns the current scene
  78965. * @returns a Scene
  78966. */
  78967. getScene(): Scene;
  78968. /**
  78969. * Specifies if the material will require alpha blending
  78970. * @returns a boolean specifying if alpha blending is needed
  78971. */
  78972. needAlphaBlending(): boolean;
  78973. /**
  78974. * Specifies if the mesh will require alpha blending
  78975. * @param mesh defines the mesh to check
  78976. * @returns a boolean specifying if alpha blending is needed for the mesh
  78977. */
  78978. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78979. /**
  78980. * Specifies if this material should be rendered in alpha test mode
  78981. * @returns a boolean specifying if an alpha test is needed.
  78982. */
  78983. needAlphaTesting(): boolean;
  78984. /**
  78985. * Gets the texture used for the alpha test
  78986. * @returns the texture to use for alpha testing
  78987. */
  78988. getAlphaTestTexture(): Nullable<BaseTexture>;
  78989. /**
  78990. * Marks the material to indicate that it needs to be re-calculated
  78991. */
  78992. markDirty(): void;
  78993. /** @hidden */
  78994. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78995. /**
  78996. * Binds the material to the mesh
  78997. * @param world defines the world transformation matrix
  78998. * @param mesh defines the mesh to bind the material to
  78999. */
  79000. bind(world: Matrix, mesh?: Mesh): void;
  79001. /**
  79002. * Binds the submesh to the material
  79003. * @param world defines the world transformation matrix
  79004. * @param mesh defines the mesh containing the submesh
  79005. * @param subMesh defines the submesh to bind the material to
  79006. */
  79007. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  79008. /**
  79009. * Binds the world matrix to the material
  79010. * @param world defines the world transformation matrix
  79011. */
  79012. bindOnlyWorldMatrix(world: Matrix): void;
  79013. /**
  79014. * Binds the scene's uniform buffer to the effect.
  79015. * @param effect defines the effect to bind to the scene uniform buffer
  79016. * @param sceneUbo defines the uniform buffer storing scene data
  79017. */
  79018. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  79019. /**
  79020. * Binds the view matrix to the effect
  79021. * @param effect defines the effect to bind the view matrix to
  79022. */
  79023. bindView(effect: Effect): void;
  79024. /**
  79025. * Binds the view projection matrix to the effect
  79026. * @param effect defines the effect to bind the view projection matrix to
  79027. */
  79028. bindViewProjection(effect: Effect): void;
  79029. /**
  79030. * Specifies if material alpha testing should be turned on for the mesh
  79031. * @param mesh defines the mesh to check
  79032. */
  79033. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  79034. /**
  79035. * Processes to execute after binding the material to a mesh
  79036. * @param mesh defines the rendered mesh
  79037. */
  79038. protected _afterBind(mesh?: Mesh): void;
  79039. /**
  79040. * Unbinds the material from the mesh
  79041. */
  79042. unbind(): void;
  79043. /**
  79044. * Gets the active textures from the material
  79045. * @returns an array of textures
  79046. */
  79047. getActiveTextures(): BaseTexture[];
  79048. /**
  79049. * Specifies if the material uses a texture
  79050. * @param texture defines the texture to check against the material
  79051. * @returns a boolean specifying if the material uses the texture
  79052. */
  79053. hasTexture(texture: BaseTexture): boolean;
  79054. /**
  79055. * Makes a duplicate of the material, and gives it a new name
  79056. * @param name defines the new name for the duplicated material
  79057. * @returns the cloned material
  79058. */
  79059. clone(name: string): Nullable<Material>;
  79060. /**
  79061. * Gets the meshes bound to the material
  79062. * @returns an array of meshes bound to the material
  79063. */
  79064. getBindedMeshes(): AbstractMesh[];
  79065. /**
  79066. * Force shader compilation
  79067. * @param mesh defines the mesh associated with this material
  79068. * @param onCompiled defines a function to execute once the material is compiled
  79069. * @param options defines the options to configure the compilation
  79070. */
  79071. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  79072. clipPlane: boolean;
  79073. }>): void;
  79074. /**
  79075. * Force shader compilation
  79076. * @param mesh defines the mesh that will use this material
  79077. * @param options defines additional options for compiling the shaders
  79078. * @returns a promise that resolves when the compilation completes
  79079. */
  79080. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  79081. clipPlane: boolean;
  79082. }>): Promise<void>;
  79083. private static readonly _ImageProcessingDirtyCallBack;
  79084. private static readonly _TextureDirtyCallBack;
  79085. private static readonly _FresnelDirtyCallBack;
  79086. private static readonly _MiscDirtyCallBack;
  79087. private static readonly _LightsDirtyCallBack;
  79088. private static readonly _AttributeDirtyCallBack;
  79089. private static _FresnelAndMiscDirtyCallBack;
  79090. private static _TextureAndMiscDirtyCallBack;
  79091. private static readonly _DirtyCallbackArray;
  79092. private static readonly _RunDirtyCallBacks;
  79093. /**
  79094. * Marks a define in the material to indicate that it needs to be re-computed
  79095. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  79096. */
  79097. markAsDirty(flag: number): void;
  79098. /**
  79099. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  79100. * @param func defines a function which checks material defines against the submeshes
  79101. */
  79102. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  79103. /**
  79104. * Indicates that image processing needs to be re-calculated for all submeshes
  79105. */
  79106. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  79107. /**
  79108. * Indicates that textures need to be re-calculated for all submeshes
  79109. */
  79110. protected _markAllSubMeshesAsTexturesDirty(): void;
  79111. /**
  79112. * Indicates that fresnel needs to be re-calculated for all submeshes
  79113. */
  79114. protected _markAllSubMeshesAsFresnelDirty(): void;
  79115. /**
  79116. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  79117. */
  79118. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  79119. /**
  79120. * Indicates that lights need to be re-calculated for all submeshes
  79121. */
  79122. protected _markAllSubMeshesAsLightsDirty(): void;
  79123. /**
  79124. * Indicates that attributes need to be re-calculated for all submeshes
  79125. */
  79126. protected _markAllSubMeshesAsAttributesDirty(): void;
  79127. /**
  79128. * Indicates that misc needs to be re-calculated for all submeshes
  79129. */
  79130. protected _markAllSubMeshesAsMiscDirty(): void;
  79131. /**
  79132. * Indicates that textures and misc need to be re-calculated for all submeshes
  79133. */
  79134. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  79135. /**
  79136. * Disposes the material
  79137. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79138. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79139. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79140. */
  79141. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79142. /** @hidden */
  79143. private releaseVertexArrayObject;
  79144. /**
  79145. * Serializes this material
  79146. * @returns the serialized material object
  79147. */
  79148. serialize(): any;
  79149. /**
  79150. * Creates a material from parsed material data
  79151. * @param parsedMaterial defines parsed material data
  79152. * @param scene defines the hosting scene
  79153. * @param rootUrl defines the root URL to use to load textures
  79154. * @returns a new material
  79155. */
  79156. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  79157. }
  79158. }
  79159. declare module BABYLON {
  79160. /**
  79161. * Base class for submeshes
  79162. */
  79163. export class BaseSubMesh {
  79164. /** @hidden */
  79165. _materialDefines: Nullable<MaterialDefines>;
  79166. /** @hidden */
  79167. _materialEffect: Nullable<Effect>;
  79168. /**
  79169. * Gets associated effect
  79170. */
  79171. readonly effect: Nullable<Effect>;
  79172. /**
  79173. * Sets associated effect (effect used to render this submesh)
  79174. * @param effect defines the effect to associate with
  79175. * @param defines defines the set of defines used to compile this effect
  79176. */
  79177. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  79178. }
  79179. /**
  79180. * Defines a subdivision inside a mesh
  79181. */
  79182. export class SubMesh extends BaseSubMesh implements ICullable {
  79183. /** the material index to use */
  79184. materialIndex: number;
  79185. /** vertex index start */
  79186. verticesStart: number;
  79187. /** vertices count */
  79188. verticesCount: number;
  79189. /** index start */
  79190. indexStart: number;
  79191. /** indices count */
  79192. indexCount: number;
  79193. /** @hidden */
  79194. _linesIndexCount: number;
  79195. private _mesh;
  79196. private _renderingMesh;
  79197. private _boundingInfo;
  79198. private _linesIndexBuffer;
  79199. /** @hidden */
  79200. _lastColliderWorldVertices: Nullable<Vector3[]>;
  79201. /** @hidden */
  79202. _trianglePlanes: Plane[];
  79203. /** @hidden */
  79204. _lastColliderTransformMatrix: Matrix;
  79205. /** @hidden */
  79206. _renderId: number;
  79207. /** @hidden */
  79208. _alphaIndex: number;
  79209. /** @hidden */
  79210. _distanceToCamera: number;
  79211. /** @hidden */
  79212. _id: number;
  79213. private _currentMaterial;
  79214. /**
  79215. * Add a new submesh to a mesh
  79216. * @param materialIndex defines the material index to use
  79217. * @param verticesStart defines vertex index start
  79218. * @param verticesCount defines vertices count
  79219. * @param indexStart defines index start
  79220. * @param indexCount defines indices count
  79221. * @param mesh defines the parent mesh
  79222. * @param renderingMesh defines an optional rendering mesh
  79223. * @param createBoundingBox defines if bounding box should be created for this submesh
  79224. * @returns the new submesh
  79225. */
  79226. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79227. /**
  79228. * Creates a new submesh
  79229. * @param materialIndex defines the material index to use
  79230. * @param verticesStart defines vertex index start
  79231. * @param verticesCount defines vertices count
  79232. * @param indexStart defines index start
  79233. * @param indexCount defines indices count
  79234. * @param mesh defines the parent mesh
  79235. * @param renderingMesh defines an optional rendering mesh
  79236. * @param createBoundingBox defines if bounding box should be created for this submesh
  79237. */
  79238. constructor(
  79239. /** the material index to use */
  79240. materialIndex: number,
  79241. /** vertex index start */
  79242. verticesStart: number,
  79243. /** vertices count */
  79244. verticesCount: number,
  79245. /** index start */
  79246. indexStart: number,
  79247. /** indices count */
  79248. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79249. /**
  79250. * Returns true if this submesh covers the entire parent mesh
  79251. * @ignorenaming
  79252. */
  79253. readonly IsGlobal: boolean;
  79254. /**
  79255. * Returns the submesh BoudingInfo object
  79256. * @returns current bounding info (or mesh's one if the submesh is global)
  79257. */
  79258. getBoundingInfo(): BoundingInfo;
  79259. /**
  79260. * Sets the submesh BoundingInfo
  79261. * @param boundingInfo defines the new bounding info to use
  79262. * @returns the SubMesh
  79263. */
  79264. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79265. /**
  79266. * Returns the mesh of the current submesh
  79267. * @return the parent mesh
  79268. */
  79269. getMesh(): AbstractMesh;
  79270. /**
  79271. * Returns the rendering mesh of the submesh
  79272. * @returns the rendering mesh (could be different from parent mesh)
  79273. */
  79274. getRenderingMesh(): Mesh;
  79275. /**
  79276. * Returns the submesh material
  79277. * @returns null or the current material
  79278. */
  79279. getMaterial(): Nullable<Material>;
  79280. /**
  79281. * Sets a new updated BoundingInfo object to the submesh
  79282. * @returns the SubMesh
  79283. */
  79284. refreshBoundingInfo(): SubMesh;
  79285. /** @hidden */
  79286. _checkCollision(collider: Collider): boolean;
  79287. /**
  79288. * Updates the submesh BoundingInfo
  79289. * @param world defines the world matrix to use to update the bounding info
  79290. * @returns the submesh
  79291. */
  79292. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79293. /**
  79294. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79295. * @param frustumPlanes defines the frustum planes
  79296. * @returns true if the submesh is intersecting with the frustum
  79297. */
  79298. isInFrustum(frustumPlanes: Plane[]): boolean;
  79299. /**
  79300. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79301. * @param frustumPlanes defines the frustum planes
  79302. * @returns true if the submesh is inside the frustum
  79303. */
  79304. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79305. /**
  79306. * Renders the submesh
  79307. * @param enableAlphaMode defines if alpha needs to be used
  79308. * @returns the submesh
  79309. */
  79310. render(enableAlphaMode: boolean): SubMesh;
  79311. /**
  79312. * @hidden
  79313. */
  79314. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79315. /**
  79316. * Checks if the submesh intersects with a ray
  79317. * @param ray defines the ray to test
  79318. * @returns true is the passed ray intersects the submesh bounding box
  79319. */
  79320. canIntersects(ray: Ray): boolean;
  79321. /**
  79322. * Intersects current submesh with a ray
  79323. * @param ray defines the ray to test
  79324. * @param positions defines mesh's positions array
  79325. * @param indices defines mesh's indices array
  79326. * @param fastCheck defines if only bounding info should be used
  79327. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79328. * @returns intersection info or null if no intersection
  79329. */
  79330. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79331. /** @hidden */
  79332. private _intersectLines;
  79333. /** @hidden */
  79334. private _intersectTriangles;
  79335. /** @hidden */
  79336. _rebuild(): void;
  79337. /**
  79338. * Creates a new submesh from the passed mesh
  79339. * @param newMesh defines the new hosting mesh
  79340. * @param newRenderingMesh defines an optional rendering mesh
  79341. * @returns the new submesh
  79342. */
  79343. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79344. /**
  79345. * Release associated resources
  79346. */
  79347. dispose(): void;
  79348. /**
  79349. * Gets the class name
  79350. * @returns the string "SubMesh".
  79351. */
  79352. getClassName(): string;
  79353. /**
  79354. * Creates a new submesh from indices data
  79355. * @param materialIndex the index of the main mesh material
  79356. * @param startIndex the index where to start the copy in the mesh indices array
  79357. * @param indexCount the number of indices to copy then from the startIndex
  79358. * @param mesh the main mesh to create the submesh from
  79359. * @param renderingMesh the optional rendering mesh
  79360. * @returns a new submesh
  79361. */
  79362. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79363. }
  79364. }
  79365. declare module BABYLON {
  79366. /**
  79367. * Class used to store geometry data (vertex buffers + index buffer)
  79368. */
  79369. export class Geometry implements IGetSetVerticesData {
  79370. /**
  79371. * Gets or sets the ID of the geometry
  79372. */
  79373. id: string;
  79374. /**
  79375. * Gets or sets the unique ID of the geometry
  79376. */
  79377. uniqueId: number;
  79378. /**
  79379. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79380. */
  79381. delayLoadState: number;
  79382. /**
  79383. * Gets the file containing the data to load when running in delay load state
  79384. */
  79385. delayLoadingFile: Nullable<string>;
  79386. /**
  79387. * Callback called when the geometry is updated
  79388. */
  79389. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79390. private _scene;
  79391. private _engine;
  79392. private _meshes;
  79393. private _totalVertices;
  79394. /** @hidden */
  79395. _indices: IndicesArray;
  79396. /** @hidden */
  79397. _vertexBuffers: {
  79398. [key: string]: VertexBuffer;
  79399. };
  79400. private _isDisposed;
  79401. private _extend;
  79402. private _boundingBias;
  79403. /** @hidden */
  79404. _delayInfo: Array<string>;
  79405. private _indexBuffer;
  79406. private _indexBufferIsUpdatable;
  79407. /** @hidden */
  79408. _boundingInfo: Nullable<BoundingInfo>;
  79409. /** @hidden */
  79410. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79411. /** @hidden */
  79412. _softwareSkinningFrameId: number;
  79413. private _vertexArrayObjects;
  79414. private _updatable;
  79415. /** @hidden */
  79416. _positions: Nullable<Vector3[]>;
  79417. /**
  79418. * 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
  79419. */
  79420. /**
  79421. * 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
  79422. */
  79423. boundingBias: Vector2;
  79424. /**
  79425. * Static function used to attach a new empty geometry to a mesh
  79426. * @param mesh defines the mesh to attach the geometry to
  79427. * @returns the new Geometry
  79428. */
  79429. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79430. /**
  79431. * Creates a new geometry
  79432. * @param id defines the unique ID
  79433. * @param scene defines the hosting scene
  79434. * @param vertexData defines the VertexData used to get geometry data
  79435. * @param updatable defines if geometry must be updatable (false by default)
  79436. * @param mesh defines the mesh that will be associated with the geometry
  79437. */
  79438. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79439. /**
  79440. * Gets the current extend of the geometry
  79441. */
  79442. readonly extend: {
  79443. minimum: Vector3;
  79444. maximum: Vector3;
  79445. };
  79446. /**
  79447. * Gets the hosting scene
  79448. * @returns the hosting Scene
  79449. */
  79450. getScene(): Scene;
  79451. /**
  79452. * Gets the hosting engine
  79453. * @returns the hosting Engine
  79454. */
  79455. getEngine(): Engine;
  79456. /**
  79457. * Defines if the geometry is ready to use
  79458. * @returns true if the geometry is ready to be used
  79459. */
  79460. isReady(): boolean;
  79461. /**
  79462. * Gets a value indicating that the geometry should not be serialized
  79463. */
  79464. readonly doNotSerialize: boolean;
  79465. /** @hidden */
  79466. _rebuild(): void;
  79467. /**
  79468. * Affects all geometry data in one call
  79469. * @param vertexData defines the geometry data
  79470. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79471. */
  79472. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79473. /**
  79474. * Set specific vertex data
  79475. * @param kind defines the data kind (Position, normal, etc...)
  79476. * @param data defines the vertex data to use
  79477. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79478. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79479. */
  79480. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79481. /**
  79482. * Removes a specific vertex data
  79483. * @param kind defines the data kind (Position, normal, etc...)
  79484. */
  79485. removeVerticesData(kind: string): void;
  79486. /**
  79487. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79488. * @param buffer defines the vertex buffer to use
  79489. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79490. */
  79491. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79492. /**
  79493. * Update a specific vertex buffer
  79494. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79495. * It will do nothing if the buffer is not updatable
  79496. * @param kind defines the data kind (Position, normal, etc...)
  79497. * @param data defines the data to use
  79498. * @param offset defines the offset in the target buffer where to store the data
  79499. * @param useBytes set to true if the offset is in bytes
  79500. */
  79501. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79502. /**
  79503. * Update a specific vertex buffer
  79504. * This function will create a new buffer if the current one is not updatable
  79505. * @param kind defines the data kind (Position, normal, etc...)
  79506. * @param data defines the data to use
  79507. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79508. */
  79509. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79510. private _updateBoundingInfo;
  79511. /** @hidden */
  79512. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79513. /**
  79514. * Gets total number of vertices
  79515. * @returns the total number of vertices
  79516. */
  79517. getTotalVertices(): number;
  79518. /**
  79519. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79520. * @param kind defines the data kind (Position, normal, etc...)
  79521. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79522. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79523. * @returns a float array containing vertex data
  79524. */
  79525. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79526. /**
  79527. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79528. * @param kind defines the data kind (Position, normal, etc...)
  79529. * @returns true if the vertex buffer with the specified kind is updatable
  79530. */
  79531. isVertexBufferUpdatable(kind: string): boolean;
  79532. /**
  79533. * Gets a specific vertex buffer
  79534. * @param kind defines the data kind (Position, normal, etc...)
  79535. * @returns a VertexBuffer
  79536. */
  79537. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79538. /**
  79539. * Returns all vertex buffers
  79540. * @return an object holding all vertex buffers indexed by kind
  79541. */
  79542. getVertexBuffers(): Nullable<{
  79543. [key: string]: VertexBuffer;
  79544. }>;
  79545. /**
  79546. * Gets a boolean indicating if specific vertex buffer is present
  79547. * @param kind defines the data kind (Position, normal, etc...)
  79548. * @returns true if data is present
  79549. */
  79550. isVerticesDataPresent(kind: string): boolean;
  79551. /**
  79552. * Gets a list of all attached data kinds (Position, normal, etc...)
  79553. * @returns a list of string containing all kinds
  79554. */
  79555. getVerticesDataKinds(): string[];
  79556. /**
  79557. * Update index buffer
  79558. * @param indices defines the indices to store in the index buffer
  79559. * @param offset defines the offset in the target buffer where to store the data
  79560. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  79561. */
  79562. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  79563. /**
  79564. * Creates a new index buffer
  79565. * @param indices defines the indices to store in the index buffer
  79566. * @param totalVertices defines the total number of vertices (could be null)
  79567. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79568. */
  79569. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79570. /**
  79571. * Return the total number of indices
  79572. * @returns the total number of indices
  79573. */
  79574. getTotalIndices(): number;
  79575. /**
  79576. * Gets the index buffer array
  79577. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79578. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79579. * @returns the index buffer array
  79580. */
  79581. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79582. /**
  79583. * Gets the index buffer
  79584. * @return the index buffer
  79585. */
  79586. getIndexBuffer(): Nullable<WebGLBuffer>;
  79587. /** @hidden */
  79588. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79589. /**
  79590. * Release the associated resources for a specific mesh
  79591. * @param mesh defines the source mesh
  79592. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79593. */
  79594. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79595. /**
  79596. * Apply current geometry to a given mesh
  79597. * @param mesh defines the mesh to apply geometry to
  79598. */
  79599. applyToMesh(mesh: Mesh): void;
  79600. private _updateExtend;
  79601. private _applyToMesh;
  79602. private notifyUpdate;
  79603. /**
  79604. * Load the geometry if it was flagged as delay loaded
  79605. * @param scene defines the hosting scene
  79606. * @param onLoaded defines a callback called when the geometry is loaded
  79607. */
  79608. load(scene: Scene, onLoaded?: () => void): void;
  79609. private _queueLoad;
  79610. /**
  79611. * Invert the geometry to move from a right handed system to a left handed one.
  79612. */
  79613. toLeftHanded(): void;
  79614. /** @hidden */
  79615. _resetPointsArrayCache(): void;
  79616. /** @hidden */
  79617. _generatePointsArray(): boolean;
  79618. /**
  79619. * Gets a value indicating if the geometry is disposed
  79620. * @returns true if the geometry was disposed
  79621. */
  79622. isDisposed(): boolean;
  79623. private _disposeVertexArrayObjects;
  79624. /**
  79625. * Free all associated resources
  79626. */
  79627. dispose(): void;
  79628. /**
  79629. * Clone the current geometry into a new geometry
  79630. * @param id defines the unique ID of the new geometry
  79631. * @returns a new geometry object
  79632. */
  79633. copy(id: string): Geometry;
  79634. /**
  79635. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79636. * @return a JSON representation of the current geometry data (without the vertices data)
  79637. */
  79638. serialize(): any;
  79639. private toNumberArray;
  79640. /**
  79641. * Serialize all vertices data into a JSON oject
  79642. * @returns a JSON representation of the current geometry data
  79643. */
  79644. serializeVerticeData(): any;
  79645. /**
  79646. * Extracts a clone of a mesh geometry
  79647. * @param mesh defines the source mesh
  79648. * @param id defines the unique ID of the new geometry object
  79649. * @returns the new geometry object
  79650. */
  79651. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79652. /**
  79653. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79654. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79655. * Be aware Math.random() could cause collisions, but:
  79656. * "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"
  79657. * @returns a string containing a new GUID
  79658. */
  79659. static RandomId(): string;
  79660. /** @hidden */
  79661. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79662. private static _CleanMatricesWeights;
  79663. /**
  79664. * Create a new geometry from persisted data (Using .babylon file format)
  79665. * @param parsedVertexData defines the persisted data
  79666. * @param scene defines the hosting scene
  79667. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79668. * @returns the new geometry object
  79669. */
  79670. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79671. }
  79672. }
  79673. declare module BABYLON {
  79674. /**
  79675. * Define an interface for all classes that will get and set the data on vertices
  79676. */
  79677. export interface IGetSetVerticesData {
  79678. /**
  79679. * Gets a boolean indicating if specific vertex data is present
  79680. * @param kind defines the vertex data kind to use
  79681. * @returns true is data kind is present
  79682. */
  79683. isVerticesDataPresent(kind: string): boolean;
  79684. /**
  79685. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79686. * @param kind defines the data kind (Position, normal, etc...)
  79687. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79688. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79689. * @returns a float array containing vertex data
  79690. */
  79691. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79692. /**
  79693. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79694. * @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.
  79695. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79696. * @returns the indices array or an empty array if the mesh has no geometry
  79697. */
  79698. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79699. /**
  79700. * Set specific vertex data
  79701. * @param kind defines the data kind (Position, normal, etc...)
  79702. * @param data defines the vertex data to use
  79703. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79704. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79705. */
  79706. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79707. /**
  79708. * Update a specific associated vertex buffer
  79709. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79710. * - VertexBuffer.PositionKind
  79711. * - VertexBuffer.UVKind
  79712. * - VertexBuffer.UV2Kind
  79713. * - VertexBuffer.UV3Kind
  79714. * - VertexBuffer.UV4Kind
  79715. * - VertexBuffer.UV5Kind
  79716. * - VertexBuffer.UV6Kind
  79717. * - VertexBuffer.ColorKind
  79718. * - VertexBuffer.MatricesIndicesKind
  79719. * - VertexBuffer.MatricesIndicesExtraKind
  79720. * - VertexBuffer.MatricesWeightsKind
  79721. * - VertexBuffer.MatricesWeightsExtraKind
  79722. * @param data defines the data source
  79723. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79724. * @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)
  79725. */
  79726. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79727. /**
  79728. * Creates a new index buffer
  79729. * @param indices defines the indices to store in the index buffer
  79730. * @param totalVertices defines the total number of vertices (could be null)
  79731. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79732. */
  79733. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79734. }
  79735. /**
  79736. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79737. */
  79738. export class VertexData {
  79739. /**
  79740. * Mesh side orientation : usually the external or front surface
  79741. */
  79742. static readonly FRONTSIDE: number;
  79743. /**
  79744. * Mesh side orientation : usually the internal or back surface
  79745. */
  79746. static readonly BACKSIDE: number;
  79747. /**
  79748. * Mesh side orientation : both internal and external or front and back surfaces
  79749. */
  79750. static readonly DOUBLESIDE: number;
  79751. /**
  79752. * Mesh side orientation : by default, `FRONTSIDE`
  79753. */
  79754. static readonly DEFAULTSIDE: number;
  79755. /**
  79756. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79757. */
  79758. positions: Nullable<FloatArray>;
  79759. /**
  79760. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79761. */
  79762. normals: Nullable<FloatArray>;
  79763. /**
  79764. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79765. */
  79766. tangents: Nullable<FloatArray>;
  79767. /**
  79768. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79769. */
  79770. uvs: Nullable<FloatArray>;
  79771. /**
  79772. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79773. */
  79774. uvs2: Nullable<FloatArray>;
  79775. /**
  79776. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79777. */
  79778. uvs3: Nullable<FloatArray>;
  79779. /**
  79780. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79781. */
  79782. uvs4: Nullable<FloatArray>;
  79783. /**
  79784. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79785. */
  79786. uvs5: Nullable<FloatArray>;
  79787. /**
  79788. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79789. */
  79790. uvs6: Nullable<FloatArray>;
  79791. /**
  79792. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79793. */
  79794. colors: Nullable<FloatArray>;
  79795. /**
  79796. * 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).
  79797. */
  79798. matricesIndices: Nullable<FloatArray>;
  79799. /**
  79800. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79801. */
  79802. matricesWeights: Nullable<FloatArray>;
  79803. /**
  79804. * An array extending the number of possible indices
  79805. */
  79806. matricesIndicesExtra: Nullable<FloatArray>;
  79807. /**
  79808. * An array extending the number of possible weights when the number of indices is extended
  79809. */
  79810. matricesWeightsExtra: Nullable<FloatArray>;
  79811. /**
  79812. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79813. */
  79814. indices: Nullable<IndicesArray>;
  79815. /**
  79816. * Uses the passed data array to set the set the values for the specified kind of data
  79817. * @param data a linear array of floating numbers
  79818. * @param kind the type of data that is being set, eg positions, colors etc
  79819. */
  79820. set(data: FloatArray, kind: string): void;
  79821. /**
  79822. * Associates the vertexData to the passed Mesh.
  79823. * Sets it as updatable or not (default `false`)
  79824. * @param mesh the mesh the vertexData is applied to
  79825. * @param updatable when used and having the value true allows new data to update the vertexData
  79826. * @returns the VertexData
  79827. */
  79828. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79829. /**
  79830. * Associates the vertexData to the passed Geometry.
  79831. * Sets it as updatable or not (default `false`)
  79832. * @param geometry the geometry the vertexData is applied to
  79833. * @param updatable when used and having the value true allows new data to update the vertexData
  79834. * @returns VertexData
  79835. */
  79836. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79837. /**
  79838. * Updates the associated mesh
  79839. * @param mesh the mesh to be updated
  79840. * @param updateExtends when true the mesh 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. updateMesh(mesh: Mesh): VertexData;
  79845. /**
  79846. * Updates the associated geometry
  79847. * @param geometry the geometry to be updated
  79848. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79849. * @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
  79850. * @returns VertexData.
  79851. */
  79852. updateGeometry(geometry: Geometry): VertexData;
  79853. private _applyTo;
  79854. private _update;
  79855. /**
  79856. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79857. * @param matrix the transforming matrix
  79858. * @returns the VertexData
  79859. */
  79860. transform(matrix: Matrix): VertexData;
  79861. /**
  79862. * Merges the passed VertexData into the current one
  79863. * @param other the VertexData to be merged into the current one
  79864. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79865. * @returns the modified VertexData
  79866. */
  79867. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79868. private _mergeElement;
  79869. private _validate;
  79870. /**
  79871. * Serializes the VertexData
  79872. * @returns a serialized object
  79873. */
  79874. serialize(): any;
  79875. /**
  79876. * Extracts the vertexData from a mesh
  79877. * @param mesh the mesh from which to extract the VertexData
  79878. * @param copyWhenShared defines if the VertexData must be cloned when 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 ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79883. /**
  79884. * Extracts the vertexData from the geometry
  79885. * @param geometry the geometry from which to extract the VertexData
  79886. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79887. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79888. * @returns the object VertexData associated to the passed mesh
  79889. */
  79890. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79891. private static _ExtractFrom;
  79892. /**
  79893. * Creates the VertexData for a Ribbon
  79894. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79895. * * pathArray array of paths, each of which an array of successive Vector3
  79896. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79897. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79898. * * 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
  79899. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79900. * * 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)
  79901. * * 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)
  79902. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79903. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79904. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79905. * @returns the VertexData of the ribbon
  79906. */
  79907. static CreateRibbon(options: {
  79908. pathArray: Vector3[][];
  79909. closeArray?: boolean;
  79910. closePath?: boolean;
  79911. offset?: number;
  79912. sideOrientation?: number;
  79913. frontUVs?: Vector4;
  79914. backUVs?: Vector4;
  79915. invertUV?: boolean;
  79916. uvs?: Vector2[];
  79917. colors?: Color4[];
  79918. }): VertexData;
  79919. /**
  79920. * Creates the VertexData for a box
  79921. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79922. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79923. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79924. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79925. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79926. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79927. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79928. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79929. * * 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)
  79930. * * 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)
  79931. * @returns the VertexData of the box
  79932. */
  79933. static CreateBox(options: {
  79934. size?: number;
  79935. width?: number;
  79936. height?: number;
  79937. depth?: number;
  79938. faceUV?: Vector4[];
  79939. faceColors?: Color4[];
  79940. sideOrientation?: number;
  79941. frontUVs?: Vector4;
  79942. backUVs?: Vector4;
  79943. }): VertexData;
  79944. /**
  79945. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79946. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79947. * * segments sets the number of horizontal strips optional, default 32
  79948. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79949. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79950. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79951. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79952. * * 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
  79953. * * 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
  79954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79955. * * 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)
  79956. * * 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)
  79957. * @returns the VertexData of the ellipsoid
  79958. */
  79959. static CreateSphere(options: {
  79960. segments?: number;
  79961. diameter?: number;
  79962. diameterX?: number;
  79963. diameterY?: number;
  79964. diameterZ?: number;
  79965. arc?: number;
  79966. slice?: number;
  79967. sideOrientation?: number;
  79968. frontUVs?: Vector4;
  79969. backUVs?: Vector4;
  79970. }): VertexData;
  79971. /**
  79972. * Creates the VertexData for a cylinder, cone or prism
  79973. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79974. * * height sets the height (y direction) of the cylinder, optional, default 2
  79975. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79976. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79977. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79978. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79979. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79980. * * 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
  79981. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79982. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79983. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79984. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79985. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79986. * * 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)
  79987. * * 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)
  79988. * @returns the VertexData of the cylinder, cone or prism
  79989. */
  79990. static CreateCylinder(options: {
  79991. height?: number;
  79992. diameterTop?: number;
  79993. diameterBottom?: number;
  79994. diameter?: number;
  79995. tessellation?: number;
  79996. subdivisions?: number;
  79997. arc?: number;
  79998. faceColors?: Color4[];
  79999. faceUV?: Vector4[];
  80000. hasRings?: boolean;
  80001. enclose?: boolean;
  80002. sideOrientation?: number;
  80003. frontUVs?: Vector4;
  80004. backUVs?: Vector4;
  80005. }): VertexData;
  80006. /**
  80007. * Creates the VertexData for a torus
  80008. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80009. * * diameter the diameter of the torus, optional default 1
  80010. * * thickness the diameter of the tube forming the torus, optional default 0.5
  80011. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80012. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80013. * * 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)
  80014. * * 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)
  80015. * @returns the VertexData of the torus
  80016. */
  80017. static CreateTorus(options: {
  80018. diameter?: number;
  80019. thickness?: number;
  80020. tessellation?: number;
  80021. sideOrientation?: number;
  80022. frontUVs?: Vector4;
  80023. backUVs?: Vector4;
  80024. }): VertexData;
  80025. /**
  80026. * Creates the VertexData of the LineSystem
  80027. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  80028. * - lines an array of lines, each line being an array of successive Vector3
  80029. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  80030. * @returns the VertexData of the LineSystem
  80031. */
  80032. static CreateLineSystem(options: {
  80033. lines: Vector3[][];
  80034. colors?: Nullable<Color4[][]>;
  80035. }): VertexData;
  80036. /**
  80037. * Create the VertexData for a DashedLines
  80038. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  80039. * - points an array successive Vector3
  80040. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  80041. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  80042. * - dashNb the intended total number of dashes, optional, default 200
  80043. * @returns the VertexData for the DashedLines
  80044. */
  80045. static CreateDashedLines(options: {
  80046. points: Vector3[];
  80047. dashSize?: number;
  80048. gapSize?: number;
  80049. dashNb?: number;
  80050. }): VertexData;
  80051. /**
  80052. * Creates the VertexData for a Ground
  80053. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80054. * - width the width (x direction) of the ground, optional, default 1
  80055. * - height the height (z direction) of the ground, optional, default 1
  80056. * - subdivisions the number of subdivisions per side, optional, default 1
  80057. * @returns the VertexData of the Ground
  80058. */
  80059. static CreateGround(options: {
  80060. width?: number;
  80061. height?: number;
  80062. subdivisions?: number;
  80063. subdivisionsX?: number;
  80064. subdivisionsY?: number;
  80065. }): VertexData;
  80066. /**
  80067. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  80068. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80069. * * xmin the ground minimum X coordinate, optional, default -1
  80070. * * zmin the ground minimum Z coordinate, optional, default -1
  80071. * * xmax the ground maximum X coordinate, optional, default 1
  80072. * * zmax the ground maximum Z coordinate, optional, default 1
  80073. * * 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}
  80074. * * 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}
  80075. * @returns the VertexData of the TiledGround
  80076. */
  80077. static CreateTiledGround(options: {
  80078. xmin: number;
  80079. zmin: number;
  80080. xmax: number;
  80081. zmax: number;
  80082. subdivisions?: {
  80083. w: number;
  80084. h: number;
  80085. };
  80086. precision?: {
  80087. w: number;
  80088. h: number;
  80089. };
  80090. }): VertexData;
  80091. /**
  80092. * Creates the VertexData of the Ground designed from a heightmap
  80093. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  80094. * * width the width (x direction) of the ground
  80095. * * height the height (z direction) of the ground
  80096. * * subdivisions the number of subdivisions per side
  80097. * * minHeight the minimum altitude on the ground, optional, default 0
  80098. * * maxHeight the maximum altitude on the ground, optional default 1
  80099. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  80100. * * buffer the array holding the image color data
  80101. * * bufferWidth the width of image
  80102. * * bufferHeight the height of image
  80103. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  80104. * @returns the VertexData of the Ground designed from a heightmap
  80105. */
  80106. static CreateGroundFromHeightMap(options: {
  80107. width: number;
  80108. height: number;
  80109. subdivisions: number;
  80110. minHeight: number;
  80111. maxHeight: number;
  80112. colorFilter: Color3;
  80113. buffer: Uint8Array;
  80114. bufferWidth: number;
  80115. bufferHeight: number;
  80116. alphaFilter: number;
  80117. }): VertexData;
  80118. /**
  80119. * Creates the VertexData for a Plane
  80120. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  80121. * * size sets the width and height of the plane to the value of size, optional default 1
  80122. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  80123. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  80124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80125. * * 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)
  80126. * * 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)
  80127. * @returns the VertexData of the box
  80128. */
  80129. static CreatePlane(options: {
  80130. size?: number;
  80131. width?: number;
  80132. height?: number;
  80133. sideOrientation?: number;
  80134. frontUVs?: Vector4;
  80135. backUVs?: Vector4;
  80136. }): VertexData;
  80137. /**
  80138. * Creates the VertexData of the Disc or regular Polygon
  80139. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  80140. * * radius the radius of the disc, optional default 0.5
  80141. * * tessellation the number of polygon sides, optional, default 64
  80142. * * 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
  80143. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80144. * * 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)
  80145. * * 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)
  80146. * @returns the VertexData of the box
  80147. */
  80148. static CreateDisc(options: {
  80149. radius?: number;
  80150. tessellation?: number;
  80151. arc?: number;
  80152. sideOrientation?: number;
  80153. frontUVs?: Vector4;
  80154. backUVs?: Vector4;
  80155. }): VertexData;
  80156. /**
  80157. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  80158. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  80159. * @param polygon a mesh built from polygonTriangulation.build()
  80160. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80161. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80162. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80163. * @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)
  80164. * @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)
  80165. * @returns the VertexData of the Polygon
  80166. */
  80167. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  80168. /**
  80169. * Creates the VertexData of the IcoSphere
  80170. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  80171. * * radius the radius of the IcoSphere, optional default 1
  80172. * * radiusX allows stretching in the x direction, optional, default radius
  80173. * * radiusY allows stretching in the y direction, optional, default radius
  80174. * * radiusZ allows stretching in the z direction, optional, default radius
  80175. * * flat when true creates a flat shaded mesh, optional, default true
  80176. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80178. * * 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)
  80179. * * 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)
  80180. * @returns the VertexData of the IcoSphere
  80181. */
  80182. static CreateIcoSphere(options: {
  80183. radius?: number;
  80184. radiusX?: number;
  80185. radiusY?: number;
  80186. radiusZ?: number;
  80187. flat?: boolean;
  80188. subdivisions?: number;
  80189. sideOrientation?: number;
  80190. frontUVs?: Vector4;
  80191. backUVs?: Vector4;
  80192. }): VertexData;
  80193. /**
  80194. * Creates the VertexData for a Polyhedron
  80195. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  80196. * * type provided types are:
  80197. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80198. * * 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)
  80199. * * size the size of the IcoSphere, optional default 1
  80200. * * sizeX allows stretching in the x direction, optional, default size
  80201. * * sizeY allows stretching in the y direction, optional, default size
  80202. * * sizeZ allows stretching in the z direction, optional, default size
  80203. * * 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
  80204. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80205. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80206. * * flat when true creates a flat shaded mesh, optional, default true
  80207. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80208. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80209. * * 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)
  80210. * * 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)
  80211. * @returns the VertexData of the Polyhedron
  80212. */
  80213. static CreatePolyhedron(options: {
  80214. type?: number;
  80215. size?: number;
  80216. sizeX?: number;
  80217. sizeY?: number;
  80218. sizeZ?: number;
  80219. custom?: any;
  80220. faceUV?: Vector4[];
  80221. faceColors?: Color4[];
  80222. flat?: boolean;
  80223. sideOrientation?: number;
  80224. frontUVs?: Vector4;
  80225. backUVs?: Vector4;
  80226. }): VertexData;
  80227. /**
  80228. * Creates the VertexData for a TorusKnot
  80229. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80230. * * radius the radius of the torus knot, optional, default 2
  80231. * * tube the thickness of the tube, optional, default 0.5
  80232. * * radialSegments the number of sides on each tube segments, optional, default 32
  80233. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80234. * * p the number of windings around the z axis, optional, default 2
  80235. * * q the number of windings around the x axis, optional, default 3
  80236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80237. * * 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)
  80238. * * 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)
  80239. * @returns the VertexData of the Torus Knot
  80240. */
  80241. static CreateTorusKnot(options: {
  80242. radius?: number;
  80243. tube?: number;
  80244. radialSegments?: number;
  80245. tubularSegments?: number;
  80246. p?: number;
  80247. q?: number;
  80248. sideOrientation?: number;
  80249. frontUVs?: Vector4;
  80250. backUVs?: Vector4;
  80251. }): VertexData;
  80252. /**
  80253. * Compute normals for given positions and indices
  80254. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80255. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80256. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80257. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80258. * * facetNormals : optional array of facet normals (vector3)
  80259. * * facetPositions : optional array of facet positions (vector3)
  80260. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80261. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80262. * * bInfo : optional bounding info, required for facetPartitioning computation
  80263. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80264. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80265. * * useRightHandedSystem: optional boolean to for right handed system computation
  80266. * * depthSort : optional boolean to enable the facet depth sort computation
  80267. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80268. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80269. */
  80270. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80271. facetNormals?: any;
  80272. facetPositions?: any;
  80273. facetPartitioning?: any;
  80274. ratio?: number;
  80275. bInfo?: any;
  80276. bbSize?: Vector3;
  80277. subDiv?: any;
  80278. useRightHandedSystem?: boolean;
  80279. depthSort?: boolean;
  80280. distanceTo?: Vector3;
  80281. depthSortedFacets?: any;
  80282. }): void;
  80283. /** @hidden */
  80284. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80285. /**
  80286. * Applies VertexData created from the imported parameters to the geometry
  80287. * @param parsedVertexData the parsed data from an imported file
  80288. * @param geometry the geometry to apply the VertexData to
  80289. */
  80290. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80291. }
  80292. }
  80293. declare module BABYLON {
  80294. /**
  80295. * Class containing static functions to help procedurally build meshes
  80296. */
  80297. export class DiscBuilder {
  80298. /**
  80299. * Creates a plane polygonal mesh. By default, this is a disc
  80300. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80301. * * 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
  80302. * * 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
  80303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80306. * @param name defines the name of the mesh
  80307. * @param options defines the options used to create the mesh
  80308. * @param scene defines the hosting scene
  80309. * @returns the plane polygonal mesh
  80310. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80311. */
  80312. static CreateDisc(name: string, options: {
  80313. radius?: number;
  80314. tessellation?: number;
  80315. arc?: number;
  80316. updatable?: boolean;
  80317. sideOrientation?: number;
  80318. frontUVs?: Vector4;
  80319. backUVs?: Vector4;
  80320. }, scene?: Nullable<Scene>): Mesh;
  80321. }
  80322. }
  80323. declare module BABYLON {
  80324. /**
  80325. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80326. *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.
  80327. * The SPS is also a particle system. It provides some methods to manage the particles.
  80328. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80329. *
  80330. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80331. */
  80332. export class SolidParticleSystem implements IDisposable {
  80333. /**
  80334. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80335. * Example : var p = SPS.particles[i];
  80336. */
  80337. particles: SolidParticle[];
  80338. /**
  80339. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80340. */
  80341. nbParticles: number;
  80342. /**
  80343. * If the particles must ever face the camera (default false). Useful for planar particles.
  80344. */
  80345. billboard: boolean;
  80346. /**
  80347. * Recompute normals when adding a shape
  80348. */
  80349. recomputeNormals: boolean;
  80350. /**
  80351. * This a counter ofr your own usage. It's not set by any SPS functions.
  80352. */
  80353. counter: number;
  80354. /**
  80355. * The SPS name. This name is also given to the underlying mesh.
  80356. */
  80357. name: string;
  80358. /**
  80359. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80360. */
  80361. mesh: Mesh;
  80362. /**
  80363. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80364. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80365. */
  80366. vars: any;
  80367. /**
  80368. * This array is populated when the SPS is set as 'pickable'.
  80369. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80370. * Each element of this array is an object `{idx: int, faceId: int}`.
  80371. * `idx` is the picked particle index in the `SPS.particles` array
  80372. * `faceId` is the picked face index counted within this particle.
  80373. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80374. */
  80375. pickedParticles: {
  80376. idx: number;
  80377. faceId: number;
  80378. }[];
  80379. /**
  80380. * This array is populated when `enableDepthSort` is set to true.
  80381. * Each element of this array is an instance of the class DepthSortedParticle.
  80382. */
  80383. depthSortedParticles: DepthSortedParticle[];
  80384. /**
  80385. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80386. * @hidden
  80387. */
  80388. _bSphereOnly: boolean;
  80389. /**
  80390. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80391. * @hidden
  80392. */
  80393. _bSphereRadiusFactor: number;
  80394. private _scene;
  80395. private _positions;
  80396. private _indices;
  80397. private _normals;
  80398. private _colors;
  80399. private _uvs;
  80400. private _indices32;
  80401. private _positions32;
  80402. private _normals32;
  80403. private _fixedNormal32;
  80404. private _colors32;
  80405. private _uvs32;
  80406. private _index;
  80407. private _updatable;
  80408. private _pickable;
  80409. private _isVisibilityBoxLocked;
  80410. private _alwaysVisible;
  80411. private _depthSort;
  80412. private _shapeCounter;
  80413. private _copy;
  80414. private _color;
  80415. private _computeParticleColor;
  80416. private _computeParticleTexture;
  80417. private _computeParticleRotation;
  80418. private _computeParticleVertex;
  80419. private _computeBoundingBox;
  80420. private _depthSortParticles;
  80421. private _camera;
  80422. private _mustUnrotateFixedNormals;
  80423. private _particlesIntersect;
  80424. private _needs32Bits;
  80425. /**
  80426. * Creates a SPS (Solid Particle System) object.
  80427. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80428. * @param scene (Scene) is the scene in which the SPS is added.
  80429. * @param options defines the options of the sps e.g.
  80430. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80431. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80432. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80433. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80434. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80435. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80436. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80437. */
  80438. constructor(name: string, scene: Scene, options?: {
  80439. updatable?: boolean;
  80440. isPickable?: boolean;
  80441. enableDepthSort?: boolean;
  80442. particleIntersection?: boolean;
  80443. boundingSphereOnly?: boolean;
  80444. bSphereRadiusFactor?: number;
  80445. });
  80446. /**
  80447. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80448. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80449. * @returns the created mesh
  80450. */
  80451. buildMesh(): Mesh;
  80452. /**
  80453. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80454. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80455. * Thus the particles generated from `digest()` have their property `position` set yet.
  80456. * @param mesh ( Mesh ) is the mesh to be digested
  80457. * @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
  80458. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80459. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80460. * @returns the current SPS
  80461. */
  80462. digest(mesh: Mesh, options?: {
  80463. facetNb?: number;
  80464. number?: number;
  80465. delta?: number;
  80466. }): SolidParticleSystem;
  80467. private _unrotateFixedNormals;
  80468. private _resetCopy;
  80469. private _meshBuilder;
  80470. private _posToShape;
  80471. private _uvsToShapeUV;
  80472. private _addParticle;
  80473. /**
  80474. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80475. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80476. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80477. * @param nb (positive integer) the number of particles to be created from this model
  80478. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80479. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80480. * @returns the number of shapes in the system
  80481. */
  80482. addShape(mesh: Mesh, nb: number, options?: {
  80483. positionFunction?: any;
  80484. vertexFunction?: any;
  80485. }): number;
  80486. private _rebuildParticle;
  80487. /**
  80488. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80489. * @returns the SPS.
  80490. */
  80491. rebuildMesh(): SolidParticleSystem;
  80492. /**
  80493. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80494. * This method calls `updateParticle()` for each particle of the SPS.
  80495. * For an animated SPS, it is usually called within the render loop.
  80496. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80497. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80498. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80499. * @returns the SPS.
  80500. */
  80501. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80502. /**
  80503. * Disposes the SPS.
  80504. */
  80505. dispose(): void;
  80506. /**
  80507. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80508. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80509. * @returns the SPS.
  80510. */
  80511. refreshVisibleSize(): SolidParticleSystem;
  80512. /**
  80513. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80514. * @param size the size (float) of the visibility box
  80515. * note : this doesn't lock the SPS mesh bounding box.
  80516. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80517. */
  80518. setVisibilityBox(size: number): void;
  80519. /**
  80520. * Gets whether the SPS as always visible or not
  80521. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80522. */
  80523. /**
  80524. * Sets the SPS as always visible or not
  80525. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80526. */
  80527. isAlwaysVisible: boolean;
  80528. /**
  80529. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80530. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80531. */
  80532. /**
  80533. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80534. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80535. */
  80536. isVisibilityBoxLocked: boolean;
  80537. /**
  80538. * Tells to `setParticles()` to compute the particle rotations or not.
  80539. * Default value : true. The SPS is faster when it's set to false.
  80540. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80541. */
  80542. /**
  80543. * Gets if `setParticles()` computes the particle rotations or not.
  80544. * Default value : true. The SPS is faster when it's set to false.
  80545. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80546. */
  80547. computeParticleRotation: boolean;
  80548. /**
  80549. * Tells to `setParticles()` to compute the particle colors or not.
  80550. * Default value : true. The SPS is faster when it's set to false.
  80551. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80552. */
  80553. /**
  80554. * Gets if `setParticles()` computes the particle colors or not.
  80555. * Default value : true. The SPS is faster when it's set to false.
  80556. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80557. */
  80558. computeParticleColor: boolean;
  80559. /**
  80560. * Gets if `setParticles()` computes the particle textures or not.
  80561. * Default value : true. The SPS is faster when it's set to false.
  80562. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80563. */
  80564. computeParticleTexture: boolean;
  80565. /**
  80566. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80567. * Default value : false. The SPS is faster when it's set to false.
  80568. * Note : the particle custom vertex positions aren't stored values.
  80569. */
  80570. /**
  80571. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80572. * Default value : false. The SPS is faster when it's set to false.
  80573. * Note : the particle custom vertex positions aren't stored values.
  80574. */
  80575. computeParticleVertex: boolean;
  80576. /**
  80577. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80578. */
  80579. /**
  80580. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80581. */
  80582. computeBoundingBox: boolean;
  80583. /**
  80584. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80585. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80586. * Default : `true`
  80587. */
  80588. /**
  80589. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80590. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80591. * Default : `true`
  80592. */
  80593. depthSortParticles: boolean;
  80594. /**
  80595. * This function does nothing. It may be overwritten to set all the particle first values.
  80596. * The SPS doesn't call this function, you may have to call it by your own.
  80597. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80598. */
  80599. initParticles(): void;
  80600. /**
  80601. * This function does nothing. It may be overwritten to recycle a particle.
  80602. * The SPS doesn't call this function, you may have to call it by your own.
  80603. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80604. * @param particle The particle to recycle
  80605. * @returns the recycled particle
  80606. */
  80607. recycleParticle(particle: SolidParticle): SolidParticle;
  80608. /**
  80609. * Updates a particle : this function should be overwritten by the user.
  80610. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80611. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80612. * @example : just set a particle position or velocity and recycle conditions
  80613. * @param particle The particle to update
  80614. * @returns the updated particle
  80615. */
  80616. updateParticle(particle: SolidParticle): SolidParticle;
  80617. /**
  80618. * Updates a vertex of a particle : it can be overwritten by the user.
  80619. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80620. * @param particle the current particle
  80621. * @param vertex the current index of the current particle
  80622. * @param pt the index of the current vertex in the particle shape
  80623. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80624. * @example : just set a vertex particle position
  80625. * @returns the updated vertex
  80626. */
  80627. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80628. /**
  80629. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80630. * This does nothing and may be overwritten by the user.
  80631. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80632. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80633. * @param update the boolean update value actually passed to setParticles()
  80634. */
  80635. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80636. /**
  80637. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80638. * This will be passed three parameters.
  80639. * This does nothing and may be overwritten by the user.
  80640. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80641. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80642. * @param update the boolean update value actually passed to setParticles()
  80643. */
  80644. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80645. }
  80646. }
  80647. declare module BABYLON {
  80648. /**
  80649. * Represents one particle of a solid particle system.
  80650. */
  80651. export class SolidParticle {
  80652. /**
  80653. * particle global index
  80654. */
  80655. idx: number;
  80656. /**
  80657. * The color of the particle
  80658. */
  80659. color: Nullable<Color4>;
  80660. /**
  80661. * The world space position of the particle.
  80662. */
  80663. position: Vector3;
  80664. /**
  80665. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80666. */
  80667. rotation: Vector3;
  80668. /**
  80669. * The world space rotation quaternion of the particle.
  80670. */
  80671. rotationQuaternion: Nullable<Quaternion>;
  80672. /**
  80673. * The scaling of the particle.
  80674. */
  80675. scaling: Vector3;
  80676. /**
  80677. * The uvs of the particle.
  80678. */
  80679. uvs: Vector4;
  80680. /**
  80681. * The current speed of the particle.
  80682. */
  80683. velocity: Vector3;
  80684. /**
  80685. * The pivot point in the particle local space.
  80686. */
  80687. pivot: Vector3;
  80688. /**
  80689. * Must the particle be translated from its pivot point in its local space ?
  80690. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80691. * Default : false
  80692. */
  80693. translateFromPivot: boolean;
  80694. /**
  80695. * Is the particle active or not ?
  80696. */
  80697. alive: boolean;
  80698. /**
  80699. * Is the particle visible or not ?
  80700. */
  80701. isVisible: boolean;
  80702. /**
  80703. * Index of this particle in the global "positions" array (Internal use)
  80704. * @hidden
  80705. */
  80706. _pos: number;
  80707. /**
  80708. * @hidden Index of this particle in the global "indices" array (Internal use)
  80709. */
  80710. _ind: number;
  80711. /**
  80712. * @hidden ModelShape of this particle (Internal use)
  80713. */
  80714. _model: ModelShape;
  80715. /**
  80716. * ModelShape id of this particle
  80717. */
  80718. shapeId: number;
  80719. /**
  80720. * Index of the particle in its shape id (Internal use)
  80721. */
  80722. idxInShape: number;
  80723. /**
  80724. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80725. */
  80726. _modelBoundingInfo: BoundingInfo;
  80727. /**
  80728. * @hidden Particle BoundingInfo object (Internal use)
  80729. */
  80730. _boundingInfo: BoundingInfo;
  80731. /**
  80732. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80733. */
  80734. _sps: SolidParticleSystem;
  80735. /**
  80736. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80737. */
  80738. _stillInvisible: boolean;
  80739. /**
  80740. * @hidden Last computed particle rotation matrix
  80741. */
  80742. _rotationMatrix: number[];
  80743. /**
  80744. * Parent particle Id, if any.
  80745. * Default null.
  80746. */
  80747. parentId: Nullable<number>;
  80748. /**
  80749. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80750. * The possible values are :
  80751. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80752. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80753. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80754. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80755. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80756. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80757. * */
  80758. cullingStrategy: number;
  80759. /**
  80760. * @hidden Internal global position in the SPS.
  80761. */
  80762. _globalPosition: Vector3;
  80763. /**
  80764. * Creates a Solid Particle object.
  80765. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80766. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80767. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80768. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80769. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80770. * @param shapeId (integer) is the model shape identifier in the SPS.
  80771. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80772. * @param sps defines the sps it is associated to
  80773. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80774. */
  80775. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80776. /**
  80777. * Legacy support, changed scale to scaling
  80778. */
  80779. /**
  80780. * Legacy support, changed scale to scaling
  80781. */
  80782. scale: Vector3;
  80783. /**
  80784. * Legacy support, changed quaternion to rotationQuaternion
  80785. */
  80786. /**
  80787. * Legacy support, changed quaternion to rotationQuaternion
  80788. */
  80789. quaternion: Nullable<Quaternion>;
  80790. /**
  80791. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80792. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80793. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80794. * @returns true if it intersects
  80795. */
  80796. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80797. /**
  80798. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80799. * A particle is in the frustum if its bounding box intersects the frustum
  80800. * @param frustumPlanes defines the frustum to test
  80801. * @returns true if the particle is in the frustum planes
  80802. */
  80803. isInFrustum(frustumPlanes: Plane[]): boolean;
  80804. /**
  80805. * get the rotation matrix of the particle
  80806. * @hidden
  80807. */
  80808. getRotationMatrix(m: Matrix): void;
  80809. }
  80810. /**
  80811. * Represents the shape of the model used by one particle of a solid particle system.
  80812. * SPS internal tool, don't use it manually.
  80813. */
  80814. export class ModelShape {
  80815. /**
  80816. * The shape id
  80817. * @hidden
  80818. */
  80819. shapeID: number;
  80820. /**
  80821. * flat array of model positions (internal use)
  80822. * @hidden
  80823. */
  80824. _shape: Vector3[];
  80825. /**
  80826. * flat array of model UVs (internal use)
  80827. * @hidden
  80828. */
  80829. _shapeUV: number[];
  80830. /**
  80831. * length of the shape in the model indices array (internal use)
  80832. * @hidden
  80833. */
  80834. _indicesLength: number;
  80835. /**
  80836. * Custom position function (internal use)
  80837. * @hidden
  80838. */
  80839. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80840. /**
  80841. * Custom vertex function (internal use)
  80842. * @hidden
  80843. */
  80844. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80845. /**
  80846. * 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.
  80847. * SPS internal tool, don't use it manually.
  80848. * @hidden
  80849. */
  80850. 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>);
  80851. }
  80852. /**
  80853. * Represents a Depth Sorted Particle in the solid particle system.
  80854. */
  80855. export class DepthSortedParticle {
  80856. /**
  80857. * Index of the particle in the "indices" array
  80858. */
  80859. ind: number;
  80860. /**
  80861. * Length of the particle shape in the "indices" array
  80862. */
  80863. indicesLength: number;
  80864. /**
  80865. * Squared distance from the particle to the camera
  80866. */
  80867. sqDistance: number;
  80868. }
  80869. }
  80870. declare module BABYLON {
  80871. /**
  80872. * Class used to store all common mesh properties
  80873. */
  80874. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80875. /** No occlusion */
  80876. static OCCLUSION_TYPE_NONE: number;
  80877. /** Occlusion set to optimisitic */
  80878. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80879. /** Occlusion set to strict */
  80880. static OCCLUSION_TYPE_STRICT: number;
  80881. /** Use an accurante occlusion algorithm */
  80882. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80883. /** Use a conservative occlusion algorithm */
  80884. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80885. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80886. * Test order :
  80887. * Is the bounding sphere outside the frustum ?
  80888. * If not, are the bounding box vertices outside the frustum ?
  80889. * It not, then the cullable object is in the frustum.
  80890. */
  80891. static readonly CULLINGSTRATEGY_STANDARD: number;
  80892. /** Culling strategy : Bounding Sphere Only.
  80893. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80894. * It's also less accurate than the standard because some not visible objects can still be selected.
  80895. * Test : is the bounding sphere outside the frustum ?
  80896. * If not, then the cullable object is in the frustum.
  80897. */
  80898. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80899. /** Culling strategy : Optimistic Inclusion.
  80900. * This in an inclusion test first, then the standard exclusion test.
  80901. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80902. * 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.
  80903. * Anyway, it's as accurate as the standard strategy.
  80904. * Test :
  80905. * Is the cullable object bounding sphere center in the frustum ?
  80906. * If not, apply the default culling strategy.
  80907. */
  80908. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80909. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80910. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80911. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80912. * 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.
  80913. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80914. * Test :
  80915. * Is the cullable object bounding sphere center in the frustum ?
  80916. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80917. */
  80918. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80919. /**
  80920. * No billboard
  80921. */
  80922. static readonly BILLBOARDMODE_NONE: number;
  80923. /** Billboard on X axis */
  80924. static readonly BILLBOARDMODE_X: number;
  80925. /** Billboard on Y axis */
  80926. static readonly BILLBOARDMODE_Y: number;
  80927. /** Billboard on Z axis */
  80928. static readonly BILLBOARDMODE_Z: number;
  80929. /** Billboard on all axes */
  80930. static readonly BILLBOARDMODE_ALL: number;
  80931. private _facetData;
  80932. /**
  80933. * The culling strategy to use to check whether the mesh must be rendered or not.
  80934. * This value can be changed at any time and will be used on the next render mesh selection.
  80935. * The possible values are :
  80936. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80937. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80938. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80939. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80940. * Please read each static variable documentation to get details about the culling process.
  80941. * */
  80942. cullingStrategy: number;
  80943. /**
  80944. * Gets the number of facets in the mesh
  80945. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80946. */
  80947. readonly facetNb: number;
  80948. /**
  80949. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80951. */
  80952. partitioningSubdivisions: number;
  80953. /**
  80954. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80955. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80956. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80957. */
  80958. partitioningBBoxRatio: number;
  80959. /**
  80960. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80961. * Works only for updatable meshes.
  80962. * Doesn't work with multi-materials
  80963. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80964. */
  80965. mustDepthSortFacets: boolean;
  80966. /**
  80967. * The location (Vector3) where the facet depth sort must be computed from.
  80968. * By default, the active camera position.
  80969. * Used only when facet depth sort is enabled
  80970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80971. */
  80972. facetDepthSortFrom: Vector3;
  80973. /**
  80974. * gets a boolean indicating if facetData is enabled
  80975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80976. */
  80977. readonly isFacetDataEnabled: boolean;
  80978. /** @hidden */
  80979. _updateNonUniformScalingState(value: boolean): boolean;
  80980. /**
  80981. * An event triggered when this mesh collides with another one
  80982. */
  80983. onCollideObservable: Observable<AbstractMesh>;
  80984. private _onCollideObserver;
  80985. /** Set a function to call when this mesh collides with another one */
  80986. onCollide: () => void;
  80987. /**
  80988. * An event triggered when the collision's position changes
  80989. */
  80990. onCollisionPositionChangeObservable: Observable<Vector3>;
  80991. private _onCollisionPositionChangeObserver;
  80992. /** Set a function to call when the collision's position changes */
  80993. onCollisionPositionChange: () => void;
  80994. /**
  80995. * An event triggered when material is changed
  80996. */
  80997. onMaterialChangedObservable: Observable<AbstractMesh>;
  80998. /**
  80999. * Gets or sets the orientation for POV movement & rotation
  81000. */
  81001. definedFacingForward: boolean;
  81002. /** @hidden */
  81003. _occlusionQuery: Nullable<WebGLQuery>;
  81004. private _visibility;
  81005. /**
  81006. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81007. */
  81008. /**
  81009. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81010. */
  81011. visibility: number;
  81012. /** Gets or sets the alpha index used to sort transparent meshes
  81013. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81014. */
  81015. alphaIndex: number;
  81016. /**
  81017. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81018. */
  81019. isVisible: boolean;
  81020. /**
  81021. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81022. */
  81023. isPickable: boolean;
  81024. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81025. showSubMeshesBoundingBox: boolean;
  81026. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81027. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81028. */
  81029. isBlocker: boolean;
  81030. /**
  81031. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81032. */
  81033. enablePointerMoveEvents: boolean;
  81034. /**
  81035. * Specifies the rendering group id for this mesh (0 by default)
  81036. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81037. */
  81038. renderingGroupId: number;
  81039. private _material;
  81040. /** Gets or sets current material */
  81041. material: Nullable<Material>;
  81042. private _receiveShadows;
  81043. /**
  81044. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81045. * @see http://doc.babylonjs.com/babylon101/shadows
  81046. */
  81047. receiveShadows: boolean;
  81048. /** Defines color to use when rendering outline */
  81049. outlineColor: Color3;
  81050. /** Define width to use when rendering outline */
  81051. outlineWidth: number;
  81052. /** Defines color to use when rendering overlay */
  81053. overlayColor: Color3;
  81054. /** Defines alpha to use when rendering overlay */
  81055. overlayAlpha: number;
  81056. private _hasVertexAlpha;
  81057. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81058. hasVertexAlpha: boolean;
  81059. private _useVertexColors;
  81060. /** 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) */
  81061. useVertexColors: boolean;
  81062. private _computeBonesUsingShaders;
  81063. /**
  81064. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81065. */
  81066. computeBonesUsingShaders: boolean;
  81067. private _numBoneInfluencers;
  81068. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81069. numBoneInfluencers: number;
  81070. private _applyFog;
  81071. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81072. applyFog: boolean;
  81073. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81074. useOctreeForRenderingSelection: boolean;
  81075. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81076. useOctreeForPicking: boolean;
  81077. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81078. useOctreeForCollisions: boolean;
  81079. private _layerMask;
  81080. /**
  81081. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81082. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81083. */
  81084. layerMask: number;
  81085. /**
  81086. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81087. */
  81088. alwaysSelectAsActiveMesh: boolean;
  81089. /**
  81090. * Gets or sets the current action manager
  81091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81092. */
  81093. actionManager: Nullable<AbstractActionManager>;
  81094. private _checkCollisions;
  81095. private _collisionMask;
  81096. private _collisionGroup;
  81097. /**
  81098. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81100. */
  81101. ellipsoid: Vector3;
  81102. /**
  81103. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81104. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81105. */
  81106. ellipsoidOffset: Vector3;
  81107. private _collider;
  81108. private _oldPositionForCollisions;
  81109. private _diffPositionForCollisions;
  81110. /**
  81111. * Gets or sets a collision mask used to mask collisions (default is -1).
  81112. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81113. */
  81114. collisionMask: number;
  81115. /**
  81116. * Gets or sets the current collision group mask (-1 by default).
  81117. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81118. */
  81119. collisionGroup: number;
  81120. /**
  81121. * Defines edge width used when edgesRenderer is enabled
  81122. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81123. */
  81124. edgesWidth: number;
  81125. /**
  81126. * Defines edge color used when edgesRenderer is enabled
  81127. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81128. */
  81129. edgesColor: Color4;
  81130. /** @hidden */
  81131. _edgesRenderer: Nullable<IEdgesRenderer>;
  81132. /** @hidden */
  81133. _masterMesh: Nullable<AbstractMesh>;
  81134. /** @hidden */
  81135. _boundingInfo: Nullable<BoundingInfo>;
  81136. /** @hidden */
  81137. _renderId: number;
  81138. /**
  81139. * Gets or sets the list of subMeshes
  81140. * @see http://doc.babylonjs.com/how_to/multi_materials
  81141. */
  81142. subMeshes: SubMesh[];
  81143. /** @hidden */
  81144. _intersectionsInProgress: AbstractMesh[];
  81145. /** @hidden */
  81146. _unIndexed: boolean;
  81147. /** @hidden */
  81148. _lightSources: Light[];
  81149. /** @hidden */
  81150. readonly _positions: Nullable<Vector3[]>;
  81151. /** @hidden */
  81152. _waitingActions: any;
  81153. /** @hidden */
  81154. _waitingFreezeWorldMatrix: Nullable<boolean>;
  81155. private _skeleton;
  81156. /** @hidden */
  81157. _bonesTransformMatrices: Nullable<Float32Array>;
  81158. /**
  81159. * Gets or sets a skeleton to apply skining transformations
  81160. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81161. */
  81162. skeleton: Nullable<Skeleton>;
  81163. /**
  81164. * An event triggered when the mesh is rebuilt.
  81165. */
  81166. onRebuildObservable: Observable<AbstractMesh>;
  81167. /**
  81168. * Creates a new AbstractMesh
  81169. * @param name defines the name of the mesh
  81170. * @param scene defines the hosting scene
  81171. */
  81172. constructor(name: string, scene?: Nullable<Scene>);
  81173. /**
  81174. * Returns the string "AbstractMesh"
  81175. * @returns "AbstractMesh"
  81176. */
  81177. getClassName(): string;
  81178. /**
  81179. * Gets a string representation of the current mesh
  81180. * @param fullDetails defines a boolean indicating if full details must be included
  81181. * @returns a string representation of the current mesh
  81182. */
  81183. toString(fullDetails?: boolean): string;
  81184. /** @hidden */
  81185. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81186. /** @hidden */
  81187. _rebuild(): void;
  81188. /** @hidden */
  81189. _resyncLightSources(): void;
  81190. /** @hidden */
  81191. _resyncLighSource(light: Light): void;
  81192. /** @hidden */
  81193. _unBindEffect(): void;
  81194. /** @hidden */
  81195. _removeLightSource(light: Light): void;
  81196. private _markSubMeshesAsDirty;
  81197. /** @hidden */
  81198. _markSubMeshesAsLightDirty(): void;
  81199. /** @hidden */
  81200. _markSubMeshesAsAttributesDirty(): void;
  81201. /** @hidden */
  81202. _markSubMeshesAsMiscDirty(): void;
  81203. /**
  81204. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81205. */
  81206. scaling: Vector3;
  81207. /**
  81208. * Returns true if the mesh is blocked. Implemented by child classes
  81209. */
  81210. readonly isBlocked: boolean;
  81211. /**
  81212. * Returns the mesh itself by default. Implemented by child classes
  81213. * @param camera defines the camera to use to pick the right LOD level
  81214. * @returns the currentAbstractMesh
  81215. */
  81216. getLOD(camera: Camera): Nullable<AbstractMesh>;
  81217. /**
  81218. * Returns 0 by default. Implemented by child classes
  81219. * @returns an integer
  81220. */
  81221. getTotalVertices(): number;
  81222. /**
  81223. * Returns a positive integer : the total number of indices in this mesh geometry.
  81224. * @returns the numner of indices or zero if the mesh has no geometry.
  81225. */
  81226. getTotalIndices(): number;
  81227. /**
  81228. * Returns null by default. Implemented by child classes
  81229. * @returns null
  81230. */
  81231. getIndices(): Nullable<IndicesArray>;
  81232. /**
  81233. * Returns the array of the requested vertex data kind. Implemented by child classes
  81234. * @param kind defines the vertex data kind to use
  81235. * @returns null
  81236. */
  81237. getVerticesData(kind: string): Nullable<FloatArray>;
  81238. /**
  81239. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81240. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81241. * Note that a new underlying VertexBuffer object is created each call.
  81242. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81243. * @param kind defines vertex data kind:
  81244. * * VertexBuffer.PositionKind
  81245. * * VertexBuffer.UVKind
  81246. * * VertexBuffer.UV2Kind
  81247. * * VertexBuffer.UV3Kind
  81248. * * VertexBuffer.UV4Kind
  81249. * * VertexBuffer.UV5Kind
  81250. * * VertexBuffer.UV6Kind
  81251. * * VertexBuffer.ColorKind
  81252. * * VertexBuffer.MatricesIndicesKind
  81253. * * VertexBuffer.MatricesIndicesExtraKind
  81254. * * VertexBuffer.MatricesWeightsKind
  81255. * * VertexBuffer.MatricesWeightsExtraKind
  81256. * @param data defines the data source
  81257. * @param updatable defines if the data must be flagged as updatable (or static)
  81258. * @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
  81259. * @returns the current mesh
  81260. */
  81261. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81262. /**
  81263. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81264. * If the mesh has no geometry, it is simply returned as it is.
  81265. * @param kind defines vertex data kind:
  81266. * * VertexBuffer.PositionKind
  81267. * * VertexBuffer.UVKind
  81268. * * VertexBuffer.UV2Kind
  81269. * * VertexBuffer.UV3Kind
  81270. * * VertexBuffer.UV4Kind
  81271. * * VertexBuffer.UV5Kind
  81272. * * VertexBuffer.UV6Kind
  81273. * * VertexBuffer.ColorKind
  81274. * * VertexBuffer.MatricesIndicesKind
  81275. * * VertexBuffer.MatricesIndicesExtraKind
  81276. * * VertexBuffer.MatricesWeightsKind
  81277. * * VertexBuffer.MatricesWeightsExtraKind
  81278. * @param data defines the data source
  81279. * @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
  81280. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81281. * @returns the current mesh
  81282. */
  81283. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81284. /**
  81285. * Sets the mesh indices,
  81286. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81287. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81288. * @param totalVertices Defines the total number of vertices
  81289. * @returns the current mesh
  81290. */
  81291. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81292. /**
  81293. * Gets a boolean indicating if specific vertex data is present
  81294. * @param kind defines the vertex data kind to use
  81295. * @returns true is data kind is present
  81296. */
  81297. isVerticesDataPresent(kind: string): boolean;
  81298. /**
  81299. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81300. * @returns a BoundingInfo
  81301. */
  81302. getBoundingInfo(): BoundingInfo;
  81303. /**
  81304. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81305. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81306. * @returns the current mesh
  81307. */
  81308. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81309. /**
  81310. * Overwrite the current bounding info
  81311. * @param boundingInfo defines the new bounding info
  81312. * @returns the current mesh
  81313. */
  81314. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81315. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81316. readonly useBones: boolean;
  81317. /** @hidden */
  81318. _preActivate(): void;
  81319. /** @hidden */
  81320. _preActivateForIntermediateRendering(renderId: number): void;
  81321. /** @hidden */
  81322. _activate(renderId: number): void;
  81323. /**
  81324. * Gets the current world matrix
  81325. * @returns a Matrix
  81326. */
  81327. getWorldMatrix(): Matrix;
  81328. /** @hidden */
  81329. _getWorldMatrixDeterminant(): number;
  81330. /**
  81331. * Perform relative position change from the point of view of behind the front of the mesh.
  81332. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81333. * Supports definition of mesh facing forward or backward
  81334. * @param amountRight defines the distance on the right axis
  81335. * @param amountUp defines the distance on the up axis
  81336. * @param amountForward defines the distance on the forward axis
  81337. * @returns the current mesh
  81338. */
  81339. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81340. /**
  81341. * Calculate relative position change from the point of view of behind the front of the mesh.
  81342. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81343. * Supports definition of mesh facing forward or backward
  81344. * @param amountRight defines the distance on the right axis
  81345. * @param amountUp defines the distance on the up axis
  81346. * @param amountForward defines the distance on the forward axis
  81347. * @returns the new displacement vector
  81348. */
  81349. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81350. /**
  81351. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81352. * Supports definition of mesh facing forward or backward
  81353. * @param flipBack defines the flip
  81354. * @param twirlClockwise defines the twirl
  81355. * @param tiltRight defines the tilt
  81356. * @returns the current mesh
  81357. */
  81358. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81359. /**
  81360. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81361. * Supports definition of mesh facing forward or backward.
  81362. * @param flipBack defines the flip
  81363. * @param twirlClockwise defines the twirl
  81364. * @param tiltRight defines the tilt
  81365. * @returns the new rotation vector
  81366. */
  81367. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81368. /**
  81369. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81370. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81371. * @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
  81372. * @returns the new bounding vectors
  81373. */
  81374. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81375. min: Vector3;
  81376. max: Vector3;
  81377. };
  81378. /**
  81379. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81380. * This means the mesh underlying bounding box and sphere are recomputed.
  81381. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81382. * @returns the current mesh
  81383. */
  81384. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81385. /** @hidden */
  81386. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81387. /** @hidden */
  81388. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81389. /** @hidden */
  81390. _updateBoundingInfo(): AbstractMesh;
  81391. /** @hidden */
  81392. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81393. /** @hidden */
  81394. protected _afterComputeWorldMatrix(): void;
  81395. /**
  81396. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81397. * A mesh is in the frustum if its bounding box intersects the frustum
  81398. * @param frustumPlanes defines the frustum to test
  81399. * @returns true if the mesh is in the frustum planes
  81400. */
  81401. isInFrustum(frustumPlanes: Plane[]): boolean;
  81402. /**
  81403. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81404. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81405. * @param frustumPlanes defines the frustum to test
  81406. * @returns true if the mesh is completely in the frustum planes
  81407. */
  81408. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81409. /**
  81410. * True if the mesh intersects another mesh or a SolidParticle object
  81411. * @param mesh defines a target mesh or SolidParticle to test
  81412. * @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)
  81413. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81414. * @returns true if there is an intersection
  81415. */
  81416. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81417. /**
  81418. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81419. * @param point defines the point to test
  81420. * @returns true if there is an intersection
  81421. */
  81422. intersectsPoint(point: Vector3): boolean;
  81423. /**
  81424. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81425. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81426. */
  81427. checkCollisions: boolean;
  81428. /**
  81429. * Gets Collider object used to compute collisions (not physics)
  81430. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81431. */
  81432. readonly collider: Collider;
  81433. /**
  81434. * Move the mesh using collision engine
  81435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81436. * @param displacement defines the requested displacement vector
  81437. * @returns the current mesh
  81438. */
  81439. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81440. private _onCollisionPositionChange;
  81441. /** @hidden */
  81442. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81443. /** @hidden */
  81444. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81445. /** @hidden */
  81446. _checkCollision(collider: Collider): AbstractMesh;
  81447. /** @hidden */
  81448. _generatePointsArray(): boolean;
  81449. /**
  81450. * Checks if the passed Ray intersects with the mesh
  81451. * @param ray defines the ray to use
  81452. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81453. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81454. * @returns the picking info
  81455. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81456. */
  81457. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81458. /**
  81459. * Clones the current mesh
  81460. * @param name defines the mesh name
  81461. * @param newParent defines the new mesh parent
  81462. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81463. * @returns the new mesh
  81464. */
  81465. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81466. /**
  81467. * Disposes all the submeshes of the current meshnp
  81468. * @returns the current mesh
  81469. */
  81470. releaseSubMeshes(): AbstractMesh;
  81471. /**
  81472. * Releases resources associated with this abstract mesh.
  81473. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81474. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81475. */
  81476. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81477. /**
  81478. * Adds the passed mesh as a child to the current mesh
  81479. * @param mesh defines the child mesh
  81480. * @returns the current mesh
  81481. */
  81482. addChild(mesh: AbstractMesh): AbstractMesh;
  81483. /**
  81484. * Removes the passed mesh from the current mesh children list
  81485. * @param mesh defines the child mesh
  81486. * @returns the current mesh
  81487. */
  81488. removeChild(mesh: AbstractMesh): AbstractMesh;
  81489. /** @hidden */
  81490. private _initFacetData;
  81491. /**
  81492. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81493. * This method can be called within the render loop.
  81494. * 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
  81495. * @returns the current mesh
  81496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81497. */
  81498. updateFacetData(): AbstractMesh;
  81499. /**
  81500. * Returns the facetLocalNormals array.
  81501. * The normals are expressed in the mesh local spac
  81502. * @returns an array of Vector3
  81503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81504. */
  81505. getFacetLocalNormals(): Vector3[];
  81506. /**
  81507. * Returns the facetLocalPositions array.
  81508. * The facet positions are expressed in the mesh local space
  81509. * @returns an array of Vector3
  81510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81511. */
  81512. getFacetLocalPositions(): Vector3[];
  81513. /**
  81514. * Returns the facetLocalPartioning array
  81515. * @returns an array of array of numbers
  81516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81517. */
  81518. getFacetLocalPartitioning(): number[][];
  81519. /**
  81520. * Returns the i-th facet position in the world system.
  81521. * This method allocates a new Vector3 per call
  81522. * @param i defines the facet index
  81523. * @returns a new Vector3
  81524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81525. */
  81526. getFacetPosition(i: number): Vector3;
  81527. /**
  81528. * Sets the reference Vector3 with the i-th facet position in the world system
  81529. * @param i defines the facet index
  81530. * @param ref defines the target vector
  81531. * @returns the current mesh
  81532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81533. */
  81534. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81535. /**
  81536. * Returns the i-th facet normal in the world system.
  81537. * This method allocates a new Vector3 per call
  81538. * @param i defines the facet index
  81539. * @returns a new Vector3
  81540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81541. */
  81542. getFacetNormal(i: number): Vector3;
  81543. /**
  81544. * Sets the reference Vector3 with the i-th facet normal in the world system
  81545. * @param i defines the facet index
  81546. * @param ref defines the target vector
  81547. * @returns the current mesh
  81548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81549. */
  81550. getFacetNormalToRef(i: number, ref: Vector3): this;
  81551. /**
  81552. * 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)
  81553. * @param x defines x coordinate
  81554. * @param y defines y coordinate
  81555. * @param z defines z coordinate
  81556. * @returns the array of facet indexes
  81557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81558. */
  81559. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81560. /**
  81561. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81562. * @param projected sets as the (x,y,z) world projection on the facet
  81563. * @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
  81564. * @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
  81565. * @param x defines x coordinate
  81566. * @param y defines y coordinate
  81567. * @param z defines z coordinate
  81568. * @returns the face index if found (or null instead)
  81569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81570. */
  81571. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81572. /**
  81573. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81574. * @param projected sets as the (x,y,z) local projection on the facet
  81575. * @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
  81576. * @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
  81577. * @param x defines x coordinate
  81578. * @param y defines y coordinate
  81579. * @param z defines z coordinate
  81580. * @returns the face index if found (or null instead)
  81581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81582. */
  81583. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81584. /**
  81585. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81586. * @returns the parameters
  81587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81588. */
  81589. getFacetDataParameters(): any;
  81590. /**
  81591. * Disables the feature FacetData and frees the related memory
  81592. * @returns the current mesh
  81593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81594. */
  81595. disableFacetData(): AbstractMesh;
  81596. /**
  81597. * Updates the AbstractMesh indices array
  81598. * @param indices defines the data source
  81599. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81600. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  81601. * @returns the current mesh
  81602. */
  81603. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  81604. /**
  81605. * Creates new normals data for the mesh
  81606. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81607. * @returns the current mesh
  81608. */
  81609. createNormals(updatable: boolean): AbstractMesh;
  81610. /**
  81611. * Align the mesh with a normal
  81612. * @param normal defines the normal to use
  81613. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81614. * @returns the current mesh
  81615. */
  81616. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81617. /** @hidden */
  81618. _checkOcclusionQuery(): boolean;
  81619. }
  81620. }
  81621. declare module BABYLON {
  81622. /**
  81623. * Interface used to define ActionEvent
  81624. */
  81625. export interface IActionEvent {
  81626. /** The mesh or sprite that triggered the action */
  81627. source: any;
  81628. /** The X mouse cursor position at the time of the event */
  81629. pointerX: number;
  81630. /** The Y mouse cursor position at the time of the event */
  81631. pointerY: number;
  81632. /** The mesh that is currently pointed at (can be null) */
  81633. meshUnderPointer: Nullable<AbstractMesh>;
  81634. /** the original (browser) event that triggered the ActionEvent */
  81635. sourceEvent?: any;
  81636. /** additional data for the event */
  81637. additionalData?: any;
  81638. }
  81639. /**
  81640. * ActionEvent is the event being sent when an action is triggered.
  81641. */
  81642. export class ActionEvent implements IActionEvent {
  81643. /** The mesh or sprite that triggered the action */
  81644. source: any;
  81645. /** The X mouse cursor position at the time of the event */
  81646. pointerX: number;
  81647. /** The Y mouse cursor position at the time of the event */
  81648. pointerY: number;
  81649. /** The mesh that is currently pointed at (can be null) */
  81650. meshUnderPointer: Nullable<AbstractMesh>;
  81651. /** the original (browser) event that triggered the ActionEvent */
  81652. sourceEvent?: any;
  81653. /** additional data for the event */
  81654. additionalData?: any;
  81655. /**
  81656. * Creates a new ActionEvent
  81657. * @param source The mesh or sprite that triggered the action
  81658. * @param pointerX The X mouse cursor position at the time of the event
  81659. * @param pointerY The Y mouse cursor position at the time of the event
  81660. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81661. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81662. * @param additionalData additional data for the event
  81663. */
  81664. constructor(
  81665. /** The mesh or sprite that triggered the action */
  81666. source: any,
  81667. /** The X mouse cursor position at the time of the event */
  81668. pointerX: number,
  81669. /** The Y mouse cursor position at the time of the event */
  81670. pointerY: number,
  81671. /** The mesh that is currently pointed at (can be null) */
  81672. meshUnderPointer: Nullable<AbstractMesh>,
  81673. /** the original (browser) event that triggered the ActionEvent */
  81674. sourceEvent?: any,
  81675. /** additional data for the event */
  81676. additionalData?: any);
  81677. /**
  81678. * Helper function to auto-create an ActionEvent from a source mesh.
  81679. * @param source The source mesh that triggered the event
  81680. * @param evt The original (browser) event
  81681. * @param additionalData additional data for the event
  81682. * @returns the new ActionEvent
  81683. */
  81684. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81685. /**
  81686. * Helper function to auto-create an ActionEvent from a source sprite
  81687. * @param source The source sprite that triggered the event
  81688. * @param scene Scene associated with the sprite
  81689. * @param evt The original (browser) event
  81690. * @param additionalData additional data for the event
  81691. * @returns the new ActionEvent
  81692. */
  81693. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81694. /**
  81695. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81696. * @param scene the scene where the event occurred
  81697. * @param evt The original (browser) event
  81698. * @returns the new ActionEvent
  81699. */
  81700. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81701. /**
  81702. * Helper function to auto-create an ActionEvent from a primitive
  81703. * @param prim defines the target primitive
  81704. * @param pointerPos defines the pointer position
  81705. * @param evt The original (browser) event
  81706. * @param additionalData additional data for the event
  81707. * @returns the new ActionEvent
  81708. */
  81709. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81710. }
  81711. }
  81712. declare module BABYLON {
  81713. /**
  81714. * Abstract class used to decouple action Manager from scene and meshes.
  81715. * Do not instantiate.
  81716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81717. */
  81718. export abstract class AbstractActionManager implements IDisposable {
  81719. /** Gets the list of active triggers */
  81720. static Triggers: {
  81721. [key: string]: number;
  81722. };
  81723. /** Gets the cursor to use when hovering items */
  81724. hoverCursor: string;
  81725. /** Gets the list of actions */
  81726. actions: IAction[];
  81727. /**
  81728. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81729. */
  81730. isRecursive: boolean;
  81731. /**
  81732. * Releases all associated resources
  81733. */
  81734. abstract dispose(): void;
  81735. /**
  81736. * Does this action manager has pointer triggers
  81737. */
  81738. abstract readonly hasPointerTriggers: boolean;
  81739. /**
  81740. * Does this action manager has pick triggers
  81741. */
  81742. abstract readonly hasPickTriggers: boolean;
  81743. /**
  81744. * Process a specific trigger
  81745. * @param trigger defines the trigger to process
  81746. * @param evt defines the event details to be processed
  81747. */
  81748. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81749. /**
  81750. * Does this action manager handles actions of any of the given triggers
  81751. * @param triggers defines the triggers to be tested
  81752. * @return a boolean indicating whether one (or more) of the triggers is handled
  81753. */
  81754. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81755. /**
  81756. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81757. * speed.
  81758. * @param triggerA defines the trigger to be tested
  81759. * @param triggerB defines the trigger to be tested
  81760. * @return a boolean indicating whether one (or more) of the triggers is handled
  81761. */
  81762. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81763. /**
  81764. * Does this action manager handles actions of a given trigger
  81765. * @param trigger defines the trigger to be tested
  81766. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81767. * @return whether the trigger is handled
  81768. */
  81769. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81770. /**
  81771. * Serialize this manager to a JSON object
  81772. * @param name defines the property name to store this manager
  81773. * @returns a JSON representation of this manager
  81774. */
  81775. abstract serialize(name: string): any;
  81776. /**
  81777. * Registers an action to this action manager
  81778. * @param action defines the action to be registered
  81779. * @return the action amended (prepared) after registration
  81780. */
  81781. abstract registerAction(action: IAction): Nullable<IAction>;
  81782. /**
  81783. * Unregisters an action to this action manager
  81784. * @param action defines the action to be unregistered
  81785. * @return a boolean indicating whether the action has been unregistered
  81786. */
  81787. abstract unregisterAction(action: IAction): Boolean;
  81788. /**
  81789. * Does exist one action manager with at least one trigger
  81790. **/
  81791. static readonly HasTriggers: boolean;
  81792. /**
  81793. * Does exist one action manager with at least one pick trigger
  81794. **/
  81795. static readonly HasPickTriggers: boolean;
  81796. /**
  81797. * Does exist one action manager that handles actions of a given trigger
  81798. * @param trigger defines the trigger to be tested
  81799. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81800. **/
  81801. static HasSpecificTrigger(trigger: number): boolean;
  81802. }
  81803. }
  81804. declare module BABYLON {
  81805. /**
  81806. * Defines how a node can be built from a string name.
  81807. */
  81808. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81809. /**
  81810. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81811. */
  81812. export class Node implements IBehaviorAware<Node> {
  81813. /** @hidden */
  81814. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81815. private static _NodeConstructors;
  81816. /**
  81817. * Add a new node constructor
  81818. * @param type defines the type name of the node to construct
  81819. * @param constructorFunc defines the constructor function
  81820. */
  81821. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81822. /**
  81823. * Returns a node constructor based on type name
  81824. * @param type defines the type name
  81825. * @param name defines the new node name
  81826. * @param scene defines the hosting scene
  81827. * @param options defines optional options to transmit to constructors
  81828. * @returns the new constructor or null
  81829. */
  81830. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81831. /**
  81832. * Gets or sets the name of the node
  81833. */
  81834. name: string;
  81835. /**
  81836. * Gets or sets the id of the node
  81837. */
  81838. id: string;
  81839. /**
  81840. * Gets or sets the unique id of the node
  81841. */
  81842. uniqueId: number;
  81843. /**
  81844. * Gets or sets a string used to store user defined state for the node
  81845. */
  81846. state: string;
  81847. /**
  81848. * Gets or sets an object used to store user defined information for the node
  81849. */
  81850. metadata: any;
  81851. /**
  81852. * For internal use only. Please do not use.
  81853. */
  81854. reservedDataStore: any;
  81855. /**
  81856. * Gets or sets a boolean used to define if the node must be serialized
  81857. */
  81858. doNotSerialize: boolean;
  81859. /** @hidden */
  81860. _isDisposed: boolean;
  81861. /**
  81862. * Gets a list of Animations associated with the node
  81863. */
  81864. animations: Animation[];
  81865. protected _ranges: {
  81866. [name: string]: Nullable<AnimationRange>;
  81867. };
  81868. /**
  81869. * Callback raised when the node is ready to be used
  81870. */
  81871. onReady: (node: Node) => void;
  81872. private _isEnabled;
  81873. private _isParentEnabled;
  81874. private _isReady;
  81875. /** @hidden */
  81876. _currentRenderId: number;
  81877. private _parentRenderId;
  81878. protected _childRenderId: number;
  81879. /** @hidden */
  81880. _waitingParentId: Nullable<string>;
  81881. /** @hidden */
  81882. _scene: Scene;
  81883. /** @hidden */
  81884. _cache: any;
  81885. private _parentNode;
  81886. private _children;
  81887. /** @hidden */
  81888. _worldMatrix: Matrix;
  81889. /** @hidden */
  81890. _worldMatrixDeterminant: number;
  81891. /** @hidden */
  81892. private _sceneRootNodesIndex;
  81893. /**
  81894. * Gets a boolean indicating if the node has been disposed
  81895. * @returns true if the node was disposed
  81896. */
  81897. isDisposed(): boolean;
  81898. /**
  81899. * Gets or sets the parent of the node
  81900. */
  81901. parent: Nullable<Node>;
  81902. private addToSceneRootNodes;
  81903. private removeFromSceneRootNodes;
  81904. private _animationPropertiesOverride;
  81905. /**
  81906. * Gets or sets the animation properties override
  81907. */
  81908. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81909. /**
  81910. * Gets a string idenfifying the name of the class
  81911. * @returns "Node" string
  81912. */
  81913. getClassName(): string;
  81914. /** @hidden */
  81915. readonly _isNode: boolean;
  81916. /**
  81917. * An event triggered when the mesh is disposed
  81918. */
  81919. onDisposeObservable: Observable<Node>;
  81920. private _onDisposeObserver;
  81921. /**
  81922. * Sets a callback that will be raised when the node will be disposed
  81923. */
  81924. onDispose: () => void;
  81925. /**
  81926. * Creates a new Node
  81927. * @param name the name and id to be given to this node
  81928. * @param scene the scene this node will be added to
  81929. * @param addToRootNodes the node will be added to scene.rootNodes
  81930. */
  81931. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81932. /**
  81933. * Gets the scene of the node
  81934. * @returns a scene
  81935. */
  81936. getScene(): Scene;
  81937. /**
  81938. * Gets the engine of the node
  81939. * @returns a Engine
  81940. */
  81941. getEngine(): Engine;
  81942. private _behaviors;
  81943. /**
  81944. * Attach a behavior to the node
  81945. * @see http://doc.babylonjs.com/features/behaviour
  81946. * @param behavior defines the behavior to attach
  81947. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81948. * @returns the current Node
  81949. */
  81950. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81951. /**
  81952. * Remove an attached behavior
  81953. * @see http://doc.babylonjs.com/features/behaviour
  81954. * @param behavior defines the behavior to attach
  81955. * @returns the current Node
  81956. */
  81957. removeBehavior(behavior: Behavior<Node>): Node;
  81958. /**
  81959. * Gets the list of attached behaviors
  81960. * @see http://doc.babylonjs.com/features/behaviour
  81961. */
  81962. readonly behaviors: Behavior<Node>[];
  81963. /**
  81964. * Gets an attached behavior by name
  81965. * @param name defines the name of the behavior to look for
  81966. * @see http://doc.babylonjs.com/features/behaviour
  81967. * @returns null if behavior was not found else the requested behavior
  81968. */
  81969. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81970. /**
  81971. * Returns the latest update of the World matrix
  81972. * @returns a Matrix
  81973. */
  81974. getWorldMatrix(): Matrix;
  81975. /** @hidden */
  81976. _getWorldMatrixDeterminant(): number;
  81977. /**
  81978. * Returns directly the latest state of the mesh World matrix.
  81979. * A Matrix is returned.
  81980. */
  81981. readonly worldMatrixFromCache: Matrix;
  81982. /** @hidden */
  81983. _initCache(): void;
  81984. /** @hidden */
  81985. updateCache(force?: boolean): void;
  81986. /** @hidden */
  81987. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81988. /** @hidden */
  81989. _updateCache(ignoreParentClass?: boolean): void;
  81990. /** @hidden */
  81991. _isSynchronized(): boolean;
  81992. /** @hidden */
  81993. _markSyncedWithParent(): void;
  81994. /** @hidden */
  81995. isSynchronizedWithParent(): boolean;
  81996. /** @hidden */
  81997. isSynchronized(): boolean;
  81998. /**
  81999. * Is this node ready to be used/rendered
  82000. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82001. * @return true if the node is ready
  82002. */
  82003. isReady(completeCheck?: boolean): boolean;
  82004. /**
  82005. * Is this node enabled?
  82006. * 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
  82007. * @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
  82008. * @return whether this node (and its parent) is enabled
  82009. */
  82010. isEnabled(checkAncestors?: boolean): boolean;
  82011. /** @hidden */
  82012. protected _syncParentEnabledState(): void;
  82013. /**
  82014. * Set the enabled state of this node
  82015. * @param value defines the new enabled state
  82016. */
  82017. setEnabled(value: boolean): void;
  82018. /**
  82019. * Is this node a descendant of the given node?
  82020. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  82021. * @param ancestor defines the parent node to inspect
  82022. * @returns a boolean indicating if this node is a descendant of the given node
  82023. */
  82024. isDescendantOf(ancestor: Node): boolean;
  82025. /** @hidden */
  82026. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  82027. /**
  82028. * Will return all nodes that have this node as ascendant
  82029. * @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
  82030. * @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
  82031. * @return all children nodes of all types
  82032. */
  82033. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  82034. /**
  82035. * Get all child-meshes of this node
  82036. * @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)
  82037. * @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
  82038. * @returns an array of AbstractMesh
  82039. */
  82040. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  82041. /**
  82042. * Get all direct children of this node
  82043. * @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
  82044. * @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)
  82045. * @returns an array of Node
  82046. */
  82047. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  82048. /** @hidden */
  82049. _setReady(state: boolean): void;
  82050. /**
  82051. * Get an animation by name
  82052. * @param name defines the name of the animation to look for
  82053. * @returns null if not found else the requested animation
  82054. */
  82055. getAnimationByName(name: string): Nullable<Animation>;
  82056. /**
  82057. * Creates an animation range for this node
  82058. * @param name defines the name of the range
  82059. * @param from defines the starting key
  82060. * @param to defines the end key
  82061. */
  82062. createAnimationRange(name: string, from: number, to: number): void;
  82063. /**
  82064. * Delete a specific animation range
  82065. * @param name defines the name of the range to delete
  82066. * @param deleteFrames defines if animation frames from the range must be deleted as well
  82067. */
  82068. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82069. /**
  82070. * Get an animation range by name
  82071. * @param name defines the name of the animation range to look for
  82072. * @returns null if not found else the requested animation range
  82073. */
  82074. getAnimationRange(name: string): Nullable<AnimationRange>;
  82075. /**
  82076. * Gets the list of all animation ranges defined on this node
  82077. * @returns an array
  82078. */
  82079. getAnimationRanges(): Nullable<AnimationRange>[];
  82080. /**
  82081. * Will start the animation sequence
  82082. * @param name defines the range frames for animation sequence
  82083. * @param loop defines if the animation should loop (false by default)
  82084. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  82085. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  82086. * @returns the object created for this animation. If range does not exist, it will return null
  82087. */
  82088. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82089. /**
  82090. * Serialize animation ranges into a JSON compatible object
  82091. * @returns serialization object
  82092. */
  82093. serializeAnimationRanges(): any;
  82094. /**
  82095. * Computes the world matrix of the node
  82096. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82097. * @returns the world matrix
  82098. */
  82099. computeWorldMatrix(force?: boolean): Matrix;
  82100. /**
  82101. * Releases resources associated with this node.
  82102. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82103. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82104. */
  82105. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82106. /**
  82107. * Parse animation range data from a serialization object and store them into a given node
  82108. * @param node defines where to store the animation ranges
  82109. * @param parsedNode defines the serialization object to read data from
  82110. * @param scene defines the hosting scene
  82111. */
  82112. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  82113. }
  82114. }
  82115. declare module BABYLON {
  82116. /**
  82117. * Class used to store any kind of animation
  82118. */
  82119. export class Animation {
  82120. /**Name of the animation */
  82121. name: string;
  82122. /**Property to animate */
  82123. targetProperty: string;
  82124. /**The frames per second of the animation */
  82125. framePerSecond: number;
  82126. /**The data type of the animation */
  82127. dataType: number;
  82128. /**The loop mode of the animation */
  82129. loopMode?: number | undefined;
  82130. /**Specifies if blending should be enabled */
  82131. enableBlending?: boolean | undefined;
  82132. /**
  82133. * Use matrix interpolation instead of using direct key value when animating matrices
  82134. */
  82135. static AllowMatricesInterpolation: boolean;
  82136. /**
  82137. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  82138. */
  82139. static AllowMatrixDecomposeForInterpolation: boolean;
  82140. /**
  82141. * Stores the key frames of the animation
  82142. */
  82143. private _keys;
  82144. /**
  82145. * Stores the easing function of the animation
  82146. */
  82147. private _easingFunction;
  82148. /**
  82149. * @hidden Internal use only
  82150. */
  82151. _runtimeAnimations: RuntimeAnimation[];
  82152. /**
  82153. * The set of event that will be linked to this animation
  82154. */
  82155. private _events;
  82156. /**
  82157. * Stores an array of target property paths
  82158. */
  82159. targetPropertyPath: string[];
  82160. /**
  82161. * Stores the blending speed of the animation
  82162. */
  82163. blendingSpeed: number;
  82164. /**
  82165. * Stores the animation ranges for the animation
  82166. */
  82167. private _ranges;
  82168. /**
  82169. * @hidden Internal use
  82170. */
  82171. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  82172. /**
  82173. * Sets up an animation
  82174. * @param property The property to animate
  82175. * @param animationType The animation type to apply
  82176. * @param framePerSecond The frames per second of the animation
  82177. * @param easingFunction The easing function used in the animation
  82178. * @returns The created animation
  82179. */
  82180. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  82181. /**
  82182. * Create and start an animation on a node
  82183. * @param name defines the name of the global animation that will be run on all nodes
  82184. * @param node defines the root node where the animation will take place
  82185. * @param targetProperty defines property to animate
  82186. * @param framePerSecond defines the number of frame per second yo use
  82187. * @param totalFrame defines the number of frames in total
  82188. * @param from defines the initial value
  82189. * @param to defines the final value
  82190. * @param loopMode defines which loop mode you want to use (off by default)
  82191. * @param easingFunction defines the easing function to use (linear by default)
  82192. * @param onAnimationEnd defines the callback to call when animation end
  82193. * @returns the animatable created for this animation
  82194. */
  82195. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82196. /**
  82197. * Create and start an animation on a node and its descendants
  82198. * @param name defines the name of the global animation that will be run on all nodes
  82199. * @param node defines the root node where the animation will take place
  82200. * @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
  82201. * @param targetProperty defines property to animate
  82202. * @param framePerSecond defines the number of frame per second to use
  82203. * @param totalFrame defines the number of frames in total
  82204. * @param from defines the initial value
  82205. * @param to defines the final value
  82206. * @param loopMode defines which loop mode you want to use (off by default)
  82207. * @param easingFunction defines the easing function to use (linear by default)
  82208. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82209. * @returns the list of animatables created for all nodes
  82210. * @example https://www.babylonjs-playground.com/#MH0VLI
  82211. */
  82212. 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[]>;
  82213. /**
  82214. * Creates a new animation, merges it with the existing animations and starts it
  82215. * @param name Name of the animation
  82216. * @param node Node which contains the scene that begins the animations
  82217. * @param targetProperty Specifies which property to animate
  82218. * @param framePerSecond The frames per second of the animation
  82219. * @param totalFrame The total number of frames
  82220. * @param from The frame at the beginning of the animation
  82221. * @param to The frame at the end of the animation
  82222. * @param loopMode Specifies the loop mode of the animation
  82223. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82224. * @param onAnimationEnd Callback to run once the animation is complete
  82225. * @returns Nullable animation
  82226. */
  82227. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82228. /**
  82229. * Transition property of an host to the target Value
  82230. * @param property The property to transition
  82231. * @param targetValue The target Value of the property
  82232. * @param host The object where the property to animate belongs
  82233. * @param scene Scene used to run the animation
  82234. * @param frameRate Framerate (in frame/s) to use
  82235. * @param transition The transition type we want to use
  82236. * @param duration The duration of the animation, in milliseconds
  82237. * @param onAnimationEnd Callback trigger at the end of the animation
  82238. * @returns Nullable animation
  82239. */
  82240. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82241. /**
  82242. * Return the array of runtime animations currently using this animation
  82243. */
  82244. readonly runtimeAnimations: RuntimeAnimation[];
  82245. /**
  82246. * Specifies if any of the runtime animations are currently running
  82247. */
  82248. readonly hasRunningRuntimeAnimations: boolean;
  82249. /**
  82250. * Initializes the animation
  82251. * @param name Name of the animation
  82252. * @param targetProperty Property to animate
  82253. * @param framePerSecond The frames per second of the animation
  82254. * @param dataType The data type of the animation
  82255. * @param loopMode The loop mode of the animation
  82256. * @param enableBlending Specifies if blending should be enabled
  82257. */
  82258. constructor(
  82259. /**Name of the animation */
  82260. name: string,
  82261. /**Property to animate */
  82262. targetProperty: string,
  82263. /**The frames per second of the animation */
  82264. framePerSecond: number,
  82265. /**The data type of the animation */
  82266. dataType: number,
  82267. /**The loop mode of the animation */
  82268. loopMode?: number | undefined,
  82269. /**Specifies if blending should be enabled */
  82270. enableBlending?: boolean | undefined);
  82271. /**
  82272. * Converts the animation to a string
  82273. * @param fullDetails support for multiple levels of logging within scene loading
  82274. * @returns String form of the animation
  82275. */
  82276. toString(fullDetails?: boolean): string;
  82277. /**
  82278. * Add an event to this animation
  82279. * @param event Event to add
  82280. */
  82281. addEvent(event: AnimationEvent): void;
  82282. /**
  82283. * Remove all events found at the given frame
  82284. * @param frame The frame to remove events from
  82285. */
  82286. removeEvents(frame: number): void;
  82287. /**
  82288. * Retrieves all the events from the animation
  82289. * @returns Events from the animation
  82290. */
  82291. getEvents(): AnimationEvent[];
  82292. /**
  82293. * Creates an animation range
  82294. * @param name Name of the animation range
  82295. * @param from Starting frame of the animation range
  82296. * @param to Ending frame of the animation
  82297. */
  82298. createRange(name: string, from: number, to: number): void;
  82299. /**
  82300. * Deletes an animation range by name
  82301. * @param name Name of the animation range to delete
  82302. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82303. */
  82304. deleteRange(name: string, deleteFrames?: boolean): void;
  82305. /**
  82306. * Gets the animation range by name, or null if not defined
  82307. * @param name Name of the animation range
  82308. * @returns Nullable animation range
  82309. */
  82310. getRange(name: string): Nullable<AnimationRange>;
  82311. /**
  82312. * Gets the key frames from the animation
  82313. * @returns The key frames of the animation
  82314. */
  82315. getKeys(): Array<IAnimationKey>;
  82316. /**
  82317. * Gets the highest frame rate of the animation
  82318. * @returns Highest frame rate of the animation
  82319. */
  82320. getHighestFrame(): number;
  82321. /**
  82322. * Gets the easing function of the animation
  82323. * @returns Easing function of the animation
  82324. */
  82325. getEasingFunction(): IEasingFunction;
  82326. /**
  82327. * Sets the easing function of the animation
  82328. * @param easingFunction A custom mathematical formula for animation
  82329. */
  82330. setEasingFunction(easingFunction: EasingFunction): void;
  82331. /**
  82332. * Interpolates a scalar linearly
  82333. * @param startValue Start value of the animation curve
  82334. * @param endValue End value of the animation curve
  82335. * @param gradient Scalar amount to interpolate
  82336. * @returns Interpolated scalar value
  82337. */
  82338. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82339. /**
  82340. * Interpolates a scalar cubically
  82341. * @param startValue Start value of the animation curve
  82342. * @param outTangent End tangent of the animation
  82343. * @param endValue End value of the animation curve
  82344. * @param inTangent Start tangent of the animation curve
  82345. * @param gradient Scalar amount to interpolate
  82346. * @returns Interpolated scalar value
  82347. */
  82348. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82349. /**
  82350. * Interpolates a quaternion using a spherical linear interpolation
  82351. * @param startValue Start value of the animation curve
  82352. * @param endValue End value of the animation curve
  82353. * @param gradient Scalar amount to interpolate
  82354. * @returns Interpolated quaternion value
  82355. */
  82356. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82357. /**
  82358. * Interpolates a quaternion cubically
  82359. * @param startValue Start value of the animation curve
  82360. * @param outTangent End tangent of the animation curve
  82361. * @param endValue End value of the animation curve
  82362. * @param inTangent Start tangent of the animation curve
  82363. * @param gradient Scalar amount to interpolate
  82364. * @returns Interpolated quaternion value
  82365. */
  82366. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82367. /**
  82368. * Interpolates a Vector3 linearl
  82369. * @param startValue Start value of the animation curve
  82370. * @param endValue End value of the animation curve
  82371. * @param gradient Scalar amount to interpolate
  82372. * @returns Interpolated scalar value
  82373. */
  82374. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82375. /**
  82376. * Interpolates a Vector3 cubically
  82377. * @param startValue Start value of the animation curve
  82378. * @param outTangent End tangent of the animation
  82379. * @param endValue End value of the animation curve
  82380. * @param inTangent Start tangent of the animation curve
  82381. * @param gradient Scalar amount to interpolate
  82382. * @returns InterpolatedVector3 value
  82383. */
  82384. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82385. /**
  82386. * Interpolates a Vector2 linearly
  82387. * @param startValue Start value of the animation curve
  82388. * @param endValue End value of the animation curve
  82389. * @param gradient Scalar amount to interpolate
  82390. * @returns Interpolated Vector2 value
  82391. */
  82392. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82393. /**
  82394. * Interpolates a Vector2 cubically
  82395. * @param startValue Start value of the animation curve
  82396. * @param outTangent End tangent of the animation
  82397. * @param endValue End value of the animation curve
  82398. * @param inTangent Start tangent of the animation curve
  82399. * @param gradient Scalar amount to interpolate
  82400. * @returns Interpolated Vector2 value
  82401. */
  82402. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82403. /**
  82404. * Interpolates a size linearly
  82405. * @param startValue Start value of the animation curve
  82406. * @param endValue End value of the animation curve
  82407. * @param gradient Scalar amount to interpolate
  82408. * @returns Interpolated Size value
  82409. */
  82410. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82411. /**
  82412. * Interpolates a Color3 linearly
  82413. * @param startValue Start value of the animation curve
  82414. * @param endValue End value of the animation curve
  82415. * @param gradient Scalar amount to interpolate
  82416. * @returns Interpolated Color3 value
  82417. */
  82418. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82419. /**
  82420. * @hidden Internal use only
  82421. */
  82422. _getKeyValue(value: any): any;
  82423. /**
  82424. * @hidden Internal use only
  82425. */
  82426. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82427. /**
  82428. * Defines the function to use to interpolate matrices
  82429. * @param startValue defines the start matrix
  82430. * @param endValue defines the end matrix
  82431. * @param gradient defines the gradient between both matrices
  82432. * @param result defines an optional target matrix where to store the interpolation
  82433. * @returns the interpolated matrix
  82434. */
  82435. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82436. /**
  82437. * Makes a copy of the animation
  82438. * @returns Cloned animation
  82439. */
  82440. clone(): Animation;
  82441. /**
  82442. * Sets the key frames of the animation
  82443. * @param values The animation key frames to set
  82444. */
  82445. setKeys(values: Array<IAnimationKey>): void;
  82446. /**
  82447. * Serializes the animation to an object
  82448. * @returns Serialized object
  82449. */
  82450. serialize(): any;
  82451. /**
  82452. * Float animation type
  82453. */
  82454. private static _ANIMATIONTYPE_FLOAT;
  82455. /**
  82456. * Vector3 animation type
  82457. */
  82458. private static _ANIMATIONTYPE_VECTOR3;
  82459. /**
  82460. * Quaternion animation type
  82461. */
  82462. private static _ANIMATIONTYPE_QUATERNION;
  82463. /**
  82464. * Matrix animation type
  82465. */
  82466. private static _ANIMATIONTYPE_MATRIX;
  82467. /**
  82468. * Color3 animation type
  82469. */
  82470. private static _ANIMATIONTYPE_COLOR3;
  82471. /**
  82472. * Vector2 animation type
  82473. */
  82474. private static _ANIMATIONTYPE_VECTOR2;
  82475. /**
  82476. * Size animation type
  82477. */
  82478. private static _ANIMATIONTYPE_SIZE;
  82479. /**
  82480. * Relative Loop Mode
  82481. */
  82482. private static _ANIMATIONLOOPMODE_RELATIVE;
  82483. /**
  82484. * Cycle Loop Mode
  82485. */
  82486. private static _ANIMATIONLOOPMODE_CYCLE;
  82487. /**
  82488. * Constant Loop Mode
  82489. */
  82490. private static _ANIMATIONLOOPMODE_CONSTANT;
  82491. /**
  82492. * Get the float animation type
  82493. */
  82494. static readonly ANIMATIONTYPE_FLOAT: number;
  82495. /**
  82496. * Get the Vector3 animation type
  82497. */
  82498. static readonly ANIMATIONTYPE_VECTOR3: number;
  82499. /**
  82500. * Get the Vector2 animation type
  82501. */
  82502. static readonly ANIMATIONTYPE_VECTOR2: number;
  82503. /**
  82504. * Get the Size animation type
  82505. */
  82506. static readonly ANIMATIONTYPE_SIZE: number;
  82507. /**
  82508. * Get the Quaternion animation type
  82509. */
  82510. static readonly ANIMATIONTYPE_QUATERNION: number;
  82511. /**
  82512. * Get the Matrix animation type
  82513. */
  82514. static readonly ANIMATIONTYPE_MATRIX: number;
  82515. /**
  82516. * Get the Color3 animation type
  82517. */
  82518. static readonly ANIMATIONTYPE_COLOR3: number;
  82519. /**
  82520. * Get the Relative Loop Mode
  82521. */
  82522. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82523. /**
  82524. * Get the Cycle Loop Mode
  82525. */
  82526. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82527. /**
  82528. * Get the Constant Loop Mode
  82529. */
  82530. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82531. /** @hidden */
  82532. static _UniversalLerp(left: any, right: any, amount: number): any;
  82533. /**
  82534. * Parses an animation object and creates an animation
  82535. * @param parsedAnimation Parsed animation object
  82536. * @returns Animation object
  82537. */
  82538. static Parse(parsedAnimation: any): Animation;
  82539. /**
  82540. * Appends the serialized animations from the source animations
  82541. * @param source Source containing the animations
  82542. * @param destination Target to store the animations
  82543. */
  82544. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82545. }
  82546. }
  82547. declare module BABYLON {
  82548. /**
  82549. * Base class of all the textures in babylon.
  82550. * It groups all the common properties the materials, post process, lights... might need
  82551. * in order to make a correct use of the texture.
  82552. */
  82553. export class BaseTexture implements IAnimatable {
  82554. /**
  82555. * Default anisotropic filtering level for the application.
  82556. * It is set to 4 as a good tradeoff between perf and quality.
  82557. */
  82558. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82559. /**
  82560. * Gets or sets the unique id of the texture
  82561. */
  82562. uniqueId: number;
  82563. /**
  82564. * Define the name of the texture.
  82565. */
  82566. name: string;
  82567. /**
  82568. * Gets or sets an object used to store user defined information.
  82569. */
  82570. metadata: any;
  82571. /**
  82572. * For internal use only. Please do not use.
  82573. */
  82574. reservedDataStore: any;
  82575. private _hasAlpha;
  82576. /**
  82577. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82578. */
  82579. hasAlpha: boolean;
  82580. /**
  82581. * Defines if the alpha value should be determined via the rgb values.
  82582. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82583. */
  82584. getAlphaFromRGB: boolean;
  82585. /**
  82586. * Intensity or strength of the texture.
  82587. * It is commonly used by materials to fine tune the intensity of the texture
  82588. */
  82589. level: number;
  82590. /**
  82591. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82592. * This is part of the texture as textures usually maps to one uv set.
  82593. */
  82594. coordinatesIndex: number;
  82595. private _coordinatesMode;
  82596. /**
  82597. * How a texture is mapped.
  82598. *
  82599. * | Value | Type | Description |
  82600. * | ----- | ----------------------------------- | ----------- |
  82601. * | 0 | EXPLICIT_MODE | |
  82602. * | 1 | SPHERICAL_MODE | |
  82603. * | 2 | PLANAR_MODE | |
  82604. * | 3 | CUBIC_MODE | |
  82605. * | 4 | PROJECTION_MODE | |
  82606. * | 5 | SKYBOX_MODE | |
  82607. * | 6 | INVCUBIC_MODE | |
  82608. * | 7 | EQUIRECTANGULAR_MODE | |
  82609. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82610. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82611. */
  82612. coordinatesMode: number;
  82613. /**
  82614. * | Value | Type | Description |
  82615. * | ----- | ------------------ | ----------- |
  82616. * | 0 | CLAMP_ADDRESSMODE | |
  82617. * | 1 | WRAP_ADDRESSMODE | |
  82618. * | 2 | MIRROR_ADDRESSMODE | |
  82619. */
  82620. wrapU: number;
  82621. /**
  82622. * | Value | Type | Description |
  82623. * | ----- | ------------------ | ----------- |
  82624. * | 0 | CLAMP_ADDRESSMODE | |
  82625. * | 1 | WRAP_ADDRESSMODE | |
  82626. * | 2 | MIRROR_ADDRESSMODE | |
  82627. */
  82628. wrapV: number;
  82629. /**
  82630. * | Value | Type | Description |
  82631. * | ----- | ------------------ | ----------- |
  82632. * | 0 | CLAMP_ADDRESSMODE | |
  82633. * | 1 | WRAP_ADDRESSMODE | |
  82634. * | 2 | MIRROR_ADDRESSMODE | |
  82635. */
  82636. wrapR: number;
  82637. /**
  82638. * With compliant hardware and browser (supporting anisotropic filtering)
  82639. * this defines the level of anisotropic filtering in the texture.
  82640. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82641. */
  82642. anisotropicFilteringLevel: number;
  82643. /**
  82644. * Define if the texture is a cube texture or if false a 2d texture.
  82645. */
  82646. isCube: boolean;
  82647. /**
  82648. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82649. */
  82650. is3D: boolean;
  82651. /**
  82652. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82653. * HDR texture are usually stored in linear space.
  82654. * This only impacts the PBR and Background materials
  82655. */
  82656. gammaSpace: boolean;
  82657. /**
  82658. * Gets whether or not the texture contains RGBD data.
  82659. */
  82660. readonly isRGBD: boolean;
  82661. /**
  82662. * Is Z inverted in the texture (useful in a cube texture).
  82663. */
  82664. invertZ: boolean;
  82665. /**
  82666. * Are mip maps generated for this texture or not.
  82667. */
  82668. readonly noMipmap: boolean;
  82669. /**
  82670. * @hidden
  82671. */
  82672. lodLevelInAlpha: boolean;
  82673. /**
  82674. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82675. */
  82676. lodGenerationOffset: number;
  82677. /**
  82678. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82679. */
  82680. lodGenerationScale: number;
  82681. /**
  82682. * Define if the texture is a render target.
  82683. */
  82684. isRenderTarget: boolean;
  82685. /**
  82686. * Define the unique id of the texture in the scene.
  82687. */
  82688. readonly uid: string;
  82689. /**
  82690. * Return a string representation of the texture.
  82691. * @returns the texture as a string
  82692. */
  82693. toString(): string;
  82694. /**
  82695. * Get the class name of the texture.
  82696. * @returns "BaseTexture"
  82697. */
  82698. getClassName(): string;
  82699. /**
  82700. * Define the list of animation attached to the texture.
  82701. */
  82702. animations: Animation[];
  82703. /**
  82704. * An event triggered when the texture is disposed.
  82705. */
  82706. onDisposeObservable: Observable<BaseTexture>;
  82707. private _onDisposeObserver;
  82708. /**
  82709. * Callback triggered when the texture has been disposed.
  82710. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82711. */
  82712. onDispose: () => void;
  82713. /**
  82714. * Define the current state of the loading sequence when in delayed load mode.
  82715. */
  82716. delayLoadState: number;
  82717. private _scene;
  82718. /** @hidden */
  82719. _texture: Nullable<InternalTexture>;
  82720. private _uid;
  82721. /**
  82722. * Define if the texture is preventinga material to render or not.
  82723. * If not and the texture is not ready, the engine will use a default black texture instead.
  82724. */
  82725. readonly isBlocking: boolean;
  82726. /**
  82727. * Instantiates a new BaseTexture.
  82728. * Base class of all the textures in babylon.
  82729. * It groups all the common properties the materials, post process, lights... might need
  82730. * in order to make a correct use of the texture.
  82731. * @param scene Define the scene the texture blongs to
  82732. */
  82733. constructor(scene: Nullable<Scene>);
  82734. /**
  82735. * Get the scene the texture belongs to.
  82736. * @returns the scene or null if undefined
  82737. */
  82738. getScene(): Nullable<Scene>;
  82739. /**
  82740. * Get the texture transform matrix used to offset tile the texture for istance.
  82741. * @returns the transformation matrix
  82742. */
  82743. getTextureMatrix(): Matrix;
  82744. /**
  82745. * Get the texture reflection matrix used to rotate/transform the reflection.
  82746. * @returns the reflection matrix
  82747. */
  82748. getReflectionTextureMatrix(): Matrix;
  82749. /**
  82750. * Get the underlying lower level texture from Babylon.
  82751. * @returns the insternal texture
  82752. */
  82753. getInternalTexture(): Nullable<InternalTexture>;
  82754. /**
  82755. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82756. * @returns true if ready or not blocking
  82757. */
  82758. isReadyOrNotBlocking(): boolean;
  82759. /**
  82760. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82761. * @returns true if fully ready
  82762. */
  82763. isReady(): boolean;
  82764. private _cachedSize;
  82765. /**
  82766. * Get the size of the texture.
  82767. * @returns the texture size.
  82768. */
  82769. getSize(): ISize;
  82770. /**
  82771. * Get the base size of the texture.
  82772. * It can be different from the size if the texture has been resized for POT for instance
  82773. * @returns the base size
  82774. */
  82775. getBaseSize(): ISize;
  82776. /**
  82777. * Update the sampling mode of the texture.
  82778. * Default is Trilinear mode.
  82779. *
  82780. * | Value | Type | Description |
  82781. * | ----- | ------------------ | ----------- |
  82782. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82783. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82784. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82785. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82786. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82787. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82788. * | 7 | NEAREST_LINEAR | |
  82789. * | 8 | NEAREST_NEAREST | |
  82790. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82791. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82792. * | 11 | LINEAR_LINEAR | |
  82793. * | 12 | LINEAR_NEAREST | |
  82794. *
  82795. * > _mag_: magnification filter (close to the viewer)
  82796. * > _min_: minification filter (far from the viewer)
  82797. * > _mip_: filter used between mip map levels
  82798. *@param samplingMode Define the new sampling mode of the texture
  82799. */
  82800. updateSamplingMode(samplingMode: number): void;
  82801. /**
  82802. * Scales the texture if is `canRescale()`
  82803. * @param ratio the resize factor we want to use to rescale
  82804. */
  82805. scale(ratio: number): void;
  82806. /**
  82807. * Get if the texture can rescale.
  82808. */
  82809. readonly canRescale: boolean;
  82810. /** @hidden */
  82811. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82812. /** @hidden */
  82813. _rebuild(): void;
  82814. /**
  82815. * Triggers the load sequence in delayed load mode.
  82816. */
  82817. delayLoad(): void;
  82818. /**
  82819. * Clones the texture.
  82820. * @returns the cloned texture
  82821. */
  82822. clone(): Nullable<BaseTexture>;
  82823. /**
  82824. * Get the texture underlying type (INT, FLOAT...)
  82825. */
  82826. readonly textureType: number;
  82827. /**
  82828. * Get the texture underlying format (RGB, RGBA...)
  82829. */
  82830. readonly textureFormat: number;
  82831. /**
  82832. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82833. * This will returns an RGBA array buffer containing either in values (0-255) or
  82834. * float values (0-1) depending of the underlying buffer type.
  82835. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82836. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82837. * @param buffer defines a user defined buffer to fill with data (can be null)
  82838. * @returns The Array buffer containing the pixels data.
  82839. */
  82840. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82841. /**
  82842. * Release and destroy the underlying lower level texture aka internalTexture.
  82843. */
  82844. releaseInternalTexture(): void;
  82845. /**
  82846. * Get the polynomial representation of the texture data.
  82847. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82848. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82849. */
  82850. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82851. /** @hidden */
  82852. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82853. /** @hidden */
  82854. readonly _lodTextureMid: Nullable<BaseTexture>;
  82855. /** @hidden */
  82856. readonly _lodTextureLow: Nullable<BaseTexture>;
  82857. /**
  82858. * Dispose the texture and release its associated resources.
  82859. */
  82860. dispose(): void;
  82861. /**
  82862. * Serialize the texture into a JSON representation that can be parsed later on.
  82863. * @returns the JSON representation of the texture
  82864. */
  82865. serialize(): any;
  82866. /**
  82867. * Helper function to be called back once a list of texture contains only ready textures.
  82868. * @param textures Define the list of textures to wait for
  82869. * @param callback Define the callback triggered once the entire list will be ready
  82870. */
  82871. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82872. }
  82873. }
  82874. declare module BABYLON {
  82875. /**
  82876. * Uniform buffer objects.
  82877. *
  82878. * Handles blocks of uniform on the GPU.
  82879. *
  82880. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82881. *
  82882. * For more information, please refer to :
  82883. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82884. */
  82885. export class UniformBuffer {
  82886. private _engine;
  82887. private _buffer;
  82888. private _data;
  82889. private _bufferData;
  82890. private _dynamic?;
  82891. private _uniformLocations;
  82892. private _uniformSizes;
  82893. private _uniformLocationPointer;
  82894. private _needSync;
  82895. private _noUBO;
  82896. private _currentEffect;
  82897. private static _MAX_UNIFORM_SIZE;
  82898. private static _tempBuffer;
  82899. /**
  82900. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82901. * This is dynamic to allow compat with webgl 1 and 2.
  82902. * You will need to pass the name of the uniform as well as the value.
  82903. */
  82904. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82905. /**
  82906. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82907. * This is dynamic to allow compat with webgl 1 and 2.
  82908. * You will need to pass the name of the uniform as well as the value.
  82909. */
  82910. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82911. /**
  82912. * Lambda to Update a single float in a uniform buffer.
  82913. * This is dynamic to allow compat with webgl 1 and 2.
  82914. * You will need to pass the name of the uniform as well as the value.
  82915. */
  82916. updateFloat: (name: string, x: number) => void;
  82917. /**
  82918. * Lambda to Update a vec2 of float in a uniform buffer.
  82919. * This is dynamic to allow compat with webgl 1 and 2.
  82920. * You will need to pass the name of the uniform as well as the value.
  82921. */
  82922. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82923. /**
  82924. * Lambda to Update a vec3 of float in a uniform buffer.
  82925. * This is dynamic to allow compat with webgl 1 and 2.
  82926. * You will need to pass the name of the uniform as well as the value.
  82927. */
  82928. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82929. /**
  82930. * Lambda to Update a vec4 of float in a uniform buffer.
  82931. * This is dynamic to allow compat with webgl 1 and 2.
  82932. * You will need to pass the name of the uniform as well as the value.
  82933. */
  82934. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82935. /**
  82936. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82937. * This is dynamic to allow compat with webgl 1 and 2.
  82938. * You will need to pass the name of the uniform as well as the value.
  82939. */
  82940. updateMatrix: (name: string, mat: Matrix) => void;
  82941. /**
  82942. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82943. * This is dynamic to allow compat with webgl 1 and 2.
  82944. * You will need to pass the name of the uniform as well as the value.
  82945. */
  82946. updateVector3: (name: string, vector: Vector3) => void;
  82947. /**
  82948. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82949. * This is dynamic to allow compat with webgl 1 and 2.
  82950. * You will need to pass the name of the uniform as well as the value.
  82951. */
  82952. updateVector4: (name: string, vector: Vector4) => void;
  82953. /**
  82954. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82955. * This is dynamic to allow compat with webgl 1 and 2.
  82956. * You will need to pass the name of the uniform as well as the value.
  82957. */
  82958. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82959. /**
  82960. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82961. * This is dynamic to allow compat with webgl 1 and 2.
  82962. * You will need to pass the name of the uniform as well as the value.
  82963. */
  82964. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82965. /**
  82966. * Instantiates a new Uniform buffer objects.
  82967. *
  82968. * Handles blocks of uniform on the GPU.
  82969. *
  82970. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82971. *
  82972. * For more information, please refer to :
  82973. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82974. * @param engine Define the engine the buffer is associated with
  82975. * @param data Define the data contained in the buffer
  82976. * @param dynamic Define if the buffer is updatable
  82977. */
  82978. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82979. /**
  82980. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82981. * or just falling back on setUniformXXX calls.
  82982. */
  82983. readonly useUbo: boolean;
  82984. /**
  82985. * Indicates if the WebGL underlying uniform buffer is in sync
  82986. * with the javascript cache data.
  82987. */
  82988. readonly isSync: boolean;
  82989. /**
  82990. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82991. * Also, a dynamic UniformBuffer will disable cache verification and always
  82992. * update the underlying WebGL uniform buffer to the GPU.
  82993. * @returns if Dynamic, otherwise false
  82994. */
  82995. isDynamic(): boolean;
  82996. /**
  82997. * The data cache on JS side.
  82998. * @returns the underlying data as a float array
  82999. */
  83000. getData(): Float32Array;
  83001. /**
  83002. * The underlying WebGL Uniform buffer.
  83003. * @returns the webgl buffer
  83004. */
  83005. getBuffer(): Nullable<WebGLBuffer>;
  83006. /**
  83007. * std140 layout specifies how to align data within an UBO structure.
  83008. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83009. * for specs.
  83010. */
  83011. private _fillAlignment;
  83012. /**
  83013. * Adds an uniform in the buffer.
  83014. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83015. * for the layout to be correct !
  83016. * @param name Name of the uniform, as used in the uniform block in the shader.
  83017. * @param size Data size, or data directly.
  83018. */
  83019. addUniform(name: string, size: number | number[]): void;
  83020. /**
  83021. * Adds a Matrix 4x4 to the uniform buffer.
  83022. * @param name Name of the uniform, as used in the uniform block in the shader.
  83023. * @param mat A 4x4 matrix.
  83024. */
  83025. addMatrix(name: string, mat: Matrix): void;
  83026. /**
  83027. * Adds a vec2 to the uniform buffer.
  83028. * @param name Name of the uniform, as used in the uniform block in the shader.
  83029. * @param x Define the x component value of the vec2
  83030. * @param y Define the y component value of the vec2
  83031. */
  83032. addFloat2(name: string, x: number, y: number): void;
  83033. /**
  83034. * Adds a vec3 to the uniform buffer.
  83035. * @param name Name of the uniform, as used in the uniform block in the shader.
  83036. * @param x Define the x component value of the vec3
  83037. * @param y Define the y component value of the vec3
  83038. * @param z Define the z component value of the vec3
  83039. */
  83040. addFloat3(name: string, x: number, y: number, z: number): void;
  83041. /**
  83042. * Adds a vec3 to the uniform buffer.
  83043. * @param name Name of the uniform, as used in the uniform block in the shader.
  83044. * @param color Define the vec3 from a Color
  83045. */
  83046. addColor3(name: string, color: Color3): void;
  83047. /**
  83048. * Adds a vec4 to the uniform buffer.
  83049. * @param name Name of the uniform, as used in the uniform block in the shader.
  83050. * @param color Define the rgb components from a Color
  83051. * @param alpha Define the a component of the vec4
  83052. */
  83053. addColor4(name: string, color: Color3, alpha: number): void;
  83054. /**
  83055. * Adds a vec3 to the uniform buffer.
  83056. * @param name Name of the uniform, as used in the uniform block in the shader.
  83057. * @param vector Define the vec3 components from a Vector
  83058. */
  83059. addVector3(name: string, vector: Vector3): void;
  83060. /**
  83061. * Adds a Matrix 3x3 to the uniform buffer.
  83062. * @param name Name of the uniform, as used in the uniform block in the shader.
  83063. */
  83064. addMatrix3x3(name: string): void;
  83065. /**
  83066. * Adds a Matrix 2x2 to the uniform buffer.
  83067. * @param name Name of the uniform, as used in the uniform block in the shader.
  83068. */
  83069. addMatrix2x2(name: string): void;
  83070. /**
  83071. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83072. */
  83073. create(): void;
  83074. /** @hidden */
  83075. _rebuild(): void;
  83076. /**
  83077. * Updates the WebGL Uniform Buffer on the GPU.
  83078. * If the `dynamic` flag is set to true, no cache comparison is done.
  83079. * Otherwise, the buffer will be updated only if the cache differs.
  83080. */
  83081. update(): void;
  83082. /**
  83083. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83084. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83085. * @param data Define the flattened data
  83086. * @param size Define the size of the data.
  83087. */
  83088. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83089. private _updateMatrix3x3ForUniform;
  83090. private _updateMatrix3x3ForEffect;
  83091. private _updateMatrix2x2ForEffect;
  83092. private _updateMatrix2x2ForUniform;
  83093. private _updateFloatForEffect;
  83094. private _updateFloatForUniform;
  83095. private _updateFloat2ForEffect;
  83096. private _updateFloat2ForUniform;
  83097. private _updateFloat3ForEffect;
  83098. private _updateFloat3ForUniform;
  83099. private _updateFloat4ForEffect;
  83100. private _updateFloat4ForUniform;
  83101. private _updateMatrixForEffect;
  83102. private _updateMatrixForUniform;
  83103. private _updateVector3ForEffect;
  83104. private _updateVector3ForUniform;
  83105. private _updateVector4ForEffect;
  83106. private _updateVector4ForUniform;
  83107. private _updateColor3ForEffect;
  83108. private _updateColor3ForUniform;
  83109. private _updateColor4ForEffect;
  83110. private _updateColor4ForUniform;
  83111. /**
  83112. * Sets a sampler uniform on the effect.
  83113. * @param name Define the name of the sampler.
  83114. * @param texture Define the texture to set in the sampler
  83115. */
  83116. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83117. /**
  83118. * Directly updates the value of the uniform in the cache AND on the GPU.
  83119. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83120. * @param data Define the flattened data
  83121. */
  83122. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83123. /**
  83124. * Binds this uniform buffer to an effect.
  83125. * @param effect Define the effect to bind the buffer to
  83126. * @param name Name of the uniform block in the shader.
  83127. */
  83128. bindToEffect(effect: Effect, name: string): void;
  83129. /**
  83130. * Disposes the uniform buffer.
  83131. */
  83132. dispose(): void;
  83133. }
  83134. }
  83135. declare module BABYLON {
  83136. /**
  83137. * This represents the required contract to create a new type of texture loader.
  83138. */
  83139. export interface IInternalTextureLoader {
  83140. /**
  83141. * Defines wether the loader supports cascade loading the different faces.
  83142. */
  83143. supportCascades: boolean;
  83144. /**
  83145. * This returns if the loader support the current file information.
  83146. * @param extension defines the file extension of the file being loaded
  83147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83148. * @param fallback defines the fallback internal texture if any
  83149. * @param isBase64 defines whether the texture is encoded as a base64
  83150. * @param isBuffer defines whether the texture data are stored as a buffer
  83151. * @returns true if the loader can load the specified file
  83152. */
  83153. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  83154. /**
  83155. * Transform the url before loading if required.
  83156. * @param rootUrl the url of the texture
  83157. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83158. * @returns the transformed texture
  83159. */
  83160. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  83161. /**
  83162. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  83163. * @param rootUrl the url of the texture
  83164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83165. * @returns the fallback texture
  83166. */
  83167. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  83168. /**
  83169. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  83170. * @param data contains the texture data
  83171. * @param texture defines the BabylonJS internal texture
  83172. * @param createPolynomials will be true if polynomials have been requested
  83173. * @param onLoad defines the callback to trigger once the texture is ready
  83174. * @param onError defines the callback to trigger in case of error
  83175. */
  83176. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  83177. /**
  83178. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  83179. * @param data contains the texture data
  83180. * @param texture defines the BabylonJS internal texture
  83181. * @param callback defines the method to call once ready to upload
  83182. */
  83183. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  83184. }
  83185. }
  83186. declare module BABYLON {
  83187. /**
  83188. * Creation options of the multi render target texture.
  83189. */
  83190. export interface IMultiRenderTargetOptions {
  83191. /**
  83192. * Define if the texture needs to create mip maps after render.
  83193. */
  83194. generateMipMaps?: boolean;
  83195. /**
  83196. * Define the types of all the draw buffers we want to create
  83197. */
  83198. types?: number[];
  83199. /**
  83200. * Define the sampling modes of all the draw buffers we want to create
  83201. */
  83202. samplingModes?: number[];
  83203. /**
  83204. * Define if a depth buffer is required
  83205. */
  83206. generateDepthBuffer?: boolean;
  83207. /**
  83208. * Define if a stencil buffer is required
  83209. */
  83210. generateStencilBuffer?: boolean;
  83211. /**
  83212. * Define if a depth texture is required instead of a depth buffer
  83213. */
  83214. generateDepthTexture?: boolean;
  83215. /**
  83216. * Define the number of desired draw buffers
  83217. */
  83218. textureCount?: number;
  83219. /**
  83220. * Define if aspect ratio should be adapted to the texture or stay the scene one
  83221. */
  83222. doNotChangeAspectRatio?: boolean;
  83223. /**
  83224. * Define the default type of the buffers we are creating
  83225. */
  83226. defaultType?: number;
  83227. }
  83228. /**
  83229. * A multi render target, like a render target provides the ability to render to a texture.
  83230. * Unlike the render target, it can render to several draw buffers in one draw.
  83231. * This is specially interesting in deferred rendering or for any effects requiring more than
  83232. * just one color from a single pass.
  83233. */
  83234. export class MultiRenderTarget extends RenderTargetTexture {
  83235. private _internalTextures;
  83236. private _textures;
  83237. private _multiRenderTargetOptions;
  83238. /**
  83239. * Get if draw buffers are currently supported by the used hardware and browser.
  83240. */
  83241. readonly isSupported: boolean;
  83242. /**
  83243. * Get the list of textures generated by the multi render target.
  83244. */
  83245. readonly textures: Texture[];
  83246. /**
  83247. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83248. */
  83249. readonly depthTexture: Texture;
  83250. /**
  83251. * Set the wrapping mode on U of all the textures we are rendering to.
  83252. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83253. */
  83254. wrapU: number;
  83255. /**
  83256. * Set the wrapping mode on V of all the textures we are rendering to.
  83257. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83258. */
  83259. wrapV: number;
  83260. /**
  83261. * Instantiate a new multi render target texture.
  83262. * A multi render target, like a render target provides the ability to render to a texture.
  83263. * Unlike the render target, it can render to several draw buffers in one draw.
  83264. * This is specially interesting in deferred rendering or for any effects requiring more than
  83265. * just one color from a single pass.
  83266. * @param name Define the name of the texture
  83267. * @param size Define the size of the buffers to render to
  83268. * @param count Define the number of target we are rendering into
  83269. * @param scene Define the scene the texture belongs to
  83270. * @param options Define the options used to create the multi render target
  83271. */
  83272. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83273. /** @hidden */
  83274. _rebuild(): void;
  83275. private _createInternalTextures;
  83276. private _createTextures;
  83277. /**
  83278. * Define the number of samples used if MSAA is enabled.
  83279. */
  83280. samples: number;
  83281. /**
  83282. * Resize all the textures in the multi render target.
  83283. * Be carrefull as it will recreate all the data in the new texture.
  83284. * @param size Define the new size
  83285. */
  83286. resize(size: any): void;
  83287. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83288. /**
  83289. * Dispose the render targets and their associated resources
  83290. */
  83291. dispose(): void;
  83292. /**
  83293. * Release all the underlying texture used as draw buffers.
  83294. */
  83295. releaseInternalTextures(): void;
  83296. }
  83297. }
  83298. declare module BABYLON {
  83299. /**
  83300. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83302. */
  83303. export class Analyser {
  83304. /**
  83305. * Gets or sets the smoothing
  83306. * @ignorenaming
  83307. */
  83308. SMOOTHING: number;
  83309. /**
  83310. * Gets or sets the FFT table size
  83311. * @ignorenaming
  83312. */
  83313. FFT_SIZE: number;
  83314. /**
  83315. * Gets or sets the bar graph amplitude
  83316. * @ignorenaming
  83317. */
  83318. BARGRAPHAMPLITUDE: number;
  83319. /**
  83320. * Gets or sets the position of the debug canvas
  83321. * @ignorenaming
  83322. */
  83323. DEBUGCANVASPOS: {
  83324. x: number;
  83325. y: number;
  83326. };
  83327. /**
  83328. * Gets or sets the debug canvas size
  83329. * @ignorenaming
  83330. */
  83331. DEBUGCANVASSIZE: {
  83332. width: number;
  83333. height: number;
  83334. };
  83335. private _byteFreqs;
  83336. private _byteTime;
  83337. private _floatFreqs;
  83338. private _webAudioAnalyser;
  83339. private _debugCanvas;
  83340. private _debugCanvasContext;
  83341. private _scene;
  83342. private _registerFunc;
  83343. private _audioEngine;
  83344. /**
  83345. * Creates a new analyser
  83346. * @param scene defines hosting scene
  83347. */
  83348. constructor(scene: Scene);
  83349. /**
  83350. * Get the number of data values you will have to play with for the visualization
  83351. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83352. * @returns a number
  83353. */
  83354. getFrequencyBinCount(): number;
  83355. /**
  83356. * Gets the current frequency data as a byte array
  83357. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83358. * @returns a Uint8Array
  83359. */
  83360. getByteFrequencyData(): Uint8Array;
  83361. /**
  83362. * Gets the current waveform as a byte array
  83363. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83364. * @returns a Uint8Array
  83365. */
  83366. getByteTimeDomainData(): Uint8Array;
  83367. /**
  83368. * Gets the current frequency data as a float array
  83369. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83370. * @returns a Float32Array
  83371. */
  83372. getFloatFrequencyData(): Float32Array;
  83373. /**
  83374. * Renders the debug canvas
  83375. */
  83376. drawDebugCanvas(): void;
  83377. /**
  83378. * Stops rendering the debug canvas and removes it
  83379. */
  83380. stopDebugCanvas(): void;
  83381. /**
  83382. * Connects two audio nodes
  83383. * @param inputAudioNode defines first node to connect
  83384. * @param outputAudioNode defines second node to connect
  83385. */
  83386. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83387. /**
  83388. * Releases all associated resources
  83389. */
  83390. dispose(): void;
  83391. }
  83392. }
  83393. declare module BABYLON {
  83394. /**
  83395. * This represents an audio engine and it is responsible
  83396. * to play, synchronize and analyse sounds throughout the application.
  83397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83398. */
  83399. export interface IAudioEngine extends IDisposable {
  83400. /**
  83401. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83402. */
  83403. readonly canUseWebAudio: boolean;
  83404. /**
  83405. * Gets the current AudioContext if available.
  83406. */
  83407. readonly audioContext: Nullable<AudioContext>;
  83408. /**
  83409. * The master gain node defines the global audio volume of your audio engine.
  83410. */
  83411. readonly masterGain: GainNode;
  83412. /**
  83413. * Gets whether or not mp3 are supported by your browser.
  83414. */
  83415. readonly isMP3supported: boolean;
  83416. /**
  83417. * Gets whether or not ogg are supported by your browser.
  83418. */
  83419. readonly isOGGsupported: boolean;
  83420. /**
  83421. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83422. * @ignoreNaming
  83423. */
  83424. WarnedWebAudioUnsupported: boolean;
  83425. /**
  83426. * Defines if the audio engine relies on a custom unlocked button.
  83427. * In this case, the embedded button will not be displayed.
  83428. */
  83429. useCustomUnlockedButton: boolean;
  83430. /**
  83431. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83432. */
  83433. readonly unlocked: boolean;
  83434. /**
  83435. * Event raised when audio has been unlocked on the browser.
  83436. */
  83437. onAudioUnlockedObservable: Observable<AudioEngine>;
  83438. /**
  83439. * Event raised when audio has been locked on the browser.
  83440. */
  83441. onAudioLockedObservable: Observable<AudioEngine>;
  83442. /**
  83443. * Flags the audio engine in Locked state.
  83444. * This happens due to new browser policies preventing audio to autoplay.
  83445. */
  83446. lock(): void;
  83447. /**
  83448. * Unlocks the audio engine once a user action has been done on the dom.
  83449. * This is helpful to resume play once browser policies have been satisfied.
  83450. */
  83451. unlock(): void;
  83452. }
  83453. /**
  83454. * This represents the default audio engine used in babylon.
  83455. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83457. */
  83458. export class AudioEngine implements IAudioEngine {
  83459. private _audioContext;
  83460. private _audioContextInitialized;
  83461. private _muteButton;
  83462. private _hostElement;
  83463. /**
  83464. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83465. */
  83466. canUseWebAudio: boolean;
  83467. /**
  83468. * The master gain node defines the global audio volume of your audio engine.
  83469. */
  83470. masterGain: GainNode;
  83471. /**
  83472. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83473. * @ignoreNaming
  83474. */
  83475. WarnedWebAudioUnsupported: boolean;
  83476. /**
  83477. * Gets whether or not mp3 are supported by your browser.
  83478. */
  83479. isMP3supported: boolean;
  83480. /**
  83481. * Gets whether or not ogg are supported by your browser.
  83482. */
  83483. isOGGsupported: boolean;
  83484. /**
  83485. * Gets whether audio has been unlocked on the device.
  83486. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83487. * a user interaction has happened.
  83488. */
  83489. unlocked: boolean;
  83490. /**
  83491. * Defines if the audio engine relies on a custom unlocked button.
  83492. * In this case, the embedded button will not be displayed.
  83493. */
  83494. useCustomUnlockedButton: boolean;
  83495. /**
  83496. * Event raised when audio has been unlocked on the browser.
  83497. */
  83498. onAudioUnlockedObservable: Observable<AudioEngine>;
  83499. /**
  83500. * Event raised when audio has been locked on the browser.
  83501. */
  83502. onAudioLockedObservable: Observable<AudioEngine>;
  83503. /**
  83504. * Gets the current AudioContext if available.
  83505. */
  83506. readonly audioContext: Nullable<AudioContext>;
  83507. private _connectedAnalyser;
  83508. /**
  83509. * Instantiates a new audio engine.
  83510. *
  83511. * There should be only one per page as some browsers restrict the number
  83512. * of audio contexts you can create.
  83513. * @param hostElement defines the host element where to display the mute icon if necessary
  83514. */
  83515. constructor(hostElement?: Nullable<HTMLElement>);
  83516. /**
  83517. * Flags the audio engine in Locked state.
  83518. * This happens due to new browser policies preventing audio to autoplay.
  83519. */
  83520. lock(): void;
  83521. /**
  83522. * Unlocks the audio engine once a user action has been done on the dom.
  83523. * This is helpful to resume play once browser policies have been satisfied.
  83524. */
  83525. unlock(): void;
  83526. private _resumeAudioContext;
  83527. private _initializeAudioContext;
  83528. private _tryToRun;
  83529. private _triggerRunningState;
  83530. private _triggerSuspendedState;
  83531. private _displayMuteButton;
  83532. private _moveButtonToTopLeft;
  83533. private _onResize;
  83534. private _hideMuteButton;
  83535. /**
  83536. * Destroy and release the resources associated with the audio ccontext.
  83537. */
  83538. dispose(): void;
  83539. /**
  83540. * Gets the global volume sets on the master gain.
  83541. * @returns the global volume if set or -1 otherwise
  83542. */
  83543. getGlobalVolume(): number;
  83544. /**
  83545. * Sets the global volume of your experience (sets on the master gain).
  83546. * @param newVolume Defines the new global volume of the application
  83547. */
  83548. setGlobalVolume(newVolume: number): void;
  83549. /**
  83550. * Connect the audio engine to an audio analyser allowing some amazing
  83551. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83553. * @param analyser The analyser to connect to the engine
  83554. */
  83555. connectToAnalyser(analyser: Analyser): void;
  83556. }
  83557. }
  83558. declare module BABYLON {
  83559. /**
  83560. * Interface used to present a loading screen while loading a scene
  83561. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83562. */
  83563. export interface ILoadingScreen {
  83564. /**
  83565. * Function called to display the loading screen
  83566. */
  83567. displayLoadingUI: () => void;
  83568. /**
  83569. * Function called to hide the loading screen
  83570. */
  83571. hideLoadingUI: () => void;
  83572. /**
  83573. * Gets or sets the color to use for the background
  83574. */
  83575. loadingUIBackgroundColor: string;
  83576. /**
  83577. * Gets or sets the text to display while loading
  83578. */
  83579. loadingUIText: string;
  83580. }
  83581. /**
  83582. * Class used for the default loading screen
  83583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83584. */
  83585. export class DefaultLoadingScreen implements ILoadingScreen {
  83586. private _renderingCanvas;
  83587. private _loadingText;
  83588. private _loadingDivBackgroundColor;
  83589. private _loadingDiv;
  83590. private _loadingTextDiv;
  83591. /**
  83592. * Creates a new default loading screen
  83593. * @param _renderingCanvas defines the canvas used to render the scene
  83594. * @param _loadingText defines the default text to display
  83595. * @param _loadingDivBackgroundColor defines the default background color
  83596. */
  83597. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83598. /**
  83599. * Function called to display the loading screen
  83600. */
  83601. displayLoadingUI(): void;
  83602. /**
  83603. * Function called to hide the loading screen
  83604. */
  83605. hideLoadingUI(): void;
  83606. /**
  83607. * Gets or sets the text to display while loading
  83608. */
  83609. loadingUIText: string;
  83610. /**
  83611. * Gets or sets the color to use for the background
  83612. */
  83613. loadingUIBackgroundColor: string;
  83614. private _resizeLoadingUI;
  83615. }
  83616. }
  83617. declare module BABYLON {
  83618. /**
  83619. * Settings for finer control over video usage
  83620. */
  83621. export interface VideoTextureSettings {
  83622. /**
  83623. * Applies `autoplay` to video, if specified
  83624. */
  83625. autoPlay?: boolean;
  83626. /**
  83627. * Applies `loop` to video, if specified
  83628. */
  83629. loop?: boolean;
  83630. /**
  83631. * Automatically updates internal texture from video at every frame in the render loop
  83632. */
  83633. autoUpdateTexture: boolean;
  83634. /**
  83635. * Image src displayed during the video loading or until the user interacts with the video.
  83636. */
  83637. poster?: string;
  83638. }
  83639. /**
  83640. * If you want to display a video in your scene, this is the special texture for that.
  83641. * This special texture works similar to other textures, with the exception of a few parameters.
  83642. * @see https://doc.babylonjs.com/how_to/video_texture
  83643. */
  83644. export class VideoTexture extends Texture {
  83645. /**
  83646. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83647. */
  83648. readonly autoUpdateTexture: boolean;
  83649. /**
  83650. * The video instance used by the texture internally
  83651. */
  83652. readonly video: HTMLVideoElement;
  83653. private _onUserActionRequestedObservable;
  83654. /**
  83655. * Event triggerd when a dom action is required by the user to play the video.
  83656. * This happens due to recent changes in browser policies preventing video to auto start.
  83657. */
  83658. readonly onUserActionRequestedObservable: Observable<Texture>;
  83659. private _generateMipMaps;
  83660. private _engine;
  83661. private _stillImageCaptured;
  83662. private _displayingPosterTexture;
  83663. private _settings;
  83664. private _createInternalTextureOnEvent;
  83665. /**
  83666. * Creates a video texture.
  83667. * If you want to display a video in your scene, this is the special texture for that.
  83668. * This special texture works similar to other textures, with the exception of a few parameters.
  83669. * @see https://doc.babylonjs.com/how_to/video_texture
  83670. * @param name optional name, will detect from video source, if not defined
  83671. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83672. * @param scene is obviously the current scene.
  83673. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83674. * @param invertY is false by default but can be used to invert video on Y axis
  83675. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83676. * @param settings allows finer control over video usage
  83677. */
  83678. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83679. private _getName;
  83680. private _getVideo;
  83681. private _createInternalTexture;
  83682. private reset;
  83683. /**
  83684. * @hidden Internal method to initiate `update`.
  83685. */
  83686. _rebuild(): void;
  83687. /**
  83688. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83689. */
  83690. update(): void;
  83691. /**
  83692. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83693. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83694. */
  83695. updateTexture(isVisible: boolean): void;
  83696. protected _updateInternalTexture: () => void;
  83697. /**
  83698. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83699. * @param url New url.
  83700. */
  83701. updateURL(url: string): void;
  83702. /**
  83703. * Dispose the texture and release its associated resources.
  83704. */
  83705. dispose(): void;
  83706. /**
  83707. * Creates a video texture straight from a stream.
  83708. * @param scene Define the scene the texture should be created in
  83709. * @param stream Define the stream the texture should be created from
  83710. * @returns The created video texture as a promise
  83711. */
  83712. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83713. /**
  83714. * Creates a video texture straight from your WebCam video feed.
  83715. * @param scene Define the scene the texture should be created in
  83716. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83717. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83718. * @returns The created video texture as a promise
  83719. */
  83720. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83721. minWidth: number;
  83722. maxWidth: number;
  83723. minHeight: number;
  83724. maxHeight: number;
  83725. deviceId: string;
  83726. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83727. /**
  83728. * Creates a video texture straight from your WebCam video feed.
  83729. * @param scene Define the scene the texture should be created in
  83730. * @param onReady Define a callback to triggered once the texture will be ready
  83731. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83732. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83733. */
  83734. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83735. minWidth: number;
  83736. maxWidth: number;
  83737. minHeight: number;
  83738. maxHeight: number;
  83739. deviceId: string;
  83740. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83741. }
  83742. }
  83743. declare module BABYLON {
  83744. /**
  83745. * Interface for attribute information associated with buffer instanciation
  83746. */
  83747. export class InstancingAttributeInfo {
  83748. /**
  83749. * Index/offset of the attribute in the vertex shader
  83750. */
  83751. index: number;
  83752. /**
  83753. * size of the attribute, 1, 2, 3 or 4
  83754. */
  83755. attributeSize: number;
  83756. /**
  83757. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83758. * default is FLOAT
  83759. */
  83760. attribyteType: number;
  83761. /**
  83762. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83763. */
  83764. normalized: boolean;
  83765. /**
  83766. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83767. */
  83768. offset: number;
  83769. /**
  83770. * Name of the GLSL attribute, for debugging purpose only
  83771. */
  83772. attributeName: string;
  83773. }
  83774. /**
  83775. * Define options used to create a depth texture
  83776. */
  83777. export class DepthTextureCreationOptions {
  83778. /** Specifies whether or not a stencil should be allocated in the texture */
  83779. generateStencil?: boolean;
  83780. /** Specifies whether or not bilinear filtering is enable on the texture */
  83781. bilinearFiltering?: boolean;
  83782. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83783. comparisonFunction?: number;
  83784. /** Specifies if the created texture is a cube texture */
  83785. isCube?: boolean;
  83786. }
  83787. /**
  83788. * Class used to describe the capabilities of the engine relatively to the current browser
  83789. */
  83790. export class EngineCapabilities {
  83791. /** Maximum textures units per fragment shader */
  83792. maxTexturesImageUnits: number;
  83793. /** Maximum texture units per vertex shader */
  83794. maxVertexTextureImageUnits: number;
  83795. /** Maximum textures units in the entire pipeline */
  83796. maxCombinedTexturesImageUnits: number;
  83797. /** Maximum texture size */
  83798. maxTextureSize: number;
  83799. /** Maximum cube texture size */
  83800. maxCubemapTextureSize: number;
  83801. /** Maximum render texture size */
  83802. maxRenderTextureSize: number;
  83803. /** Maximum number of vertex attributes */
  83804. maxVertexAttribs: number;
  83805. /** Maximum number of varyings */
  83806. maxVaryingVectors: number;
  83807. /** Maximum number of uniforms per vertex shader */
  83808. maxVertexUniformVectors: number;
  83809. /** Maximum number of uniforms per fragment shader */
  83810. maxFragmentUniformVectors: number;
  83811. /** Defines if standard derivates (dx/dy) are supported */
  83812. standardDerivatives: boolean;
  83813. /** Defines if s3tc texture compression is supported */
  83814. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83815. /** Defines if pvrtc texture compression is supported */
  83816. pvrtc: any;
  83817. /** Defines if etc1 texture compression is supported */
  83818. etc1: any;
  83819. /** Defines if etc2 texture compression is supported */
  83820. etc2: any;
  83821. /** Defines if astc texture compression is supported */
  83822. astc: any;
  83823. /** Defines if float textures are supported */
  83824. textureFloat: boolean;
  83825. /** Defines if vertex array objects are supported */
  83826. vertexArrayObject: boolean;
  83827. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83828. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83829. /** Gets the maximum level of anisotropy supported */
  83830. maxAnisotropy: number;
  83831. /** Defines if instancing is supported */
  83832. instancedArrays: boolean;
  83833. /** Defines if 32 bits indices are supported */
  83834. uintIndices: boolean;
  83835. /** Defines if high precision shaders are supported */
  83836. highPrecisionShaderSupported: boolean;
  83837. /** Defines if depth reading in the fragment shader is supported */
  83838. fragmentDepthSupported: boolean;
  83839. /** Defines if float texture linear filtering is supported*/
  83840. textureFloatLinearFiltering: boolean;
  83841. /** Defines if rendering to float textures is supported */
  83842. textureFloatRender: boolean;
  83843. /** Defines if half float textures are supported*/
  83844. textureHalfFloat: boolean;
  83845. /** Defines if half float texture linear filtering is supported*/
  83846. textureHalfFloatLinearFiltering: boolean;
  83847. /** Defines if rendering to half float textures is supported */
  83848. textureHalfFloatRender: boolean;
  83849. /** Defines if textureLOD shader command is supported */
  83850. textureLOD: boolean;
  83851. /** Defines if draw buffers extension is supported */
  83852. drawBuffersExtension: boolean;
  83853. /** Defines if depth textures are supported */
  83854. depthTextureExtension: boolean;
  83855. /** Defines if float color buffer are supported */
  83856. colorBufferFloat: boolean;
  83857. /** Gets disjoint timer query extension (null if not supported) */
  83858. timerQuery: EXT_disjoint_timer_query;
  83859. /** Defines if timestamp can be used with timer query */
  83860. canUseTimestampForTimerQuery: boolean;
  83861. /** Function used to let the system compiles shaders in background */
  83862. parallelShaderCompile: {
  83863. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83864. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83865. COMPLETION_STATUS_KHR: number;
  83866. };
  83867. }
  83868. /** Interface defining initialization parameters for Engine class */
  83869. export interface EngineOptions extends WebGLContextAttributes {
  83870. /**
  83871. * Defines if the engine should no exceed a specified device ratio
  83872. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83873. */
  83874. limitDeviceRatio?: number;
  83875. /**
  83876. * Defines if webvr should be enabled automatically
  83877. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83878. */
  83879. autoEnableWebVR?: boolean;
  83880. /**
  83881. * Defines if webgl2 should be turned off even if supported
  83882. * @see http://doc.babylonjs.com/features/webgl2
  83883. */
  83884. disableWebGL2Support?: boolean;
  83885. /**
  83886. * Defines if webaudio should be initialized as well
  83887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83888. */
  83889. audioEngine?: boolean;
  83890. /**
  83891. * Defines if animations should run using a deterministic lock step
  83892. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83893. */
  83894. deterministicLockstep?: boolean;
  83895. /** Defines the maximum steps to use with deterministic lock step mode */
  83896. lockstepMaxSteps?: number;
  83897. /**
  83898. * Defines that engine should ignore context lost events
  83899. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83900. */
  83901. doNotHandleContextLost?: boolean;
  83902. /**
  83903. * Defines that engine should ignore modifying touch action attribute and style
  83904. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83905. */
  83906. doNotHandleTouchAction?: boolean;
  83907. }
  83908. /**
  83909. * Defines the interface used by display changed events
  83910. */
  83911. export interface IDisplayChangedEventArgs {
  83912. /** Gets the vrDisplay object (if any) */
  83913. vrDisplay: Nullable<any>;
  83914. /** Gets a boolean indicating if webVR is supported */
  83915. vrSupported: boolean;
  83916. }
  83917. /**
  83918. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83919. */
  83920. export class Engine {
  83921. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83922. static ExceptionList: ({
  83923. key: string;
  83924. capture: string;
  83925. captureConstraint: number;
  83926. targets: string[];
  83927. } | {
  83928. key: string;
  83929. capture: null;
  83930. captureConstraint: null;
  83931. targets: string[];
  83932. })[];
  83933. /** Gets the list of created engines */
  83934. static readonly Instances: Engine[];
  83935. /**
  83936. * Gets the latest created engine
  83937. */
  83938. static readonly LastCreatedEngine: Nullable<Engine>;
  83939. /**
  83940. * Gets the latest created scene
  83941. */
  83942. static readonly LastCreatedScene: Nullable<Scene>;
  83943. /**
  83944. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83945. * @param flag defines which part of the materials must be marked as dirty
  83946. * @param predicate defines a predicate used to filter which materials should be affected
  83947. */
  83948. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83949. /**
  83950. * Hidden
  83951. */
  83952. static _TextureLoaders: IInternalTextureLoader[];
  83953. /** Defines that alpha blending is disabled */
  83954. static readonly ALPHA_DISABLE: number;
  83955. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83956. static readonly ALPHA_ADD: number;
  83957. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83958. static readonly ALPHA_COMBINE: number;
  83959. /** Defines that alpha blending to DEST - SRC * DEST */
  83960. static readonly ALPHA_SUBTRACT: number;
  83961. /** Defines that alpha blending to SRC * DEST */
  83962. static readonly ALPHA_MULTIPLY: number;
  83963. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83964. static readonly ALPHA_MAXIMIZED: number;
  83965. /** Defines that alpha blending to SRC + DEST */
  83966. static readonly ALPHA_ONEONE: number;
  83967. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83968. static readonly ALPHA_PREMULTIPLIED: number;
  83969. /**
  83970. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83971. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83972. */
  83973. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83974. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83975. static readonly ALPHA_INTERPOLATE: number;
  83976. /**
  83977. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83978. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83979. */
  83980. static readonly ALPHA_SCREENMODE: number;
  83981. /** Defines that the ressource is not delayed*/
  83982. static readonly DELAYLOADSTATE_NONE: number;
  83983. /** Defines that the ressource was successfully delay loaded */
  83984. static readonly DELAYLOADSTATE_LOADED: number;
  83985. /** Defines that the ressource is currently delay loading */
  83986. static readonly DELAYLOADSTATE_LOADING: number;
  83987. /** Defines that the ressource is delayed and has not started loading */
  83988. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83989. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83990. static readonly NEVER: number;
  83991. /** 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 */
  83992. static readonly ALWAYS: number;
  83993. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83994. static readonly LESS: number;
  83995. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83996. static readonly EQUAL: number;
  83997. /** 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 */
  83998. static readonly LEQUAL: number;
  83999. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  84000. static readonly GREATER: number;
  84001. /** 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 */
  84002. static readonly GEQUAL: number;
  84003. /** 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 */
  84004. static readonly NOTEQUAL: number;
  84005. /** Passed to stencilOperation to specify that stencil value must be kept */
  84006. static readonly KEEP: number;
  84007. /** Passed to stencilOperation to specify that stencil value must be replaced */
  84008. static readonly REPLACE: number;
  84009. /** Passed to stencilOperation to specify that stencil value must be incremented */
  84010. static readonly INCR: number;
  84011. /** Passed to stencilOperation to specify that stencil value must be decremented */
  84012. static readonly DECR: number;
  84013. /** Passed to stencilOperation to specify that stencil value must be inverted */
  84014. static readonly INVERT: number;
  84015. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  84016. static readonly INCR_WRAP: number;
  84017. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  84018. static readonly DECR_WRAP: number;
  84019. /** Texture is not repeating outside of 0..1 UVs */
  84020. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  84021. /** Texture is repeating outside of 0..1 UVs */
  84022. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  84023. /** Texture is repeating and mirrored */
  84024. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  84025. /** ALPHA */
  84026. static readonly TEXTUREFORMAT_ALPHA: number;
  84027. /** LUMINANCE */
  84028. static readonly TEXTUREFORMAT_LUMINANCE: number;
  84029. /** LUMINANCE_ALPHA */
  84030. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  84031. /** RGB */
  84032. static readonly TEXTUREFORMAT_RGB: number;
  84033. /** RGBA */
  84034. static readonly TEXTUREFORMAT_RGBA: number;
  84035. /** RED */
  84036. static readonly TEXTUREFORMAT_RED: number;
  84037. /** RED (2nd reference) */
  84038. static readonly TEXTUREFORMAT_R: number;
  84039. /** RG */
  84040. static readonly TEXTUREFORMAT_RG: number;
  84041. /** RED_INTEGER */
  84042. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  84043. /** RED_INTEGER (2nd reference) */
  84044. static readonly TEXTUREFORMAT_R_INTEGER: number;
  84045. /** RG_INTEGER */
  84046. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  84047. /** RGB_INTEGER */
  84048. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  84049. /** RGBA_INTEGER */
  84050. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  84051. /** UNSIGNED_BYTE */
  84052. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  84053. /** UNSIGNED_BYTE (2nd reference) */
  84054. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  84055. /** FLOAT */
  84056. static readonly TEXTURETYPE_FLOAT: number;
  84057. /** HALF_FLOAT */
  84058. static readonly TEXTURETYPE_HALF_FLOAT: number;
  84059. /** BYTE */
  84060. static readonly TEXTURETYPE_BYTE: number;
  84061. /** SHORT */
  84062. static readonly TEXTURETYPE_SHORT: number;
  84063. /** UNSIGNED_SHORT */
  84064. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  84065. /** INT */
  84066. static readonly TEXTURETYPE_INT: number;
  84067. /** UNSIGNED_INT */
  84068. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  84069. /** UNSIGNED_SHORT_4_4_4_4 */
  84070. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  84071. /** UNSIGNED_SHORT_5_5_5_1 */
  84072. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  84073. /** UNSIGNED_SHORT_5_6_5 */
  84074. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  84075. /** UNSIGNED_INT_2_10_10_10_REV */
  84076. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  84077. /** UNSIGNED_INT_24_8 */
  84078. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  84079. /** UNSIGNED_INT_10F_11F_11F_REV */
  84080. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  84081. /** UNSIGNED_INT_5_9_9_9_REV */
  84082. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  84083. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  84084. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  84085. /** nearest is mag = nearest and min = nearest and mip = linear */
  84086. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  84087. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84088. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  84089. /** Trilinear is mag = linear and min = linear and mip = linear */
  84090. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  84091. /** nearest is mag = nearest and min = nearest and mip = linear */
  84092. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  84093. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84094. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  84095. /** Trilinear is mag = linear and min = linear and mip = linear */
  84096. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  84097. /** mag = nearest and min = nearest and mip = nearest */
  84098. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  84099. /** mag = nearest and min = linear and mip = nearest */
  84100. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  84101. /** mag = nearest and min = linear and mip = linear */
  84102. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  84103. /** mag = nearest and min = linear and mip = none */
  84104. static readonly TEXTURE_NEAREST_LINEAR: number;
  84105. /** mag = nearest and min = nearest and mip = none */
  84106. static readonly TEXTURE_NEAREST_NEAREST: number;
  84107. /** mag = linear and min = nearest and mip = nearest */
  84108. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  84109. /** mag = linear and min = nearest and mip = linear */
  84110. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  84111. /** mag = linear and min = linear and mip = none */
  84112. static readonly TEXTURE_LINEAR_LINEAR: number;
  84113. /** mag = linear and min = nearest and mip = none */
  84114. static readonly TEXTURE_LINEAR_NEAREST: number;
  84115. /** Explicit coordinates mode */
  84116. static readonly TEXTURE_EXPLICIT_MODE: number;
  84117. /** Spherical coordinates mode */
  84118. static readonly TEXTURE_SPHERICAL_MODE: number;
  84119. /** Planar coordinates mode */
  84120. static readonly TEXTURE_PLANAR_MODE: number;
  84121. /** Cubic coordinates mode */
  84122. static readonly TEXTURE_CUBIC_MODE: number;
  84123. /** Projection coordinates mode */
  84124. static readonly TEXTURE_PROJECTION_MODE: number;
  84125. /** Skybox coordinates mode */
  84126. static readonly TEXTURE_SKYBOX_MODE: number;
  84127. /** Inverse Cubic coordinates mode */
  84128. static readonly TEXTURE_INVCUBIC_MODE: number;
  84129. /** Equirectangular coordinates mode */
  84130. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  84131. /** Equirectangular Fixed coordinates mode */
  84132. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  84133. /** Equirectangular Fixed Mirrored coordinates mode */
  84134. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84135. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  84136. static readonly SCALEMODE_FLOOR: number;
  84137. /** Defines that texture rescaling will look for the nearest power of 2 size */
  84138. static readonly SCALEMODE_NEAREST: number;
  84139. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  84140. static readonly SCALEMODE_CEILING: number;
  84141. /**
  84142. * Returns the current version of the framework
  84143. */
  84144. static readonly Version: string;
  84145. /**
  84146. * Returns a string describing the current engine
  84147. */
  84148. readonly description: string;
  84149. /**
  84150. * Gets or sets the epsilon value used by collision engine
  84151. */
  84152. static CollisionsEpsilon: number;
  84153. /**
  84154. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84155. */
  84156. static ShadersRepository: string;
  84157. /**
  84158. * Method called to create the default loading screen.
  84159. * This can be overriden in your own app.
  84160. * @param canvas The rendering canvas element
  84161. * @returns The loading screen
  84162. */
  84163. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  84164. /**
  84165. * Method called to create the default rescale post process on each engine.
  84166. */
  84167. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  84168. /**
  84169. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  84170. */
  84171. forcePOTTextures: boolean;
  84172. /**
  84173. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  84174. */
  84175. isFullscreen: boolean;
  84176. /**
  84177. * Gets a boolean indicating if the pointer is currently locked
  84178. */
  84179. isPointerLock: boolean;
  84180. /**
  84181. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  84182. */
  84183. cullBackFaces: boolean;
  84184. /**
  84185. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  84186. */
  84187. renderEvenInBackground: boolean;
  84188. /**
  84189. * Gets or sets a boolean indicating that cache can be kept between frames
  84190. */
  84191. preventCacheWipeBetweenFrames: boolean;
  84192. /**
  84193. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  84194. **/
  84195. enableOfflineSupport: boolean;
  84196. /**
  84197. * 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)
  84198. **/
  84199. disableManifestCheck: boolean;
  84200. /**
  84201. * Gets the list of created scenes
  84202. */
  84203. scenes: Scene[];
  84204. /**
  84205. * Event raised when a new scene is created
  84206. */
  84207. onNewSceneAddedObservable: Observable<Scene>;
  84208. /**
  84209. * Gets the list of created postprocesses
  84210. */
  84211. postProcesses: PostProcess[];
  84212. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  84213. validateShaderPrograms: boolean;
  84214. /**
  84215. * Observable event triggered each time the rendering canvas is resized
  84216. */
  84217. onResizeObservable: Observable<Engine>;
  84218. /**
  84219. * Observable event triggered each time the canvas loses focus
  84220. */
  84221. onCanvasBlurObservable: Observable<Engine>;
  84222. /**
  84223. * Observable event triggered each time the canvas gains focus
  84224. */
  84225. onCanvasFocusObservable: Observable<Engine>;
  84226. /**
  84227. * Observable event triggered each time the canvas receives pointerout event
  84228. */
  84229. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84230. /**
  84231. * Observable event triggered before each texture is initialized
  84232. */
  84233. onBeforeTextureInitObservable: Observable<Texture>;
  84234. private _vrDisplay;
  84235. private _vrSupported;
  84236. private _oldSize;
  84237. private _oldHardwareScaleFactor;
  84238. private _vrExclusivePointerMode;
  84239. private _webVRInitPromise;
  84240. /**
  84241. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84242. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84243. */
  84244. readonly isInVRExclusivePointerMode: boolean;
  84245. /**
  84246. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84247. */
  84248. disableUniformBuffers: boolean;
  84249. /** @hidden */
  84250. _uniformBuffers: UniformBuffer[];
  84251. /**
  84252. * Gets a boolean indicating that the engine supports uniform buffers
  84253. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84254. */
  84255. readonly supportsUniformBuffers: boolean;
  84256. /**
  84257. * Observable raised when the engine begins a new frame
  84258. */
  84259. onBeginFrameObservable: Observable<Engine>;
  84260. /**
  84261. * If set, will be used to request the next animation frame for the render loop
  84262. */
  84263. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84264. /**
  84265. * Observable raised when the engine ends the current frame
  84266. */
  84267. onEndFrameObservable: Observable<Engine>;
  84268. /**
  84269. * Observable raised when the engine is about to compile a shader
  84270. */
  84271. onBeforeShaderCompilationObservable: Observable<Engine>;
  84272. /**
  84273. * Observable raised when the engine has jsut compiled a shader
  84274. */
  84275. onAfterShaderCompilationObservable: Observable<Engine>;
  84276. /** @hidden */
  84277. _gl: WebGLRenderingContext;
  84278. private _renderingCanvas;
  84279. private _windowIsBackground;
  84280. private _webGLVersion;
  84281. /**
  84282. * Gets a boolean indicating that only power of 2 textures are supported
  84283. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84284. */
  84285. readonly needPOTTextures: boolean;
  84286. /** @hidden */
  84287. _badOS: boolean;
  84288. /** @hidden */
  84289. _badDesktopOS: boolean;
  84290. /**
  84291. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84292. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84293. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84294. */
  84295. disableTextureBindingOptimization: boolean;
  84296. /**
  84297. * Gets the audio engine
  84298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84299. * @ignorenaming
  84300. */
  84301. static audioEngine: IAudioEngine;
  84302. /**
  84303. * Default AudioEngine factory responsible of creating the Audio Engine.
  84304. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84305. */
  84306. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84307. /**
  84308. * Default offline support factory responsible of creating a tool used to store data locally.
  84309. * By default, this will create a Database object if the workload has been embedded.
  84310. */
  84311. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84312. private _onFocus;
  84313. private _onBlur;
  84314. private _onCanvasPointerOut;
  84315. private _onCanvasBlur;
  84316. private _onCanvasFocus;
  84317. private _onFullscreenChange;
  84318. private _onPointerLockChange;
  84319. private _onVRDisplayPointerRestricted;
  84320. private _onVRDisplayPointerUnrestricted;
  84321. private _onVrDisplayConnect;
  84322. private _onVrDisplayDisconnect;
  84323. private _onVrDisplayPresentChange;
  84324. /**
  84325. * Observable signaled when VR display mode changes
  84326. */
  84327. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84328. /**
  84329. * Observable signaled when VR request present is complete
  84330. */
  84331. onVRRequestPresentComplete: Observable<boolean>;
  84332. /**
  84333. * Observable signaled when VR request present starts
  84334. */
  84335. onVRRequestPresentStart: Observable<Engine>;
  84336. private _hardwareScalingLevel;
  84337. /** @hidden */
  84338. protected _caps: EngineCapabilities;
  84339. private _pointerLockRequested;
  84340. private _isStencilEnable;
  84341. private _colorWrite;
  84342. private _loadingScreen;
  84343. /** @hidden */
  84344. _drawCalls: PerfCounter;
  84345. /** @hidden */
  84346. _textureCollisions: PerfCounter;
  84347. private _glVersion;
  84348. private _glRenderer;
  84349. private _glVendor;
  84350. private _videoTextureSupported;
  84351. private _renderingQueueLaunched;
  84352. private _activeRenderLoops;
  84353. private _deterministicLockstep;
  84354. private _lockstepMaxSteps;
  84355. /**
  84356. * Observable signaled when a context lost event is raised
  84357. */
  84358. onContextLostObservable: Observable<Engine>;
  84359. /**
  84360. * Observable signaled when a context restored event is raised
  84361. */
  84362. onContextRestoredObservable: Observable<Engine>;
  84363. private _onContextLost;
  84364. private _onContextRestored;
  84365. private _contextWasLost;
  84366. private _doNotHandleContextLost;
  84367. /**
  84368. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84370. */
  84371. doNotHandleContextLost: boolean;
  84372. private _performanceMonitor;
  84373. private _fps;
  84374. private _deltaTime;
  84375. /**
  84376. * Turn this value on if you want to pause FPS computation when in background
  84377. */
  84378. disablePerformanceMonitorInBackground: boolean;
  84379. /**
  84380. * Gets the performance monitor attached to this engine
  84381. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84382. */
  84383. readonly performanceMonitor: PerformanceMonitor;
  84384. /** @hidden */
  84385. protected _depthCullingState: _DepthCullingState;
  84386. /** @hidden */
  84387. protected _stencilState: _StencilState;
  84388. /** @hidden */
  84389. protected _alphaState: _AlphaState;
  84390. /** @hidden */
  84391. protected _alphaMode: number;
  84392. protected _internalTexturesCache: InternalTexture[];
  84393. /** @hidden */
  84394. protected _activeChannel: number;
  84395. private _currentTextureChannel;
  84396. /** @hidden */
  84397. protected _boundTexturesCache: {
  84398. [key: string]: Nullable<InternalTexture>;
  84399. };
  84400. /** @hidden */
  84401. protected _currentEffect: Nullable<Effect>;
  84402. /** @hidden */
  84403. protected _currentProgram: Nullable<WebGLProgram>;
  84404. private _compiledEffects;
  84405. private _vertexAttribArraysEnabled;
  84406. /** @hidden */
  84407. protected _cachedViewport: Nullable<Viewport>;
  84408. private _cachedVertexArrayObject;
  84409. /** @hidden */
  84410. protected _cachedVertexBuffers: any;
  84411. /** @hidden */
  84412. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84413. /** @hidden */
  84414. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84415. /** @hidden */
  84416. protected _currentRenderTarget: Nullable<InternalTexture>;
  84417. private _uintIndicesCurrentlySet;
  84418. private _currentBoundBuffer;
  84419. /** @hidden */
  84420. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84421. private _currentBufferPointers;
  84422. private _currentInstanceLocations;
  84423. private _currentInstanceBuffers;
  84424. private _textureUnits;
  84425. private _firstBoundInternalTextureTracker;
  84426. private _lastBoundInternalTextureTracker;
  84427. private _workingCanvas;
  84428. private _workingContext;
  84429. private _rescalePostProcess;
  84430. private _dummyFramebuffer;
  84431. private _externalData;
  84432. private _bindedRenderFunction;
  84433. private _vaoRecordInProgress;
  84434. private _mustWipeVertexAttributes;
  84435. private _emptyTexture;
  84436. private _emptyCubeTexture;
  84437. private _emptyTexture3D;
  84438. /** @hidden */
  84439. _frameHandler: number;
  84440. private _nextFreeTextureSlots;
  84441. private _maxSimultaneousTextures;
  84442. private _activeRequests;
  84443. private _texturesSupported;
  84444. private _textureFormatInUse;
  84445. /**
  84446. * Gets the list of texture formats supported
  84447. */
  84448. readonly texturesSupported: Array<string>;
  84449. /**
  84450. * Gets the list of texture formats in use
  84451. */
  84452. readonly textureFormatInUse: Nullable<string>;
  84453. /**
  84454. * Gets the current viewport
  84455. */
  84456. readonly currentViewport: Nullable<Viewport>;
  84457. /**
  84458. * Gets the default empty texture
  84459. */
  84460. readonly emptyTexture: InternalTexture;
  84461. /**
  84462. * Gets the default empty 3D texture
  84463. */
  84464. readonly emptyTexture3D: InternalTexture;
  84465. /**
  84466. * Gets the default empty cube texture
  84467. */
  84468. readonly emptyCubeTexture: InternalTexture;
  84469. /**
  84470. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84471. */
  84472. readonly premultipliedAlpha: boolean;
  84473. /**
  84474. * Creates a new engine
  84475. * @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
  84476. * @param antialias defines enable antialiasing (default: false)
  84477. * @param options defines further options to be sent to the getContext() function
  84478. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84479. */
  84480. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84481. private _disableTouchAction;
  84482. private _rebuildInternalTextures;
  84483. private _rebuildEffects;
  84484. /**
  84485. * Gets a boolean indicating if all created effects are ready
  84486. * @returns true if all effects are ready
  84487. */
  84488. areAllEffectsReady(): boolean;
  84489. private _rebuildBuffers;
  84490. private _initGLContext;
  84491. /**
  84492. * Gets version of the current webGL context
  84493. */
  84494. readonly webGLVersion: number;
  84495. /**
  84496. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84497. */
  84498. readonly isStencilEnable: boolean;
  84499. private _prepareWorkingCanvas;
  84500. /**
  84501. * Reset the texture cache to empty state
  84502. */
  84503. resetTextureCache(): void;
  84504. /**
  84505. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84506. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84507. * @returns true if engine is in deterministic lock step mode
  84508. */
  84509. isDeterministicLockStep(): boolean;
  84510. /**
  84511. * Gets the max steps when engine is running in deterministic lock step
  84512. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84513. * @returns the max steps
  84514. */
  84515. getLockstepMaxSteps(): number;
  84516. /**
  84517. * Gets an object containing information about the current webGL context
  84518. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84519. */
  84520. getGlInfo(): {
  84521. vendor: string;
  84522. renderer: string;
  84523. version: string;
  84524. };
  84525. /**
  84526. * Gets current aspect ratio
  84527. * @param camera defines the camera to use to get the aspect ratio
  84528. * @param useScreen defines if screen size must be used (or the current render target if any)
  84529. * @returns a number defining the aspect ratio
  84530. */
  84531. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84532. /**
  84533. * Gets current screen aspect ratio
  84534. * @returns a number defining the aspect ratio
  84535. */
  84536. getScreenAspectRatio(): number;
  84537. /**
  84538. * Gets the current render width
  84539. * @param useScreen defines if screen size must be used (or the current render target if any)
  84540. * @returns a number defining the current render width
  84541. */
  84542. getRenderWidth(useScreen?: boolean): number;
  84543. /**
  84544. * Gets the current render height
  84545. * @param useScreen defines if screen size must be used (or the current render target if any)
  84546. * @returns a number defining the current render height
  84547. */
  84548. getRenderHeight(useScreen?: boolean): number;
  84549. /**
  84550. * Gets the HTML canvas attached with the current webGL context
  84551. * @returns a HTML canvas
  84552. */
  84553. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84554. /**
  84555. * Gets the client rect of the HTML canvas attached with the current webGL context
  84556. * @returns a client rectanglee
  84557. */
  84558. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84559. /**
  84560. * Defines the hardware scaling level.
  84561. * By default the hardware scaling level is computed from the window device ratio.
  84562. * 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.
  84563. * @param level defines the level to use
  84564. */
  84565. setHardwareScalingLevel(level: number): void;
  84566. /**
  84567. * Gets the current hardware scaling level.
  84568. * By default the hardware scaling level is computed from the window device ratio.
  84569. * 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.
  84570. * @returns a number indicating the current hardware scaling level
  84571. */
  84572. getHardwareScalingLevel(): number;
  84573. /**
  84574. * Gets the list of loaded textures
  84575. * @returns an array containing all loaded textures
  84576. */
  84577. getLoadedTexturesCache(): InternalTexture[];
  84578. /**
  84579. * Gets the object containing all engine capabilities
  84580. * @returns the EngineCapabilities object
  84581. */
  84582. getCaps(): EngineCapabilities;
  84583. /**
  84584. * Gets the current depth function
  84585. * @returns a number defining the depth function
  84586. */
  84587. getDepthFunction(): Nullable<number>;
  84588. /**
  84589. * Sets the current depth function
  84590. * @param depthFunc defines the function to use
  84591. */
  84592. setDepthFunction(depthFunc: number): void;
  84593. /**
  84594. * Sets the current depth function to GREATER
  84595. */
  84596. setDepthFunctionToGreater(): void;
  84597. /**
  84598. * Sets the current depth function to GEQUAL
  84599. */
  84600. setDepthFunctionToGreaterOrEqual(): void;
  84601. /**
  84602. * Sets the current depth function to LESS
  84603. */
  84604. setDepthFunctionToLess(): void;
  84605. /**
  84606. * Sets the current depth function to LEQUAL
  84607. */
  84608. setDepthFunctionToLessOrEqual(): void;
  84609. /**
  84610. * Gets a boolean indicating if stencil buffer is enabled
  84611. * @returns the current stencil buffer state
  84612. */
  84613. getStencilBuffer(): boolean;
  84614. /**
  84615. * Enable or disable the stencil buffer
  84616. * @param enable defines if the stencil buffer must be enabled or disabled
  84617. */
  84618. setStencilBuffer(enable: boolean): void;
  84619. /**
  84620. * Gets the current stencil mask
  84621. * @returns a number defining the new stencil mask to use
  84622. */
  84623. getStencilMask(): number;
  84624. /**
  84625. * Sets the current stencil mask
  84626. * @param mask defines the new stencil mask to use
  84627. */
  84628. setStencilMask(mask: number): void;
  84629. /**
  84630. * Gets the current stencil function
  84631. * @returns a number defining the stencil function to use
  84632. */
  84633. getStencilFunction(): number;
  84634. /**
  84635. * Gets the current stencil reference value
  84636. * @returns a number defining the stencil reference value to use
  84637. */
  84638. getStencilFunctionReference(): number;
  84639. /**
  84640. * Gets the current stencil mask
  84641. * @returns a number defining the stencil mask to use
  84642. */
  84643. getStencilFunctionMask(): number;
  84644. /**
  84645. * Sets the current stencil function
  84646. * @param stencilFunc defines the new stencil function to use
  84647. */
  84648. setStencilFunction(stencilFunc: number): void;
  84649. /**
  84650. * Sets the current stencil reference
  84651. * @param reference defines the new stencil reference to use
  84652. */
  84653. setStencilFunctionReference(reference: number): void;
  84654. /**
  84655. * Sets the current stencil mask
  84656. * @param mask defines the new stencil mask to use
  84657. */
  84658. setStencilFunctionMask(mask: number): void;
  84659. /**
  84660. * Gets the current stencil operation when stencil fails
  84661. * @returns a number defining stencil operation to use when stencil fails
  84662. */
  84663. getStencilOperationFail(): number;
  84664. /**
  84665. * Gets the current stencil operation when depth fails
  84666. * @returns a number defining stencil operation to use when depth fails
  84667. */
  84668. getStencilOperationDepthFail(): number;
  84669. /**
  84670. * Gets the current stencil operation when stencil passes
  84671. * @returns a number defining stencil operation to use when stencil passes
  84672. */
  84673. getStencilOperationPass(): number;
  84674. /**
  84675. * Sets the stencil operation to use when stencil fails
  84676. * @param operation defines the stencil operation to use when stencil fails
  84677. */
  84678. setStencilOperationFail(operation: number): void;
  84679. /**
  84680. * Sets the stencil operation to use when depth fails
  84681. * @param operation defines the stencil operation to use when depth fails
  84682. */
  84683. setStencilOperationDepthFail(operation: number): void;
  84684. /**
  84685. * Sets the stencil operation to use when stencil passes
  84686. * @param operation defines the stencil operation to use when stencil passes
  84687. */
  84688. setStencilOperationPass(operation: number): void;
  84689. /**
  84690. * Sets a boolean indicating if the dithering state is enabled or disabled
  84691. * @param value defines the dithering state
  84692. */
  84693. setDitheringState(value: boolean): void;
  84694. /**
  84695. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84696. * @param value defines the rasterizer state
  84697. */
  84698. setRasterizerState(value: boolean): void;
  84699. /**
  84700. * stop executing a render loop function and remove it from the execution array
  84701. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84702. */
  84703. stopRenderLoop(renderFunction?: () => void): void;
  84704. /** @hidden */
  84705. _renderLoop(): void;
  84706. /**
  84707. * Register and execute a render loop. The engine can have more than one render function
  84708. * @param renderFunction defines the function to continuously execute
  84709. */
  84710. runRenderLoop(renderFunction: () => void): void;
  84711. /**
  84712. * Toggle full screen mode
  84713. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84714. */
  84715. switchFullscreen(requestPointerLock: boolean): void;
  84716. /**
  84717. * Enters full screen mode
  84718. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84719. */
  84720. enterFullscreen(requestPointerLock: boolean): void;
  84721. /**
  84722. * Exits full screen mode
  84723. */
  84724. exitFullscreen(): void;
  84725. /**
  84726. * Clear the current render buffer or the current render target (if any is set up)
  84727. * @param color defines the color to use
  84728. * @param backBuffer defines if the back buffer must be cleared
  84729. * @param depth defines if the depth buffer must be cleared
  84730. * @param stencil defines if the stencil buffer must be cleared
  84731. */
  84732. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84733. /**
  84734. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84735. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84736. * @param y defines the y-coordinate of the corner of the clear rectangle
  84737. * @param width defines the width of the clear rectangle
  84738. * @param height defines the height of the clear rectangle
  84739. * @param clearColor defines the clear color
  84740. */
  84741. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84742. /**
  84743. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84744. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84745. * @param y defines the y-coordinate of the corner of the clear rectangle
  84746. * @param width defines the width of the clear rectangle
  84747. * @param height defines the height of the clear rectangle
  84748. */
  84749. enableScissor(x: number, y: number, width: number, height: number): void;
  84750. /**
  84751. * Disable previously set scissor test rectangle
  84752. */
  84753. disableScissor(): void;
  84754. private _viewportCached;
  84755. /** @hidden */
  84756. _viewport(x: number, y: number, width: number, height: number): void;
  84757. /**
  84758. * Set the WebGL's viewport
  84759. * @param viewport defines the viewport element to be used
  84760. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84761. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84762. */
  84763. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84764. /**
  84765. * Directly set the WebGL Viewport
  84766. * @param x defines the x coordinate of the viewport (in screen space)
  84767. * @param y defines the y coordinate of the viewport (in screen space)
  84768. * @param width defines the width of the viewport (in screen space)
  84769. * @param height defines the height of the viewport (in screen space)
  84770. * @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
  84771. */
  84772. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84773. /**
  84774. * Begin a new frame
  84775. */
  84776. beginFrame(): void;
  84777. /**
  84778. * Enf the current frame
  84779. */
  84780. endFrame(): void;
  84781. /**
  84782. * Resize the view according to the canvas' size
  84783. */
  84784. resize(): void;
  84785. /**
  84786. * Force a specific size of the canvas
  84787. * @param width defines the new canvas' width
  84788. * @param height defines the new canvas' height
  84789. */
  84790. setSize(width: number, height: number): void;
  84791. /**
  84792. * Gets a boolean indicating if a webVR device was detected
  84793. * @returns true if a webVR device was detected
  84794. */
  84795. isVRDevicePresent(): boolean;
  84796. /**
  84797. * Gets the current webVR device
  84798. * @returns the current webVR device (or null)
  84799. */
  84800. getVRDevice(): any;
  84801. /**
  84802. * Initializes a webVR display and starts listening to display change events
  84803. * The onVRDisplayChangedObservable will be notified upon these changes
  84804. * @returns The onVRDisplayChangedObservable
  84805. */
  84806. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84807. /**
  84808. * Initializes a webVR display and starts listening to display change events
  84809. * The onVRDisplayChangedObservable will be notified upon these changes
  84810. * @returns A promise containing a VRDisplay and if vr is supported
  84811. */
  84812. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84813. /**
  84814. * Call this function to switch to webVR mode
  84815. * Will do nothing if webVR is not supported or if there is no webVR device
  84816. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84817. */
  84818. enableVR(): void;
  84819. /**
  84820. * Call this function to leave webVR mode
  84821. * Will do nothing if webVR is not supported or if there is no webVR device
  84822. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84823. */
  84824. disableVR(): void;
  84825. private _onVRFullScreenTriggered;
  84826. private _getVRDisplaysAsync;
  84827. /**
  84828. * Binds the frame buffer to the specified texture.
  84829. * @param texture The texture to render to or null for the default canvas
  84830. * @param faceIndex The face of the texture to render to in case of cube texture
  84831. * @param requiredWidth The width of the target to render to
  84832. * @param requiredHeight The height of the target to render to
  84833. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84834. * @param depthStencilTexture The depth stencil texture to use to render
  84835. * @param lodLevel defines le lod level to bind to the frame buffer
  84836. */
  84837. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84838. private bindUnboundFramebuffer;
  84839. /**
  84840. * Unbind the current render target texture from the webGL context
  84841. * @param texture defines the render target texture to unbind
  84842. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84843. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84844. */
  84845. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84846. /**
  84847. * Unbind a list of render target textures from the webGL context
  84848. * This is used only when drawBuffer extension or webGL2 are active
  84849. * @param textures defines the render target textures to unbind
  84850. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84851. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84852. */
  84853. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84854. /**
  84855. * Force the mipmap generation for the given render target texture
  84856. * @param texture defines the render target texture to use
  84857. */
  84858. generateMipMapsForCubemap(texture: InternalTexture): void;
  84859. /**
  84860. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84861. */
  84862. flushFramebuffer(): void;
  84863. /**
  84864. * Unbind the current render target and bind the default framebuffer
  84865. */
  84866. restoreDefaultFramebuffer(): void;
  84867. /**
  84868. * Create an uniform buffer
  84869. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84870. * @param elements defines the content of the uniform buffer
  84871. * @returns the webGL uniform buffer
  84872. */
  84873. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84874. /**
  84875. * Create a dynamic uniform buffer
  84876. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84877. * @param elements defines the content of the uniform buffer
  84878. * @returns the webGL uniform buffer
  84879. */
  84880. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84881. /**
  84882. * Update an existing uniform buffer
  84883. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84884. * @param uniformBuffer defines the target uniform buffer
  84885. * @param elements defines the content to update
  84886. * @param offset defines the offset in the uniform buffer where update should start
  84887. * @param count defines the size of the data to update
  84888. */
  84889. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84890. private _resetVertexBufferBinding;
  84891. /**
  84892. * Creates a vertex buffer
  84893. * @param data the data for the vertex buffer
  84894. * @returns the new WebGL static buffer
  84895. */
  84896. createVertexBuffer(data: DataArray): WebGLBuffer;
  84897. /**
  84898. * Creates a dynamic vertex buffer
  84899. * @param data the data for the dynamic vertex buffer
  84900. * @returns the new WebGL dynamic buffer
  84901. */
  84902. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84903. /**
  84904. * Update a dynamic index buffer
  84905. * @param indexBuffer defines the target index buffer
  84906. * @param indices defines the data to update
  84907. * @param offset defines the offset in the target index buffer where update should start
  84908. */
  84909. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84910. /**
  84911. * Updates a dynamic vertex buffer.
  84912. * @param vertexBuffer the vertex buffer to update
  84913. * @param data the data used to update the vertex buffer
  84914. * @param byteOffset the byte offset of the data
  84915. * @param byteLength the byte length of the data
  84916. */
  84917. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84918. private _resetIndexBufferBinding;
  84919. /**
  84920. * Creates a new index buffer
  84921. * @param indices defines the content of the index buffer
  84922. * @param updatable defines if the index buffer must be updatable
  84923. * @returns a new webGL buffer
  84924. */
  84925. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84926. /**
  84927. * Bind a webGL buffer to the webGL context
  84928. * @param buffer defines the buffer to bind
  84929. */
  84930. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84931. /**
  84932. * Bind an uniform buffer to the current webGL context
  84933. * @param buffer defines the buffer to bind
  84934. */
  84935. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84936. /**
  84937. * Bind a buffer to the current webGL context at a given location
  84938. * @param buffer defines the buffer to bind
  84939. * @param location defines the index where to bind the buffer
  84940. */
  84941. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84942. /**
  84943. * Bind a specific block at a given index in a specific shader program
  84944. * @param shaderProgram defines the shader program
  84945. * @param blockName defines the block name
  84946. * @param index defines the index where to bind the block
  84947. */
  84948. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84949. private bindIndexBuffer;
  84950. private bindBuffer;
  84951. /**
  84952. * update the bound buffer with the given data
  84953. * @param data defines the data to update
  84954. */
  84955. updateArrayBuffer(data: Float32Array): void;
  84956. private _vertexAttribPointer;
  84957. private _bindIndexBufferWithCache;
  84958. private _bindVertexBuffersAttributes;
  84959. /**
  84960. * Records a vertex array object
  84961. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84962. * @param vertexBuffers defines the list of vertex buffers to store
  84963. * @param indexBuffer defines the index buffer to store
  84964. * @param effect defines the effect to store
  84965. * @returns the new vertex array object
  84966. */
  84967. recordVertexArrayObject(vertexBuffers: {
  84968. [key: string]: VertexBuffer;
  84969. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84970. /**
  84971. * Bind a specific vertex array object
  84972. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84973. * @param vertexArrayObject defines the vertex array object to bind
  84974. * @param indexBuffer defines the index buffer to bind
  84975. */
  84976. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84977. /**
  84978. * Bind webGl buffers directly to the webGL context
  84979. * @param vertexBuffer defines the vertex buffer to bind
  84980. * @param indexBuffer defines the index buffer to bind
  84981. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84982. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84983. * @param effect defines the effect associated with the vertex buffer
  84984. */
  84985. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84986. private _unbindVertexArrayObject;
  84987. /**
  84988. * Bind a list of vertex buffers to the webGL context
  84989. * @param vertexBuffers defines the list of vertex buffers to bind
  84990. * @param indexBuffer defines the index buffer to bind
  84991. * @param effect defines the effect associated with the vertex buffers
  84992. */
  84993. bindBuffers(vertexBuffers: {
  84994. [key: string]: Nullable<VertexBuffer>;
  84995. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84996. /**
  84997. * Unbind all instance attributes
  84998. */
  84999. unbindInstanceAttributes(): void;
  85000. /**
  85001. * Release and free the memory of a vertex array object
  85002. * @param vao defines the vertex array object to delete
  85003. */
  85004. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  85005. /** @hidden */
  85006. _releaseBuffer(buffer: WebGLBuffer): boolean;
  85007. /**
  85008. * Creates a webGL buffer to use with instanciation
  85009. * @param capacity defines the size of the buffer
  85010. * @returns the webGL buffer
  85011. */
  85012. createInstancesBuffer(capacity: number): WebGLBuffer;
  85013. /**
  85014. * Delete a webGL buffer used with instanciation
  85015. * @param buffer defines the webGL buffer to delete
  85016. */
  85017. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  85018. /**
  85019. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  85020. * @param instancesBuffer defines the webGL buffer to update and bind
  85021. * @param data defines the data to store in the buffer
  85022. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  85023. */
  85024. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  85025. /**
  85026. * Apply all cached states (depth, culling, stencil and alpha)
  85027. */
  85028. applyStates(): void;
  85029. /**
  85030. * Send a draw order
  85031. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85032. * @param indexStart defines the starting index
  85033. * @param indexCount defines the number of index to draw
  85034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85035. */
  85036. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  85037. /**
  85038. * Draw a list of points
  85039. * @param verticesStart defines the index of first vertex to draw
  85040. * @param verticesCount defines the count of vertices to draw
  85041. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85042. */
  85043. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85044. /**
  85045. * Draw a list of unindexed primitives
  85046. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85047. * @param verticesStart defines the index of first vertex to draw
  85048. * @param verticesCount defines the count of vertices to draw
  85049. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85050. */
  85051. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85052. /**
  85053. * Draw a list of indexed primitives
  85054. * @param fillMode defines the primitive to use
  85055. * @param indexStart defines the starting index
  85056. * @param indexCount defines the number of index to draw
  85057. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85058. */
  85059. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  85060. /**
  85061. * Draw a list of unindexed primitives
  85062. * @param fillMode defines the primitive to use
  85063. * @param verticesStart defines the index of first vertex to draw
  85064. * @param verticesCount defines the count of vertices to draw
  85065. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85066. */
  85067. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85068. private _drawMode;
  85069. /** @hidden */
  85070. _releaseEffect(effect: Effect): void;
  85071. /** @hidden */
  85072. _deleteProgram(program: WebGLProgram): void;
  85073. /**
  85074. * Create a new effect (used to store vertex/fragment shaders)
  85075. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  85076. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  85077. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  85078. * @param samplers defines an array of string used to represent textures
  85079. * @param defines defines the string containing the defines to use to compile the shaders
  85080. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  85081. * @param onCompiled defines a function to call when the effect creation is successful
  85082. * @param onError defines a function to call when the effect creation has failed
  85083. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  85084. * @returns the new Effect
  85085. */
  85086. 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;
  85087. private _compileShader;
  85088. private _compileRawShader;
  85089. /**
  85090. * Directly creates a webGL program
  85091. * @param vertexCode defines the vertex shader code to use
  85092. * @param fragmentCode defines the fragment shader code to use
  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. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85098. /**
  85099. * Creates a webGL program
  85100. * @param vertexCode defines the vertex shader code to use
  85101. * @param fragmentCode defines the fragment shader code to use
  85102. * @param defines defines the string containing the defines to use to compile the shaders
  85103. * @param context defines the webGL context to use (if not set, the current one will be used)
  85104. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85105. * @returns the new webGL program
  85106. */
  85107. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85108. private _createShaderProgram;
  85109. private _finalizeProgram;
  85110. /** @hidden */
  85111. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  85112. /** @hidden */
  85113. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  85114. /**
  85115. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  85116. * @param shaderProgram defines the webGL program to use
  85117. * @param uniformsNames defines the list of uniform names
  85118. * @returns an array of webGL uniform locations
  85119. */
  85120. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  85121. /**
  85122. * Gets the lsit of active attributes for a given webGL program
  85123. * @param shaderProgram defines the webGL program to use
  85124. * @param attributesNames defines the list of attribute names to get
  85125. * @returns an array of indices indicating the offset of each attribute
  85126. */
  85127. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  85128. /**
  85129. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  85130. * @param effect defines the effect to activate
  85131. */
  85132. enableEffect(effect: Nullable<Effect>): void;
  85133. /**
  85134. * Set the value of an uniform to an array of int32
  85135. * @param uniform defines the webGL uniform location where to store the value
  85136. * @param array defines the array of int32 to store
  85137. */
  85138. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85139. /**
  85140. * Set the value of an uniform to an array of int32 (stored as vec2)
  85141. * @param uniform defines the webGL uniform location where to store the value
  85142. * @param array defines the array of int32 to store
  85143. */
  85144. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85145. /**
  85146. * Set the value of an uniform to an array of int32 (stored as vec3)
  85147. * @param uniform defines the webGL uniform location where to store the value
  85148. * @param array defines the array of int32 to store
  85149. */
  85150. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85151. /**
  85152. * Set the value of an uniform to an array of int32 (stored as vec4)
  85153. * @param uniform defines the webGL uniform location where to store the value
  85154. * @param array defines the array of int32 to store
  85155. */
  85156. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85157. /**
  85158. * Set the value of an uniform to an array of float32
  85159. * @param uniform defines the webGL uniform location where to store the value
  85160. * @param array defines the array of float32 to store
  85161. */
  85162. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85163. /**
  85164. * Set the value of an uniform to an array of float32 (stored as vec2)
  85165. * @param uniform defines the webGL uniform location where to store the value
  85166. * @param array defines the array of float32 to store
  85167. */
  85168. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85169. /**
  85170. * Set the value of an uniform to an array of float32 (stored as vec3)
  85171. * @param uniform defines the webGL uniform location where to store the value
  85172. * @param array defines the array of float32 to store
  85173. */
  85174. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85175. /**
  85176. * Set the value of an uniform to an array of float32 (stored as vec4)
  85177. * @param uniform defines the webGL uniform location where to store the value
  85178. * @param array defines the array of float32 to store
  85179. */
  85180. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85181. /**
  85182. * Set the value of an uniform to an array of number
  85183. * @param uniform defines the webGL uniform location where to store the value
  85184. * @param array defines the array of number to store
  85185. */
  85186. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85187. /**
  85188. * Set the value of an uniform to an array of number (stored as vec2)
  85189. * @param uniform defines the webGL uniform location where to store the value
  85190. * @param array defines the array of number to store
  85191. */
  85192. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85193. /**
  85194. * Set the value of an uniform to an array of number (stored as vec3)
  85195. * @param uniform defines the webGL uniform location where to store the value
  85196. * @param array defines the array of number to store
  85197. */
  85198. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85199. /**
  85200. * Set the value of an uniform to an array of number (stored as vec4)
  85201. * @param uniform defines the webGL uniform location where to store the value
  85202. * @param array defines the array of number to store
  85203. */
  85204. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85205. /**
  85206. * Set the value of an uniform to an array of float32 (stored as matrices)
  85207. * @param uniform defines the webGL uniform location where to store the value
  85208. * @param matrices defines the array of float32 to store
  85209. */
  85210. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  85211. /**
  85212. * Set the value of an uniform to a matrix
  85213. * @param uniform defines the webGL uniform location where to store the value
  85214. * @param matrix defines the matrix to store
  85215. */
  85216. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  85217. /**
  85218. * Set the value of an uniform to a matrix (3x3)
  85219. * @param uniform defines the webGL uniform location where to store the value
  85220. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  85221. */
  85222. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85223. /**
  85224. * Set the value of an uniform to a matrix (2x2)
  85225. * @param uniform defines the webGL uniform location where to store the value
  85226. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85227. */
  85228. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85229. /**
  85230. * Set the value of an uniform to a number (int)
  85231. * @param uniform defines the webGL uniform location where to store the value
  85232. * @param value defines the int number to store
  85233. */
  85234. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85235. /**
  85236. * Set the value of an uniform to a number (float)
  85237. * @param uniform defines the webGL uniform location where to store the value
  85238. * @param value defines the float number to store
  85239. */
  85240. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85241. /**
  85242. * Set the value of an uniform to a vec2
  85243. * @param uniform defines the webGL uniform location where to store the value
  85244. * @param x defines the 1st component of the value
  85245. * @param y defines the 2nd component of the value
  85246. */
  85247. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85248. /**
  85249. * Set the value of an uniform to a vec3
  85250. * @param uniform defines the webGL uniform location where to store the value
  85251. * @param x defines the 1st component of the value
  85252. * @param y defines the 2nd component of the value
  85253. * @param z defines the 3rd component of the value
  85254. */
  85255. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85256. /**
  85257. * Set the value of an uniform to a boolean
  85258. * @param uniform defines the webGL uniform location where to store the value
  85259. * @param bool defines the boolean to store
  85260. */
  85261. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85262. /**
  85263. * Set the value of an uniform to a vec4
  85264. * @param uniform defines the webGL uniform location where to store the value
  85265. * @param x defines the 1st component of the value
  85266. * @param y defines the 2nd component of the value
  85267. * @param z defines the 3rd component of the value
  85268. * @param w defines the 4th component of the value
  85269. */
  85270. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85271. /**
  85272. * Set the value of an uniform to a Color3
  85273. * @param uniform defines the webGL uniform location where to store the value
  85274. * @param color3 defines the color to store
  85275. */
  85276. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85277. /**
  85278. * Set the value of an uniform to a Color3 and an alpha value
  85279. * @param uniform defines the webGL uniform location where to store the value
  85280. * @param color3 defines the color to store
  85281. * @param alpha defines the alpha component to store
  85282. */
  85283. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85284. /**
  85285. * Sets a Color4 on a uniform variable
  85286. * @param uniform defines the uniform location
  85287. * @param color4 defines the value to be set
  85288. */
  85289. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85290. /**
  85291. * Set various states to the webGL context
  85292. * @param culling defines backface culling state
  85293. * @param zOffset defines the value to apply to zOffset (0 by default)
  85294. * @param force defines if states must be applied even if cache is up to date
  85295. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85296. */
  85297. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85298. /**
  85299. * Set the z offset to apply to current rendering
  85300. * @param value defines the offset to apply
  85301. */
  85302. setZOffset(value: number): void;
  85303. /**
  85304. * Gets the current value of the zOffset
  85305. * @returns the current zOffset state
  85306. */
  85307. getZOffset(): number;
  85308. /**
  85309. * Enable or disable depth buffering
  85310. * @param enable defines the state to set
  85311. */
  85312. setDepthBuffer(enable: boolean): void;
  85313. /**
  85314. * Gets a boolean indicating if depth writing is enabled
  85315. * @returns the current depth writing state
  85316. */
  85317. getDepthWrite(): boolean;
  85318. /**
  85319. * Enable or disable depth writing
  85320. * @param enable defines the state to set
  85321. */
  85322. setDepthWrite(enable: boolean): void;
  85323. /**
  85324. * Enable or disable color writing
  85325. * @param enable defines the state to set
  85326. */
  85327. setColorWrite(enable: boolean): void;
  85328. /**
  85329. * Gets a boolean indicating if color writing is enabled
  85330. * @returns the current color writing state
  85331. */
  85332. getColorWrite(): boolean;
  85333. /**
  85334. * Sets alpha constants used by some alpha blending modes
  85335. * @param r defines the red component
  85336. * @param g defines the green component
  85337. * @param b defines the blue component
  85338. * @param a defines the alpha component
  85339. */
  85340. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85341. /**
  85342. * Sets the current alpha mode
  85343. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85344. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85346. */
  85347. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85348. /**
  85349. * Gets the current alpha mode
  85350. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85351. * @returns the current alpha mode
  85352. */
  85353. getAlphaMode(): number;
  85354. /**
  85355. * Clears the list of texture accessible through engine.
  85356. * This can help preventing texture load conflict due to name collision.
  85357. */
  85358. clearInternalTexturesCache(): void;
  85359. /**
  85360. * Force the entire cache to be cleared
  85361. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85362. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85363. */
  85364. wipeCaches(bruteForce?: boolean): void;
  85365. /**
  85366. * Set the compressed texture format to use, based on the formats you have, and the formats
  85367. * supported by the hardware / browser.
  85368. *
  85369. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85370. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85371. * to API arguments needed to compressed textures. This puts the burden on the container
  85372. * generator to house the arcane code for determining these for current & future formats.
  85373. *
  85374. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85375. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85376. *
  85377. * Note: The result of this call is not taken into account when a texture is base64.
  85378. *
  85379. * @param formatsAvailable defines the list of those format families you have created
  85380. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85381. *
  85382. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85383. * @returns The extension selected.
  85384. */
  85385. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85386. private _getSamplingParameters;
  85387. private _partialLoadImg;
  85388. private _cascadeLoadImgs;
  85389. /** @hidden */
  85390. _createTexture(): WebGLTexture;
  85391. /**
  85392. * Usually called from Texture.ts.
  85393. * Passed information to create a WebGLTexture
  85394. * @param urlArg defines a value which contains one of the following:
  85395. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85396. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85397. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85398. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85399. * @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)
  85400. * @param scene needed for loading to the correct scene
  85401. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85402. * @param onLoad optional callback to be called upon successful completion
  85403. * @param onError optional callback to be called upon failure
  85404. * @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
  85405. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85406. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85407. * @param forcedExtension defines the extension to use to pick the right loader
  85408. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85409. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85410. */
  85411. 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;
  85412. private _rescaleTexture;
  85413. /**
  85414. * Update a raw texture
  85415. * @param texture defines the texture to update
  85416. * @param data defines the data to store in the texture
  85417. * @param format defines the format of the data
  85418. * @param invertY defines if data must be stored with Y axis inverted
  85419. * @param compression defines the compression used (null by default)
  85420. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85421. */
  85422. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85423. /**
  85424. * Creates a raw texture
  85425. * @param data defines the data to store in the texture
  85426. * @param width defines the width of the texture
  85427. * @param height defines the height of the texture
  85428. * @param format defines the format of the data
  85429. * @param generateMipMaps defines if the engine should generate the mip levels
  85430. * @param invertY defines if data must be stored with Y axis inverted
  85431. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85432. * @param compression defines the compression used (null by default)
  85433. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85434. * @returns the raw texture inside an InternalTexture
  85435. */
  85436. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85437. private _unpackFlipYCached;
  85438. /**
  85439. * In case you are sharing the context with other applications, it might
  85440. * be interested to not cache the unpack flip y state to ensure a consistent
  85441. * value would be set.
  85442. */
  85443. enableUnpackFlipYCached: boolean;
  85444. /** @hidden */
  85445. _unpackFlipY(value: boolean): void;
  85446. /** @hidden */
  85447. _getUnpackAlignement(): number;
  85448. /**
  85449. * Creates a dynamic texture
  85450. * @param width defines the width of the texture
  85451. * @param height defines the height of the texture
  85452. * @param generateMipMaps defines if the engine should generate the mip levels
  85453. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85454. * @returns the dynamic texture inside an InternalTexture
  85455. */
  85456. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85457. /**
  85458. * Update the sampling mode of a given texture
  85459. * @param samplingMode defines the required sampling mode
  85460. * @param texture defines the texture to update
  85461. */
  85462. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85463. /**
  85464. * Update the content of a dynamic texture
  85465. * @param texture defines the texture to update
  85466. * @param canvas defines the canvas containing the source
  85467. * @param invertY defines if data must be stored with Y axis inverted
  85468. * @param premulAlpha defines if alpha is stored as premultiplied
  85469. * @param format defines the format of the data
  85470. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85471. */
  85472. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85473. /**
  85474. * Update a video texture
  85475. * @param texture defines the texture to update
  85476. * @param video defines the video element to use
  85477. * @param invertY defines if data must be stored with Y axis inverted
  85478. */
  85479. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85480. /**
  85481. * Updates a depth texture Comparison Mode and Function.
  85482. * If the comparison Function is equal to 0, the mode will be set to none.
  85483. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85484. * @param texture The texture to set the comparison function for
  85485. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85486. */
  85487. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85488. private _setupDepthStencilTexture;
  85489. /**
  85490. * Creates a depth stencil texture.
  85491. * This is only available in WebGL 2 or with the depth texture extension available.
  85492. * @param size The size of face edge in the texture.
  85493. * @param options The options defining the texture.
  85494. * @returns The texture
  85495. */
  85496. createDepthStencilTexture(size: number | {
  85497. width: number;
  85498. height: number;
  85499. }, options: DepthTextureCreationOptions): InternalTexture;
  85500. /**
  85501. * Creates a depth stencil texture.
  85502. * This is only available in WebGL 2 or with the depth texture extension available.
  85503. * @param size The size of face edge in the texture.
  85504. * @param options The options defining the texture.
  85505. * @returns The texture
  85506. */
  85507. private _createDepthStencilTexture;
  85508. /**
  85509. * Creates a depth stencil cube texture.
  85510. * This is only available in WebGL 2.
  85511. * @param size The size of face edge in the cube texture.
  85512. * @param options The options defining the cube texture.
  85513. * @returns The cube texture
  85514. */
  85515. private _createDepthStencilCubeTexture;
  85516. /**
  85517. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85518. * @param renderTarget The render target to set the frame buffer for
  85519. */
  85520. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85521. /**
  85522. * Creates a new render target texture
  85523. * @param size defines the size of the texture
  85524. * @param options defines the options used to create the texture
  85525. * @returns a new render target texture stored in an InternalTexture
  85526. */
  85527. createRenderTargetTexture(size: number | {
  85528. width: number;
  85529. height: number;
  85530. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85531. /**
  85532. * Create a multi render target texture
  85533. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85534. * @param size defines the size of the texture
  85535. * @param options defines the creation options
  85536. * @returns the cube texture as an InternalTexture
  85537. */
  85538. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85539. private _setupFramebufferDepthAttachments;
  85540. /**
  85541. * Updates the sample count of a render target texture
  85542. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85543. * @param texture defines the texture to update
  85544. * @param samples defines the sample count to set
  85545. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85546. */
  85547. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85548. /**
  85549. * Update the sample count for a given multiple render target texture
  85550. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85551. * @param textures defines the textures to update
  85552. * @param samples defines the sample count to set
  85553. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85554. */
  85555. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85556. /** @hidden */
  85557. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85558. /** @hidden */
  85559. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85560. /** @hidden */
  85561. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85562. /** @hidden */
  85563. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85564. /**
  85565. * Creates a new render target cube texture
  85566. * @param size defines the size of the texture
  85567. * @param options defines the options used to create the texture
  85568. * @returns a new render target cube texture stored in an InternalTexture
  85569. */
  85570. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85571. /**
  85572. * Creates a cube texture
  85573. * @param rootUrl defines the url where the files to load is located
  85574. * @param scene defines the current scene
  85575. * @param files defines the list of files to load (1 per face)
  85576. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85577. * @param onLoad defines an optional callback raised when the texture is loaded
  85578. * @param onError defines an optional callback raised if there is an issue to load the texture
  85579. * @param format defines the format of the data
  85580. * @param forcedExtension defines the extension to use to pick the right loader
  85581. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85582. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85583. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85584. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85585. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85586. * @returns the cube texture as an InternalTexture
  85587. */
  85588. 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;
  85589. /**
  85590. * @hidden
  85591. */
  85592. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85593. /**
  85594. * Update a raw cube texture
  85595. * @param texture defines the texture to udpdate
  85596. * @param data defines the data to store
  85597. * @param format defines the data format
  85598. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85599. * @param invertY defines if data must be stored with Y axis inverted
  85600. * @param compression defines the compression used (null by default)
  85601. * @param level defines which level of the texture to update
  85602. */
  85603. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85604. /**
  85605. * Creates a new raw cube texture
  85606. * @param data defines the array of data to use to create each face
  85607. * @param size defines the size of the textures
  85608. * @param format defines the format of the data
  85609. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85610. * @param generateMipMaps defines if the engine should generate the mip levels
  85611. * @param invertY defines if data must be stored with Y axis inverted
  85612. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85613. * @param compression defines the compression used (null by default)
  85614. * @returns the cube texture as an InternalTexture
  85615. */
  85616. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85617. /**
  85618. * Creates a new raw cube texture from a specified url
  85619. * @param url defines the url where the data is located
  85620. * @param scene defines the current scene
  85621. * @param size defines the size of the textures
  85622. * @param format defines the format of the data
  85623. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85624. * @param noMipmap defines if the engine should avoid generating the mip levels
  85625. * @param callback defines a callback used to extract texture data from loaded data
  85626. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85627. * @param onLoad defines a callback called when texture is loaded
  85628. * @param onError defines a callback called if there is an error
  85629. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85630. * @param invertY defines if data must be stored with Y axis inverted
  85631. * @returns the cube texture as an InternalTexture
  85632. */
  85633. 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;
  85634. /**
  85635. * Update a raw 3D texture
  85636. * @param texture defines the texture to update
  85637. * @param data defines the data to store
  85638. * @param format defines the data format
  85639. * @param invertY defines if data must be stored with Y axis inverted
  85640. * @param compression defines the used compression (can be null)
  85641. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85642. */
  85643. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85644. /**
  85645. * Creates a new raw 3D texture
  85646. * @param data defines the data used to create the texture
  85647. * @param width defines the width of the texture
  85648. * @param height defines the height of the texture
  85649. * @param depth defines the depth of the texture
  85650. * @param format defines the format of the texture
  85651. * @param generateMipMaps defines if the engine must generate mip levels
  85652. * @param invertY defines if data must be stored with Y axis inverted
  85653. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85654. * @param compression defines the compressed used (can be null)
  85655. * @param textureType defines the compressed used (can be null)
  85656. * @returns a new raw 3D texture (stored in an InternalTexture)
  85657. */
  85658. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85659. private _prepareWebGLTextureContinuation;
  85660. private _prepareWebGLTexture;
  85661. private _convertRGBtoRGBATextureData;
  85662. /** @hidden */
  85663. _releaseFramebufferObjects(texture: InternalTexture): void;
  85664. /** @hidden */
  85665. _releaseTexture(texture: InternalTexture): void;
  85666. private setProgram;
  85667. private _boundUniforms;
  85668. /**
  85669. * Binds an effect to the webGL context
  85670. * @param effect defines the effect to bind
  85671. */
  85672. bindSamplers(effect: Effect): void;
  85673. private _moveBoundTextureOnTop;
  85674. private _getCorrectTextureChannel;
  85675. private _linkTrackers;
  85676. private _removeDesignatedSlot;
  85677. private _activateCurrentTexture;
  85678. /** @hidden */
  85679. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85680. /** @hidden */
  85681. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85682. /**
  85683. * Sets a texture to the webGL context from a postprocess
  85684. * @param channel defines the channel to use
  85685. * @param postProcess defines the source postprocess
  85686. */
  85687. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85688. /**
  85689. * Binds the output of the passed in post process to the texture channel specified
  85690. * @param channel The channel the texture should be bound to
  85691. * @param postProcess The post process which's output should be bound
  85692. */
  85693. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85694. /**
  85695. * Unbind all textures from the webGL context
  85696. */
  85697. unbindAllTextures(): void;
  85698. /**
  85699. * Sets a texture to the according uniform.
  85700. * @param channel The texture channel
  85701. * @param uniform The uniform to set
  85702. * @param texture The texture to apply
  85703. */
  85704. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85705. /**
  85706. * Sets a depth stencil texture from a render target to the according uniform.
  85707. * @param channel The texture channel
  85708. * @param uniform The uniform to set
  85709. * @param texture The render target texture containing the depth stencil texture to apply
  85710. */
  85711. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85712. private _bindSamplerUniformToChannel;
  85713. private _getTextureWrapMode;
  85714. private _setTexture;
  85715. /**
  85716. * Sets an array of texture to the webGL context
  85717. * @param channel defines the channel where the texture array must be set
  85718. * @param uniform defines the associated uniform location
  85719. * @param textures defines the array of textures to bind
  85720. */
  85721. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85722. /** @hidden */
  85723. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85724. private _setTextureParameterFloat;
  85725. private _setTextureParameterInteger;
  85726. /**
  85727. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85728. * @param x defines the x coordinate of the rectangle where pixels must be read
  85729. * @param y defines the y coordinate of the rectangle where pixels must be read
  85730. * @param width defines the width of the rectangle where pixels must be read
  85731. * @param height defines the height of the rectangle where pixels must be read
  85732. * @returns a Uint8Array containing RGBA colors
  85733. */
  85734. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85735. /**
  85736. * Add an externaly attached data from its key.
  85737. * This method call will fail and return false, if such key already exists.
  85738. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85739. * @param key the unique key that identifies the data
  85740. * @param data the data object to associate to the key for this Engine instance
  85741. * @return true if no such key were already present and the data was added successfully, false otherwise
  85742. */
  85743. addExternalData<T>(key: string, data: T): boolean;
  85744. /**
  85745. * Get an externaly attached data from its key
  85746. * @param key the unique key that identifies the data
  85747. * @return the associated data, if present (can be null), or undefined if not present
  85748. */
  85749. getExternalData<T>(key: string): T;
  85750. /**
  85751. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85752. * @param key the unique key that identifies the data
  85753. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85754. * @return the associated data, can be null if the factory returned null.
  85755. */
  85756. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85757. /**
  85758. * Remove an externaly attached data from the Engine instance
  85759. * @param key the unique key that identifies the data
  85760. * @return true if the data was successfully removed, false if it doesn't exist
  85761. */
  85762. removeExternalData(key: string): boolean;
  85763. /**
  85764. * Unbind all vertex attributes from the webGL context
  85765. */
  85766. unbindAllAttributes(): void;
  85767. /**
  85768. * 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
  85769. */
  85770. releaseEffects(): void;
  85771. /**
  85772. * Dispose and release all associated resources
  85773. */
  85774. dispose(): void;
  85775. /**
  85776. * Display the loading screen
  85777. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85778. */
  85779. displayLoadingUI(): void;
  85780. /**
  85781. * Hide the loading screen
  85782. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85783. */
  85784. hideLoadingUI(): void;
  85785. /**
  85786. * Gets the current loading screen object
  85787. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85788. */
  85789. /**
  85790. * Sets the current loading screen object
  85791. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85792. */
  85793. loadingScreen: ILoadingScreen;
  85794. /**
  85795. * Sets the current loading screen text
  85796. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85797. */
  85798. loadingUIText: string;
  85799. /**
  85800. * Sets the current loading screen background color
  85801. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85802. */
  85803. loadingUIBackgroundColor: string;
  85804. /**
  85805. * Attach a new callback raised when context lost event is fired
  85806. * @param callback defines the callback to call
  85807. */
  85808. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85809. /**
  85810. * Attach a new callback raised when context restored event is fired
  85811. * @param callback defines the callback to call
  85812. */
  85813. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85814. /**
  85815. * Gets the source code of the vertex shader associated with a specific webGL program
  85816. * @param program defines the program to use
  85817. * @returns a string containing the source code of the vertex shader associated with the program
  85818. */
  85819. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85820. /**
  85821. * Gets the source code of the fragment shader associated with a specific webGL program
  85822. * @param program defines the program to use
  85823. * @returns a string containing the source code of the fragment shader associated with the program
  85824. */
  85825. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85826. /**
  85827. * Get the current error code of the webGL context
  85828. * @returns the error code
  85829. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85830. */
  85831. getError(): number;
  85832. /**
  85833. * Gets the current framerate
  85834. * @returns a number representing the framerate
  85835. */
  85836. getFps(): number;
  85837. /**
  85838. * Gets the time spent between current and previous frame
  85839. * @returns a number representing the delta time in ms
  85840. */
  85841. getDeltaTime(): number;
  85842. private _measureFps;
  85843. /** @hidden */
  85844. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85845. private _canRenderToFloatFramebuffer;
  85846. private _canRenderToHalfFloatFramebuffer;
  85847. private _canRenderToFramebuffer;
  85848. /** @hidden */
  85849. _getWebGLTextureType(type: number): number;
  85850. private _getInternalFormat;
  85851. /** @hidden */
  85852. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85853. /** @hidden */
  85854. _getRGBAMultiSampleBufferFormat(type: number): number;
  85855. /** @hidden */
  85856. _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;
  85857. /** @hidden */
  85858. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85859. private _partialLoadFile;
  85860. private _cascadeLoadFiles;
  85861. /**
  85862. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85863. * @returns true if the engine can be created
  85864. * @ignorenaming
  85865. */
  85866. static isSupported(): boolean;
  85867. }
  85868. }
  85869. declare module BABYLON {
  85870. /**
  85871. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85872. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85873. */
  85874. export class EffectFallbacks {
  85875. private _defines;
  85876. private _currentRank;
  85877. private _maxRank;
  85878. private _mesh;
  85879. /**
  85880. * Removes the fallback from the bound mesh.
  85881. */
  85882. unBindMesh(): void;
  85883. /**
  85884. * Adds a fallback on the specified property.
  85885. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85886. * @param define The name of the define in the shader
  85887. */
  85888. addFallback(rank: number, define: string): void;
  85889. /**
  85890. * Sets the mesh to use CPU skinning when needing to fallback.
  85891. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85892. * @param mesh The mesh to use the fallbacks.
  85893. */
  85894. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85895. /**
  85896. * Checks to see if more fallbacks are still availible.
  85897. */
  85898. readonly isMoreFallbacks: boolean;
  85899. /**
  85900. * Removes the defines that shoould be removed when falling back.
  85901. * @param currentDefines defines the current define statements for the shader.
  85902. * @param effect defines the current effect we try to compile
  85903. * @returns The resulting defines with defines of the current rank removed.
  85904. */
  85905. reduce(currentDefines: string, effect: Effect): string;
  85906. }
  85907. /**
  85908. * Options to be used when creating an effect.
  85909. */
  85910. export class EffectCreationOptions {
  85911. /**
  85912. * Atrributes that will be used in the shader.
  85913. */
  85914. attributes: string[];
  85915. /**
  85916. * Uniform varible names that will be set in the shader.
  85917. */
  85918. uniformsNames: string[];
  85919. /**
  85920. * Uniform buffer varible names that will be set in the shader.
  85921. */
  85922. uniformBuffersNames: string[];
  85923. /**
  85924. * Sampler texture variable names that will be set in the shader.
  85925. */
  85926. samplers: string[];
  85927. /**
  85928. * Define statements that will be set in the shader.
  85929. */
  85930. defines: any;
  85931. /**
  85932. * Possible fallbacks for this effect to improve performance when needed.
  85933. */
  85934. fallbacks: Nullable<EffectFallbacks>;
  85935. /**
  85936. * Callback that will be called when the shader is compiled.
  85937. */
  85938. onCompiled: Nullable<(effect: Effect) => void>;
  85939. /**
  85940. * Callback that will be called if an error occurs during shader compilation.
  85941. */
  85942. onError: Nullable<(effect: Effect, errors: string) => void>;
  85943. /**
  85944. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85945. */
  85946. indexParameters: any;
  85947. /**
  85948. * Max number of lights that can be used in the shader.
  85949. */
  85950. maxSimultaneousLights: number;
  85951. /**
  85952. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85953. */
  85954. transformFeedbackVaryings: Nullable<string[]>;
  85955. }
  85956. /**
  85957. * Effect containing vertex and fragment shader that can be executed on an object.
  85958. */
  85959. export class Effect {
  85960. /**
  85961. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85962. */
  85963. static ShadersRepository: string;
  85964. /**
  85965. * Name of the effect.
  85966. */
  85967. name: any;
  85968. /**
  85969. * String container all the define statements that should be set on the shader.
  85970. */
  85971. defines: string;
  85972. /**
  85973. * Callback that will be called when the shader is compiled.
  85974. */
  85975. onCompiled: Nullable<(effect: Effect) => void>;
  85976. /**
  85977. * Callback that will be called if an error occurs during shader compilation.
  85978. */
  85979. onError: Nullable<(effect: Effect, errors: string) => void>;
  85980. /**
  85981. * Callback that will be called when effect is bound.
  85982. */
  85983. onBind: Nullable<(effect: Effect) => void>;
  85984. /**
  85985. * Unique ID of the effect.
  85986. */
  85987. uniqueId: number;
  85988. /**
  85989. * Observable that will be called when the shader is compiled.
  85990. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85991. */
  85992. onCompileObservable: Observable<Effect>;
  85993. /**
  85994. * Observable that will be called if an error occurs during shader compilation.
  85995. */
  85996. onErrorObservable: Observable<Effect>;
  85997. /** @hidden */
  85998. _onBindObservable: Nullable<Observable<Effect>>;
  85999. /**
  86000. * Observable that will be called when effect is bound.
  86001. */
  86002. readonly onBindObservable: Observable<Effect>;
  86003. /** @hidden */
  86004. _bonesComputationForcedToCPU: boolean;
  86005. private static _uniqueIdSeed;
  86006. private _engine;
  86007. private _uniformBuffersNames;
  86008. private _uniformsNames;
  86009. private _samplers;
  86010. private _isReady;
  86011. private _compilationError;
  86012. private _attributesNames;
  86013. private _attributes;
  86014. private _uniforms;
  86015. /**
  86016. * Key for the effect.
  86017. * @hidden
  86018. */
  86019. _key: string;
  86020. private _indexParameters;
  86021. private _fallbacks;
  86022. private _vertexSourceCode;
  86023. private _fragmentSourceCode;
  86024. private _vertexSourceCodeOverride;
  86025. private _fragmentSourceCodeOverride;
  86026. private _transformFeedbackVaryings;
  86027. /**
  86028. * Compiled shader to webGL program.
  86029. * @hidden
  86030. */
  86031. _program: WebGLProgram;
  86032. private _valueCache;
  86033. private static _baseCache;
  86034. /**
  86035. * Instantiates an effect.
  86036. * An effect can be used to create/manage/execute vertex and fragment shaders.
  86037. * @param baseName Name of the effect.
  86038. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  86039. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  86040. * @param samplers List of sampler variables that will be passed to the shader.
  86041. * @param engine Engine to be used to render the effect
  86042. * @param defines Define statements to be added to the shader.
  86043. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  86044. * @param onCompiled Callback that will be called when the shader is compiled.
  86045. * @param onError Callback that will be called if an error occurs during shader compilation.
  86046. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86047. */
  86048. 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);
  86049. /**
  86050. * Unique key for this effect
  86051. */
  86052. readonly key: string;
  86053. /**
  86054. * If the effect has been compiled and prepared.
  86055. * @returns if the effect is compiled and prepared.
  86056. */
  86057. isReady(): boolean;
  86058. /**
  86059. * The engine the effect was initialized with.
  86060. * @returns the engine.
  86061. */
  86062. getEngine(): Engine;
  86063. /**
  86064. * The compiled webGL program for the effect
  86065. * @returns the webGL program.
  86066. */
  86067. getProgram(): WebGLProgram;
  86068. /**
  86069. * The set of names of attribute variables for the shader.
  86070. * @returns An array of attribute names.
  86071. */
  86072. getAttributesNames(): string[];
  86073. /**
  86074. * Returns the attribute at the given index.
  86075. * @param index The index of the attribute.
  86076. * @returns The location of the attribute.
  86077. */
  86078. getAttributeLocation(index: number): number;
  86079. /**
  86080. * Returns the attribute based on the name of the variable.
  86081. * @param name of the attribute to look up.
  86082. * @returns the attribute location.
  86083. */
  86084. getAttributeLocationByName(name: string): number;
  86085. /**
  86086. * The number of attributes.
  86087. * @returns the numnber of attributes.
  86088. */
  86089. getAttributesCount(): number;
  86090. /**
  86091. * Gets the index of a uniform variable.
  86092. * @param uniformName of the uniform to look up.
  86093. * @returns the index.
  86094. */
  86095. getUniformIndex(uniformName: string): number;
  86096. /**
  86097. * Returns the attribute based on the name of the variable.
  86098. * @param uniformName of the uniform to look up.
  86099. * @returns the location of the uniform.
  86100. */
  86101. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  86102. /**
  86103. * Returns an array of sampler variable names
  86104. * @returns The array of sampler variable neames.
  86105. */
  86106. getSamplers(): string[];
  86107. /**
  86108. * The error from the last compilation.
  86109. * @returns the error string.
  86110. */
  86111. getCompilationError(): string;
  86112. /**
  86113. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  86114. * @param func The callback to be used.
  86115. */
  86116. executeWhenCompiled(func: (effect: Effect) => void): void;
  86117. private _checkIsReady;
  86118. /** @hidden */
  86119. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  86120. /** @hidden */
  86121. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  86122. /** @hidden */
  86123. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  86124. private _processShaderConversion;
  86125. private _processIncludes;
  86126. private _processPrecision;
  86127. /**
  86128. * Recompiles the webGL program
  86129. * @param vertexSourceCode The source code for the vertex shader.
  86130. * @param fragmentSourceCode The source code for the fragment shader.
  86131. * @param onCompiled Callback called when completed.
  86132. * @param onError Callback called on error.
  86133. * @hidden
  86134. */
  86135. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  86136. /**
  86137. * Gets the uniform locations of the the specified variable names
  86138. * @param names THe names of the variables to lookup.
  86139. * @returns Array of locations in the same order as variable names.
  86140. */
  86141. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  86142. /**
  86143. * Prepares the effect
  86144. * @hidden
  86145. */
  86146. _prepareEffect(): void;
  86147. /**
  86148. * Checks if the effect is supported. (Must be called after compilation)
  86149. */
  86150. readonly isSupported: boolean;
  86151. /**
  86152. * Binds a texture to the engine to be used as output of the shader.
  86153. * @param channel Name of the output variable.
  86154. * @param texture Texture to bind.
  86155. * @hidden
  86156. */
  86157. _bindTexture(channel: string, texture: InternalTexture): void;
  86158. /**
  86159. * Sets a texture on the engine to be used in the shader.
  86160. * @param channel Name of the sampler variable.
  86161. * @param texture Texture to set.
  86162. */
  86163. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  86164. /**
  86165. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  86166. * @param channel Name of the sampler variable.
  86167. * @param texture Texture to set.
  86168. */
  86169. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  86170. /**
  86171. * Sets an array of textures on the engine to be used in the shader.
  86172. * @param channel Name of the variable.
  86173. * @param textures Textures to set.
  86174. */
  86175. setTextureArray(channel: string, textures: BaseTexture[]): void;
  86176. /**
  86177. * 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)
  86178. * @param channel Name of the sampler variable.
  86179. * @param postProcess Post process to get the input texture from.
  86180. */
  86181. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  86182. /**
  86183. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  86184. * 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)
  86185. * @param channel Name of the sampler variable.
  86186. * @param postProcess Post process to get the output texture from.
  86187. */
  86188. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  86189. /** @hidden */
  86190. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  86191. /** @hidden */
  86192. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  86193. /** @hidden */
  86194. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  86195. /** @hidden */
  86196. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  86197. /**
  86198. * Binds a buffer to a uniform.
  86199. * @param buffer Buffer to bind.
  86200. * @param name Name of the uniform variable to bind to.
  86201. */
  86202. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  86203. /**
  86204. * Binds block to a uniform.
  86205. * @param blockName Name of the block to bind.
  86206. * @param index Index to bind.
  86207. */
  86208. bindUniformBlock(blockName: string, index: number): void;
  86209. /**
  86210. * Sets an interger value on a uniform variable.
  86211. * @param uniformName Name of the variable.
  86212. * @param value Value to be set.
  86213. * @returns this effect.
  86214. */
  86215. setInt(uniformName: string, value: number): Effect;
  86216. /**
  86217. * Sets an int array on a uniform variable.
  86218. * @param uniformName Name of the variable.
  86219. * @param array array to be set.
  86220. * @returns this effect.
  86221. */
  86222. setIntArray(uniformName: string, array: Int32Array): Effect;
  86223. /**
  86224. * 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)
  86225. * @param uniformName Name of the variable.
  86226. * @param array array to be set.
  86227. * @returns this effect.
  86228. */
  86229. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86230. /**
  86231. * 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)
  86232. * @param uniformName Name of the variable.
  86233. * @param array array to be set.
  86234. * @returns this effect.
  86235. */
  86236. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86237. /**
  86238. * 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)
  86239. * @param uniformName Name of the variable.
  86240. * @param array array to be set.
  86241. * @returns this effect.
  86242. */
  86243. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86244. /**
  86245. * Sets an float array on a uniform variable.
  86246. * @param uniformName Name of the variable.
  86247. * @param array array to be set.
  86248. * @returns this effect.
  86249. */
  86250. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86251. /**
  86252. * 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)
  86253. * @param uniformName Name of the variable.
  86254. * @param array array to be set.
  86255. * @returns this effect.
  86256. */
  86257. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86258. /**
  86259. * 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)
  86260. * @param uniformName Name of the variable.
  86261. * @param array array to be set.
  86262. * @returns this effect.
  86263. */
  86264. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86265. /**
  86266. * 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)
  86267. * @param uniformName Name of the variable.
  86268. * @param array array to be set.
  86269. * @returns this effect.
  86270. */
  86271. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86272. /**
  86273. * Sets an array on a uniform variable.
  86274. * @param uniformName Name of the variable.
  86275. * @param array array to be set.
  86276. * @returns this effect.
  86277. */
  86278. setArray(uniformName: string, array: number[]): Effect;
  86279. /**
  86280. * 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)
  86281. * @param uniformName Name of the variable.
  86282. * @param array array to be set.
  86283. * @returns this effect.
  86284. */
  86285. setArray2(uniformName: string, array: number[]): Effect;
  86286. /**
  86287. * 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)
  86288. * @param uniformName Name of the variable.
  86289. * @param array array to be set.
  86290. * @returns this effect.
  86291. */
  86292. setArray3(uniformName: string, array: number[]): Effect;
  86293. /**
  86294. * 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)
  86295. * @param uniformName Name of the variable.
  86296. * @param array array to be set.
  86297. * @returns this effect.
  86298. */
  86299. setArray4(uniformName: string, array: number[]): Effect;
  86300. /**
  86301. * Sets matrices on a uniform variable.
  86302. * @param uniformName Name of the variable.
  86303. * @param matrices matrices to be set.
  86304. * @returns this effect.
  86305. */
  86306. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86307. /**
  86308. * Sets matrix on a uniform variable.
  86309. * @param uniformName Name of the variable.
  86310. * @param matrix matrix to be set.
  86311. * @returns this effect.
  86312. */
  86313. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86314. /**
  86315. * 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)
  86316. * @param uniformName Name of the variable.
  86317. * @param matrix matrix to be set.
  86318. * @returns this effect.
  86319. */
  86320. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86321. /**
  86322. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86323. * @param uniformName Name of the variable.
  86324. * @param matrix matrix to be set.
  86325. * @returns this effect.
  86326. */
  86327. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86328. /**
  86329. * Sets a float on a uniform variable.
  86330. * @param uniformName Name of the variable.
  86331. * @param value value to be set.
  86332. * @returns this effect.
  86333. */
  86334. setFloat(uniformName: string, value: number): Effect;
  86335. /**
  86336. * Sets a boolean on a uniform variable.
  86337. * @param uniformName Name of the variable.
  86338. * @param bool value to be set.
  86339. * @returns this effect.
  86340. */
  86341. setBool(uniformName: string, bool: boolean): Effect;
  86342. /**
  86343. * Sets a Vector2 on a uniform variable.
  86344. * @param uniformName Name of the variable.
  86345. * @param vector2 vector2 to be set.
  86346. * @returns this effect.
  86347. */
  86348. setVector2(uniformName: string, vector2: Vector2): Effect;
  86349. /**
  86350. * Sets a float2 on a uniform variable.
  86351. * @param uniformName Name of the variable.
  86352. * @param x First float in float2.
  86353. * @param y Second float in float2.
  86354. * @returns this effect.
  86355. */
  86356. setFloat2(uniformName: string, x: number, y: number): Effect;
  86357. /**
  86358. * Sets a Vector3 on a uniform variable.
  86359. * @param uniformName Name of the variable.
  86360. * @param vector3 Value to be set.
  86361. * @returns this effect.
  86362. */
  86363. setVector3(uniformName: string, vector3: Vector3): Effect;
  86364. /**
  86365. * Sets a float3 on a uniform variable.
  86366. * @param uniformName Name of the variable.
  86367. * @param x First float in float3.
  86368. * @param y Second float in float3.
  86369. * @param z Third float in float3.
  86370. * @returns this effect.
  86371. */
  86372. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86373. /**
  86374. * Sets a Vector4 on a uniform variable.
  86375. * @param uniformName Name of the variable.
  86376. * @param vector4 Value to be set.
  86377. * @returns this effect.
  86378. */
  86379. setVector4(uniformName: string, vector4: Vector4): Effect;
  86380. /**
  86381. * Sets a float4 on a uniform variable.
  86382. * @param uniformName Name of the variable.
  86383. * @param x First float in float4.
  86384. * @param y Second float in float4.
  86385. * @param z Third float in float4.
  86386. * @param w Fourth float in float4.
  86387. * @returns this effect.
  86388. */
  86389. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86390. /**
  86391. * Sets a Color3 on a uniform variable.
  86392. * @param uniformName Name of the variable.
  86393. * @param color3 Value to be set.
  86394. * @returns this effect.
  86395. */
  86396. setColor3(uniformName: string, color3: Color3): Effect;
  86397. /**
  86398. * Sets a Color4 on a uniform variable.
  86399. * @param uniformName Name of the variable.
  86400. * @param color3 Value to be set.
  86401. * @param alpha Alpha value to be set.
  86402. * @returns this effect.
  86403. */
  86404. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86405. /**
  86406. * Sets a Color4 on a uniform variable
  86407. * @param uniformName defines the name of the variable
  86408. * @param color4 defines the value to be set
  86409. * @returns this effect.
  86410. */
  86411. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86412. /**
  86413. * This function will add a new shader to the shader store
  86414. * @param name the name of the shader
  86415. * @param pixelShader optional pixel shader content
  86416. * @param vertexShader optional vertex shader content
  86417. */
  86418. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86419. /**
  86420. * Store of each shader (The can be looked up using effect.key)
  86421. */
  86422. static ShadersStore: {
  86423. [key: string]: string;
  86424. };
  86425. /**
  86426. * Store of each included file for a shader (The can be looked up using effect.key)
  86427. */
  86428. static IncludesShadersStore: {
  86429. [key: string]: string;
  86430. };
  86431. /**
  86432. * Resets the cache of effects.
  86433. */
  86434. static ResetCache(): void;
  86435. }
  86436. }
  86437. declare module BABYLON {
  86438. /**
  86439. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86440. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86441. * 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;
  86442. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86443. */
  86444. export class ColorCurves {
  86445. private _dirty;
  86446. private _tempColor;
  86447. private _globalCurve;
  86448. private _highlightsCurve;
  86449. private _midtonesCurve;
  86450. private _shadowsCurve;
  86451. private _positiveCurve;
  86452. private _negativeCurve;
  86453. private _globalHue;
  86454. private _globalDensity;
  86455. private _globalSaturation;
  86456. private _globalExposure;
  86457. /**
  86458. * Gets the global Hue value.
  86459. * 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).
  86460. */
  86461. /**
  86462. * Sets the global Hue value.
  86463. * 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).
  86464. */
  86465. globalHue: number;
  86466. /**
  86467. * Gets the global Density value.
  86468. * 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.
  86469. * Values less than zero provide a filter of opposite hue.
  86470. */
  86471. /**
  86472. * Sets the global Density value.
  86473. * 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.
  86474. * Values less than zero provide a filter of opposite hue.
  86475. */
  86476. globalDensity: number;
  86477. /**
  86478. * Gets the global Saturation value.
  86479. * 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.
  86480. */
  86481. /**
  86482. * Sets the global Saturation value.
  86483. * 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.
  86484. */
  86485. globalSaturation: number;
  86486. /**
  86487. * Gets the global Exposure value.
  86488. * 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.
  86489. */
  86490. /**
  86491. * Sets the global Exposure value.
  86492. * 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.
  86493. */
  86494. globalExposure: number;
  86495. private _highlightsHue;
  86496. private _highlightsDensity;
  86497. private _highlightsSaturation;
  86498. private _highlightsExposure;
  86499. /**
  86500. * Gets the highlights Hue value.
  86501. * 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).
  86502. */
  86503. /**
  86504. * Sets the highlights Hue value.
  86505. * 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).
  86506. */
  86507. highlightsHue: number;
  86508. /**
  86509. * Gets the highlights Density value.
  86510. * 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.
  86511. * Values less than zero provide a filter of opposite hue.
  86512. */
  86513. /**
  86514. * Sets the highlights Density value.
  86515. * 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.
  86516. * Values less than zero provide a filter of opposite hue.
  86517. */
  86518. highlightsDensity: number;
  86519. /**
  86520. * Gets the highlights Saturation value.
  86521. * 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.
  86522. */
  86523. /**
  86524. * Sets the highlights Saturation value.
  86525. * 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.
  86526. */
  86527. highlightsSaturation: number;
  86528. /**
  86529. * Gets the highlights Exposure value.
  86530. * 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.
  86531. */
  86532. /**
  86533. * Sets the highlights Exposure value.
  86534. * 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.
  86535. */
  86536. highlightsExposure: number;
  86537. private _midtonesHue;
  86538. private _midtonesDensity;
  86539. private _midtonesSaturation;
  86540. private _midtonesExposure;
  86541. /**
  86542. * Gets the midtones Hue value.
  86543. * 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).
  86544. */
  86545. /**
  86546. * Sets the midtones Hue value.
  86547. * 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).
  86548. */
  86549. midtonesHue: number;
  86550. /**
  86551. * Gets the midtones Density value.
  86552. * 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.
  86553. * Values less than zero provide a filter of opposite hue.
  86554. */
  86555. /**
  86556. * Sets the midtones Density value.
  86557. * 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.
  86558. * Values less than zero provide a filter of opposite hue.
  86559. */
  86560. midtonesDensity: number;
  86561. /**
  86562. * Gets the midtones Saturation value.
  86563. * 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.
  86564. */
  86565. /**
  86566. * Sets the midtones Saturation value.
  86567. * 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.
  86568. */
  86569. midtonesSaturation: number;
  86570. /**
  86571. * Gets the midtones Exposure value.
  86572. * 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.
  86573. */
  86574. /**
  86575. * Sets the midtones Exposure value.
  86576. * 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.
  86577. */
  86578. midtonesExposure: number;
  86579. private _shadowsHue;
  86580. private _shadowsDensity;
  86581. private _shadowsSaturation;
  86582. private _shadowsExposure;
  86583. /**
  86584. * Gets the shadows Hue value.
  86585. * 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).
  86586. */
  86587. /**
  86588. * Sets the shadows Hue value.
  86589. * 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).
  86590. */
  86591. shadowsHue: number;
  86592. /**
  86593. * Gets the shadows Density value.
  86594. * 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.
  86595. * Values less than zero provide a filter of opposite hue.
  86596. */
  86597. /**
  86598. * Sets the shadows Density value.
  86599. * 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.
  86600. * Values less than zero provide a filter of opposite hue.
  86601. */
  86602. shadowsDensity: number;
  86603. /**
  86604. * Gets the shadows Saturation value.
  86605. * 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.
  86606. */
  86607. /**
  86608. * Sets the shadows Saturation value.
  86609. * 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.
  86610. */
  86611. shadowsSaturation: number;
  86612. /**
  86613. * Gets the shadows Exposure value.
  86614. * 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.
  86615. */
  86616. /**
  86617. * Sets the shadows Exposure value.
  86618. * 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.
  86619. */
  86620. shadowsExposure: number;
  86621. /**
  86622. * Returns the class name
  86623. * @returns The class name
  86624. */
  86625. getClassName(): string;
  86626. /**
  86627. * Binds the color curves to the shader.
  86628. * @param colorCurves The color curve to bind
  86629. * @param effect The effect to bind to
  86630. * @param positiveUniform The positive uniform shader parameter
  86631. * @param neutralUniform The neutral uniform shader parameter
  86632. * @param negativeUniform The negative uniform shader parameter
  86633. */
  86634. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86635. /**
  86636. * Prepare the list of uniforms associated with the ColorCurves effects.
  86637. * @param uniformsList The list of uniforms used in the effect
  86638. */
  86639. static PrepareUniforms(uniformsList: string[]): void;
  86640. /**
  86641. * Returns color grading data based on a hue, density, saturation and exposure value.
  86642. * @param filterHue The hue of the color filter.
  86643. * @param filterDensity The density of the color filter.
  86644. * @param saturation The saturation.
  86645. * @param exposure The exposure.
  86646. * @param result The result data container.
  86647. */
  86648. private getColorGradingDataToRef;
  86649. /**
  86650. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86651. * @param value The input slider value in range [-100,100].
  86652. * @returns Adjusted value.
  86653. */
  86654. private static applyColorGradingSliderNonlinear;
  86655. /**
  86656. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86657. * @param hue The hue (H) input.
  86658. * @param saturation The saturation (S) input.
  86659. * @param brightness The brightness (B) input.
  86660. * @result An RGBA color represented as Vector4.
  86661. */
  86662. private static fromHSBToRef;
  86663. /**
  86664. * Returns a value clamped between min and max
  86665. * @param value The value to clamp
  86666. * @param min The minimum of value
  86667. * @param max The maximum of value
  86668. * @returns The clamped value.
  86669. */
  86670. private static clamp;
  86671. /**
  86672. * Clones the current color curve instance.
  86673. * @return The cloned curves
  86674. */
  86675. clone(): ColorCurves;
  86676. /**
  86677. * Serializes the current color curve instance to a json representation.
  86678. * @return a JSON representation
  86679. */
  86680. serialize(): any;
  86681. /**
  86682. * Parses the color curve from a json representation.
  86683. * @param source the JSON source to parse
  86684. * @return The parsed curves
  86685. */
  86686. static Parse(source: any): ColorCurves;
  86687. }
  86688. }
  86689. declare module BABYLON {
  86690. /**
  86691. * Interface to follow in your material defines to integrate easily the
  86692. * Image proccessing functions.
  86693. * @hidden
  86694. */
  86695. export interface IImageProcessingConfigurationDefines {
  86696. IMAGEPROCESSING: boolean;
  86697. VIGNETTE: boolean;
  86698. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86699. VIGNETTEBLENDMODEOPAQUE: boolean;
  86700. TONEMAPPING: boolean;
  86701. TONEMAPPING_ACES: boolean;
  86702. CONTRAST: boolean;
  86703. EXPOSURE: boolean;
  86704. COLORCURVES: boolean;
  86705. COLORGRADING: boolean;
  86706. COLORGRADING3D: boolean;
  86707. SAMPLER3DGREENDEPTH: boolean;
  86708. SAMPLER3DBGRMAP: boolean;
  86709. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86710. }
  86711. /**
  86712. * @hidden
  86713. */
  86714. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86715. IMAGEPROCESSING: boolean;
  86716. VIGNETTE: boolean;
  86717. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86718. VIGNETTEBLENDMODEOPAQUE: boolean;
  86719. TONEMAPPING: boolean;
  86720. TONEMAPPING_ACES: boolean;
  86721. CONTRAST: boolean;
  86722. COLORCURVES: boolean;
  86723. COLORGRADING: boolean;
  86724. COLORGRADING3D: boolean;
  86725. SAMPLER3DGREENDEPTH: boolean;
  86726. SAMPLER3DBGRMAP: boolean;
  86727. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86728. EXPOSURE: boolean;
  86729. constructor();
  86730. }
  86731. /**
  86732. * This groups together the common properties used for image processing either in direct forward pass
  86733. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86734. * or not.
  86735. */
  86736. export class ImageProcessingConfiguration {
  86737. /**
  86738. * Default tone mapping applied in BabylonJS.
  86739. */
  86740. static readonly TONEMAPPING_STANDARD: number;
  86741. /**
  86742. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86743. * to other engines rendering to increase portability.
  86744. */
  86745. static readonly TONEMAPPING_ACES: number;
  86746. /**
  86747. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86748. */
  86749. colorCurves: Nullable<ColorCurves>;
  86750. private _colorCurvesEnabled;
  86751. /**
  86752. * Gets wether the color curves effect is enabled.
  86753. */
  86754. /**
  86755. * Sets wether the color curves effect is enabled.
  86756. */
  86757. colorCurvesEnabled: boolean;
  86758. private _colorGradingTexture;
  86759. /**
  86760. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86761. */
  86762. /**
  86763. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86764. */
  86765. colorGradingTexture: Nullable<BaseTexture>;
  86766. private _colorGradingEnabled;
  86767. /**
  86768. * Gets wether the color grading effect is enabled.
  86769. */
  86770. /**
  86771. * Sets wether the color grading effect is enabled.
  86772. */
  86773. colorGradingEnabled: boolean;
  86774. private _colorGradingWithGreenDepth;
  86775. /**
  86776. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86777. */
  86778. /**
  86779. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86780. */
  86781. colorGradingWithGreenDepth: boolean;
  86782. private _colorGradingBGR;
  86783. /**
  86784. * Gets wether the color grading texture contains BGR values.
  86785. */
  86786. /**
  86787. * Sets wether the color grading texture contains BGR values.
  86788. */
  86789. colorGradingBGR: boolean;
  86790. /** @hidden */
  86791. _exposure: number;
  86792. /**
  86793. * Gets the Exposure used in the effect.
  86794. */
  86795. /**
  86796. * Sets the Exposure used in the effect.
  86797. */
  86798. exposure: number;
  86799. private _toneMappingEnabled;
  86800. /**
  86801. * Gets wether the tone mapping effect is enabled.
  86802. */
  86803. /**
  86804. * Sets wether the tone mapping effect is enabled.
  86805. */
  86806. toneMappingEnabled: boolean;
  86807. private _toneMappingType;
  86808. /**
  86809. * Gets the type of tone mapping effect.
  86810. */
  86811. /**
  86812. * Sets the type of tone mapping effect used in BabylonJS.
  86813. */
  86814. toneMappingType: number;
  86815. protected _contrast: number;
  86816. /**
  86817. * Gets the contrast used in the effect.
  86818. */
  86819. /**
  86820. * Sets the contrast used in the effect.
  86821. */
  86822. contrast: number;
  86823. /**
  86824. * Vignette stretch size.
  86825. */
  86826. vignetteStretch: number;
  86827. /**
  86828. * Vignette centre X Offset.
  86829. */
  86830. vignetteCentreX: number;
  86831. /**
  86832. * Vignette centre Y Offset.
  86833. */
  86834. vignetteCentreY: number;
  86835. /**
  86836. * Vignette weight or intensity of the vignette effect.
  86837. */
  86838. vignetteWeight: number;
  86839. /**
  86840. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86841. * if vignetteEnabled is set to true.
  86842. */
  86843. vignetteColor: Color4;
  86844. /**
  86845. * Camera field of view used by the Vignette effect.
  86846. */
  86847. vignetteCameraFov: number;
  86848. private _vignetteBlendMode;
  86849. /**
  86850. * Gets the vignette blend mode allowing different kind of effect.
  86851. */
  86852. /**
  86853. * Sets the vignette blend mode allowing different kind of effect.
  86854. */
  86855. vignetteBlendMode: number;
  86856. private _vignetteEnabled;
  86857. /**
  86858. * Gets wether the vignette effect is enabled.
  86859. */
  86860. /**
  86861. * Sets wether the vignette effect is enabled.
  86862. */
  86863. vignetteEnabled: boolean;
  86864. private _applyByPostProcess;
  86865. /**
  86866. * Gets wether the image processing is applied through a post process or not.
  86867. */
  86868. /**
  86869. * Sets wether the image processing is applied through a post process or not.
  86870. */
  86871. applyByPostProcess: boolean;
  86872. private _isEnabled;
  86873. /**
  86874. * Gets wether the image processing is enabled or not.
  86875. */
  86876. /**
  86877. * Sets wether the image processing is enabled or not.
  86878. */
  86879. isEnabled: boolean;
  86880. /**
  86881. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86882. */
  86883. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86884. /**
  86885. * Method called each time the image processing information changes requires to recompile the effect.
  86886. */
  86887. protected _updateParameters(): void;
  86888. /**
  86889. * Gets the current class name.
  86890. * @return "ImageProcessingConfiguration"
  86891. */
  86892. getClassName(): string;
  86893. /**
  86894. * Prepare the list of uniforms associated with the Image Processing effects.
  86895. * @param uniforms The list of uniforms used in the effect
  86896. * @param defines the list of defines currently in use
  86897. */
  86898. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86899. /**
  86900. * Prepare the list of samplers associated with the Image Processing effects.
  86901. * @param samplersList The list of uniforms used in the effect
  86902. * @param defines the list of defines currently in use
  86903. */
  86904. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86905. /**
  86906. * Prepare the list of defines associated to the shader.
  86907. * @param defines the list of defines to complete
  86908. * @param forPostProcess Define if we are currently in post process mode or not
  86909. */
  86910. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86911. /**
  86912. * Returns true if all the image processing information are ready.
  86913. * @returns True if ready, otherwise, false
  86914. */
  86915. isReady(): boolean;
  86916. /**
  86917. * Binds the image processing to the shader.
  86918. * @param effect The effect to bind to
  86919. * @param aspectRatio Define the current aspect ratio of the effect
  86920. */
  86921. bind(effect: Effect, aspectRatio?: number): void;
  86922. /**
  86923. * Clones the current image processing instance.
  86924. * @return The cloned image processing
  86925. */
  86926. clone(): ImageProcessingConfiguration;
  86927. /**
  86928. * Serializes the current image processing instance to a json representation.
  86929. * @return a JSON representation
  86930. */
  86931. serialize(): any;
  86932. /**
  86933. * Parses the image processing from a json representation.
  86934. * @param source the JSON source to parse
  86935. * @return The parsed image processing
  86936. */
  86937. static Parse(source: any): ImageProcessingConfiguration;
  86938. private static _VIGNETTEMODE_MULTIPLY;
  86939. private static _VIGNETTEMODE_OPAQUE;
  86940. /**
  86941. * Used to apply the vignette as a mix with the pixel color.
  86942. */
  86943. static readonly VIGNETTEMODE_MULTIPLY: number;
  86944. /**
  86945. * Used to apply the vignette as a replacement of the pixel color.
  86946. */
  86947. static readonly VIGNETTEMODE_OPAQUE: number;
  86948. }
  86949. }
  86950. declare module BABYLON {
  86951. /**
  86952. * This represents all the required information to add a fresnel effect on a material:
  86953. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86954. */
  86955. export class FresnelParameters {
  86956. private _isEnabled;
  86957. /**
  86958. * Define if the fresnel effect is enable or not.
  86959. */
  86960. isEnabled: boolean;
  86961. /**
  86962. * Define the color used on edges (grazing angle)
  86963. */
  86964. leftColor: Color3;
  86965. /**
  86966. * Define the color used on center
  86967. */
  86968. rightColor: Color3;
  86969. /**
  86970. * Define bias applied to computed fresnel term
  86971. */
  86972. bias: number;
  86973. /**
  86974. * Defined the power exponent applied to fresnel term
  86975. */
  86976. power: number;
  86977. /**
  86978. * Clones the current fresnel and its valuues
  86979. * @returns a clone fresnel configuration
  86980. */
  86981. clone(): FresnelParameters;
  86982. /**
  86983. * Serializes the current fresnel parameters to a JSON representation.
  86984. * @return the JSON serialization
  86985. */
  86986. serialize(): any;
  86987. /**
  86988. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86989. * @param parsedFresnelParameters Define the JSON representation
  86990. * @returns the parsed parameters
  86991. */
  86992. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86993. }
  86994. }
  86995. declare module BABYLON {
  86996. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86997. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86998. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86999. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87000. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87001. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87002. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87003. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87004. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87005. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87006. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87007. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87008. /**
  87009. * Decorator used to define property that can be serialized as reference to a camera
  87010. * @param sourceName defines the name of the property to decorate
  87011. */
  87012. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87013. /**
  87014. * Class used to help serialization objects
  87015. */
  87016. export class SerializationHelper {
  87017. /** hidden */
  87018. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  87019. /** hidden */
  87020. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  87021. /** hidden */
  87022. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  87023. /** hidden */
  87024. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  87025. /**
  87026. * Appends the serialized animations from the source animations
  87027. * @param source Source containing the animations
  87028. * @param destination Target to store the animations
  87029. */
  87030. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  87031. /**
  87032. * Static function used to serialized a specific entity
  87033. * @param entity defines the entity to serialize
  87034. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  87035. * @returns a JSON compatible object representing the serialization of the entity
  87036. */
  87037. static Serialize<T>(entity: T, serializationObject?: any): any;
  87038. /**
  87039. * Creates a new entity from a serialization data object
  87040. * @param creationFunction defines a function used to instanciated the new entity
  87041. * @param source defines the source serialization data
  87042. * @param scene defines the hosting scene
  87043. * @param rootUrl defines the root url for resources
  87044. * @returns a new entity
  87045. */
  87046. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  87047. /**
  87048. * Clones an object
  87049. * @param creationFunction defines the function used to instanciate the new object
  87050. * @param source defines the source object
  87051. * @returns the cloned object
  87052. */
  87053. static Clone<T>(creationFunction: () => T, source: T): T;
  87054. /**
  87055. * Instanciates a new object based on a source one (some data will be shared between both object)
  87056. * @param creationFunction defines the function used to instanciate the new object
  87057. * @param source defines the source object
  87058. * @returns the new object
  87059. */
  87060. static Instanciate<T>(creationFunction: () => T, source: T): T;
  87061. }
  87062. }
  87063. declare module BABYLON {
  87064. /**
  87065. * This is the base class of all the camera used in the application.
  87066. * @see http://doc.babylonjs.com/features/cameras
  87067. */
  87068. export class Camera extends Node {
  87069. /** @hidden */
  87070. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  87071. /**
  87072. * This is the default projection mode used by the cameras.
  87073. * It helps recreating a feeling of perspective and better appreciate depth.
  87074. * This is the best way to simulate real life cameras.
  87075. */
  87076. static readonly PERSPECTIVE_CAMERA: number;
  87077. /**
  87078. * This helps creating camera with an orthographic mode.
  87079. * 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.
  87080. */
  87081. static readonly ORTHOGRAPHIC_CAMERA: number;
  87082. /**
  87083. * This is the default FOV mode for perspective cameras.
  87084. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  87085. */
  87086. static readonly FOVMODE_VERTICAL_FIXED: number;
  87087. /**
  87088. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  87089. */
  87090. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  87091. /**
  87092. * This specifies ther is no need for a camera rig.
  87093. * Basically only one eye is rendered corresponding to the camera.
  87094. */
  87095. static readonly RIG_MODE_NONE: number;
  87096. /**
  87097. * Simulates a camera Rig with one blue eye and one red eye.
  87098. * This can be use with 3d blue and red glasses.
  87099. */
  87100. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  87101. /**
  87102. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  87103. */
  87104. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  87105. /**
  87106. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  87107. */
  87108. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  87109. /**
  87110. * Defines that both eyes of the camera will be rendered over under each other.
  87111. */
  87112. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  87113. /**
  87114. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  87115. */
  87116. static readonly RIG_MODE_VR: number;
  87117. /**
  87118. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  87119. */
  87120. static readonly RIG_MODE_WEBVR: number;
  87121. /**
  87122. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  87123. */
  87124. static readonly RIG_MODE_CUSTOM: number;
  87125. /**
  87126. * Defines if by default attaching controls should prevent the default javascript event to continue.
  87127. */
  87128. static ForceAttachControlToAlwaysPreventDefault: boolean;
  87129. /**
  87130. * @hidden
  87131. * Might be removed once multiview will be a thing
  87132. */
  87133. static UseAlternateWebVRRendering: boolean;
  87134. /**
  87135. * Define the input manager associated with the camera.
  87136. */
  87137. inputs: CameraInputsManager<Camera>;
  87138. /** @hidden */
  87139. _position: Vector3;
  87140. /**
  87141. * Define the current local position of the camera in the scene
  87142. */
  87143. position: Vector3;
  87144. /**
  87145. * The vector the camera should consider as up.
  87146. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  87147. */
  87148. upVector: Vector3;
  87149. /**
  87150. * Define the current limit on the left side for an orthographic camera
  87151. * In scene unit
  87152. */
  87153. orthoLeft: Nullable<number>;
  87154. /**
  87155. * Define the current limit on the right side for an orthographic camera
  87156. * In scene unit
  87157. */
  87158. orthoRight: Nullable<number>;
  87159. /**
  87160. * Define the current limit on the bottom side for an orthographic camera
  87161. * In scene unit
  87162. */
  87163. orthoBottom: Nullable<number>;
  87164. /**
  87165. * Define the current limit on the top side for an orthographic camera
  87166. * In scene unit
  87167. */
  87168. orthoTop: Nullable<number>;
  87169. /**
  87170. * Field Of View is set in Radians. (default is 0.8)
  87171. */
  87172. fov: number;
  87173. /**
  87174. * Define the minimum distance the camera can see from.
  87175. * This is important to note that the depth buffer are not infinite and the closer it starts
  87176. * the more your scene might encounter depth fighting issue.
  87177. */
  87178. minZ: number;
  87179. /**
  87180. * Define the maximum distance the camera can see to.
  87181. * This is important to note that the depth buffer are not infinite and the further it end
  87182. * the more your scene might encounter depth fighting issue.
  87183. */
  87184. maxZ: number;
  87185. /**
  87186. * Define the default inertia of the camera.
  87187. * This helps giving a smooth feeling to the camera movement.
  87188. */
  87189. inertia: number;
  87190. /**
  87191. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  87192. */
  87193. mode: number;
  87194. /**
  87195. * Define wether the camera is intermediate.
  87196. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  87197. */
  87198. isIntermediate: boolean;
  87199. /**
  87200. * Define the viewport of the camera.
  87201. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  87202. */
  87203. viewport: Viewport;
  87204. /**
  87205. * Restricts the camera to viewing objects with the same layerMask.
  87206. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  87207. */
  87208. layerMask: number;
  87209. /**
  87210. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  87211. */
  87212. fovMode: number;
  87213. /**
  87214. * Rig mode of the camera.
  87215. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  87216. * This is normally controlled byt the camera themselves as internal use.
  87217. */
  87218. cameraRigMode: number;
  87219. /**
  87220. * Defines the distance between both "eyes" in case of a RIG
  87221. */
  87222. interaxialDistance: number;
  87223. /**
  87224. * Defines if stereoscopic rendering is done side by side or over under.
  87225. */
  87226. isStereoscopicSideBySide: boolean;
  87227. /**
  87228. * 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
  87229. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87230. * else in the scene.
  87231. */
  87232. customRenderTargets: RenderTargetTexture[];
  87233. /**
  87234. * When set, the camera will render to this render target instead of the default canvas
  87235. */
  87236. outputRenderTarget: Nullable<RenderTargetTexture>;
  87237. /**
  87238. * Observable triggered when the camera view matrix has changed.
  87239. */
  87240. onViewMatrixChangedObservable: Observable<Camera>;
  87241. /**
  87242. * Observable triggered when the camera Projection matrix has changed.
  87243. */
  87244. onProjectionMatrixChangedObservable: Observable<Camera>;
  87245. /**
  87246. * Observable triggered when the inputs have been processed.
  87247. */
  87248. onAfterCheckInputsObservable: Observable<Camera>;
  87249. /**
  87250. * Observable triggered when reset has been called and applied to the camera.
  87251. */
  87252. onRestoreStateObservable: Observable<Camera>;
  87253. /** @hidden */
  87254. _cameraRigParams: any;
  87255. /** @hidden */
  87256. _rigCameras: Camera[];
  87257. /** @hidden */
  87258. _rigPostProcess: Nullable<PostProcess>;
  87259. protected _webvrViewMatrix: Matrix;
  87260. /** @hidden */
  87261. _skipRendering: boolean;
  87262. /** @hidden */
  87263. _alternateCamera: Camera;
  87264. /** @hidden */
  87265. _projectionMatrix: Matrix;
  87266. /** @hidden */
  87267. _postProcesses: Nullable<PostProcess>[];
  87268. /** @hidden */
  87269. _activeMeshes: SmartArray<AbstractMesh>;
  87270. protected _globalPosition: Vector3;
  87271. /** hidden */
  87272. _computedViewMatrix: Matrix;
  87273. private _doNotComputeProjectionMatrix;
  87274. private _transformMatrix;
  87275. private _frustumPlanes;
  87276. private _refreshFrustumPlanes;
  87277. private _storedFov;
  87278. private _stateStored;
  87279. /**
  87280. * Instantiates a new camera object.
  87281. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87282. * @see http://doc.babylonjs.com/features/cameras
  87283. * @param name Defines the name of the camera in the scene
  87284. * @param position Defines the position of the camera
  87285. * @param scene Defines the scene the camera belongs too
  87286. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87287. */
  87288. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87289. /**
  87290. * Store current camera state (fov, position, etc..)
  87291. * @returns the camera
  87292. */
  87293. storeState(): Camera;
  87294. /**
  87295. * Restores the camera state values if it has been stored. You must call storeState() first
  87296. */
  87297. protected _restoreStateValues(): boolean;
  87298. /**
  87299. * Restored camera state. You must call storeState() first.
  87300. * @returns true if restored and false otherwise
  87301. */
  87302. restoreState(): boolean;
  87303. /**
  87304. * Gets the class name of the camera.
  87305. * @returns the class name
  87306. */
  87307. getClassName(): string;
  87308. /** @hidden */
  87309. readonly _isCamera: boolean;
  87310. /**
  87311. * Gets a string representation of the camera useful for debug purpose.
  87312. * @param fullDetails Defines that a more verboe level of logging is required
  87313. * @returns the string representation
  87314. */
  87315. toString(fullDetails?: boolean): string;
  87316. /**
  87317. * Gets the current world space position of the camera.
  87318. */
  87319. readonly globalPosition: Vector3;
  87320. /**
  87321. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87322. * @returns the active meshe list
  87323. */
  87324. getActiveMeshes(): SmartArray<AbstractMesh>;
  87325. /**
  87326. * Check wether a mesh is part of the current active mesh list of the camera
  87327. * @param mesh Defines the mesh to check
  87328. * @returns true if active, false otherwise
  87329. */
  87330. isActiveMesh(mesh: Mesh): boolean;
  87331. /**
  87332. * Is this camera ready to be used/rendered
  87333. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87334. * @return true if the camera is ready
  87335. */
  87336. isReady(completeCheck?: boolean): boolean;
  87337. /** @hidden */
  87338. _initCache(): void;
  87339. /** @hidden */
  87340. _updateCache(ignoreParentClass?: boolean): void;
  87341. /** @hidden */
  87342. _isSynchronized(): boolean;
  87343. /** @hidden */
  87344. _isSynchronizedViewMatrix(): boolean;
  87345. /** @hidden */
  87346. _isSynchronizedProjectionMatrix(): boolean;
  87347. /**
  87348. * Attach the input controls to a specific dom element to get the input from.
  87349. * @param element Defines the element the controls should be listened from
  87350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87351. */
  87352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87353. /**
  87354. * Detach the current controls from the specified dom element.
  87355. * @param element Defines the element to stop listening the inputs from
  87356. */
  87357. detachControl(element: HTMLElement): void;
  87358. /**
  87359. * Update the camera state according to the different inputs gathered during the frame.
  87360. */
  87361. update(): void;
  87362. /** @hidden */
  87363. _checkInputs(): void;
  87364. /** @hidden */
  87365. readonly rigCameras: Camera[];
  87366. /**
  87367. * Gets the post process used by the rig cameras
  87368. */
  87369. readonly rigPostProcess: Nullable<PostProcess>;
  87370. /**
  87371. * Internal, gets the first post proces.
  87372. * @returns the first post process to be run on this camera.
  87373. */
  87374. _getFirstPostProcess(): Nullable<PostProcess>;
  87375. private _cascadePostProcessesToRigCams;
  87376. /**
  87377. * Attach a post process to the camera.
  87378. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87379. * @param postProcess The post process to attach to the camera
  87380. * @param insertAt The position of the post process in case several of them are in use in the scene
  87381. * @returns the position the post process has been inserted at
  87382. */
  87383. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87384. /**
  87385. * Detach a post process to the camera.
  87386. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87387. * @param postProcess The post process to detach from the camera
  87388. */
  87389. detachPostProcess(postProcess: PostProcess): void;
  87390. /**
  87391. * Gets the current world matrix of the camera
  87392. */
  87393. getWorldMatrix(): Matrix;
  87394. /** @hidden */
  87395. _getViewMatrix(): Matrix;
  87396. /**
  87397. * Gets the current view matrix of the camera.
  87398. * @param force forces the camera to recompute the matrix without looking at the cached state
  87399. * @returns the view matrix
  87400. */
  87401. getViewMatrix(force?: boolean): Matrix;
  87402. /**
  87403. * Freeze the projection matrix.
  87404. * It will prevent the cache check of the camera projection compute and can speed up perf
  87405. * if no parameter of the camera are meant to change
  87406. * @param projection Defines manually a projection if necessary
  87407. */
  87408. freezeProjectionMatrix(projection?: Matrix): void;
  87409. /**
  87410. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87411. */
  87412. unfreezeProjectionMatrix(): void;
  87413. /**
  87414. * Gets the current projection matrix of the camera.
  87415. * @param force forces the camera to recompute the matrix without looking at the cached state
  87416. * @returns the projection matrix
  87417. */
  87418. getProjectionMatrix(force?: boolean): Matrix;
  87419. /**
  87420. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87421. * @returns a Matrix
  87422. */
  87423. getTransformationMatrix(): Matrix;
  87424. private _updateFrustumPlanes;
  87425. /**
  87426. * Checks if a cullable object (mesh...) is in the camera frustum
  87427. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87428. * @param target The object to check
  87429. * @returns true if the object is in frustum otherwise false
  87430. */
  87431. isInFrustum(target: ICullable): boolean;
  87432. /**
  87433. * Checks if a cullable object (mesh...) is in the camera frustum
  87434. * Unlike isInFrustum this cheks the full bounding box
  87435. * @param target The object to check
  87436. * @returns true if the object is in frustum otherwise false
  87437. */
  87438. isCompletelyInFrustum(target: ICullable): boolean;
  87439. /**
  87440. * Gets a ray in the forward direction from the camera.
  87441. * @param length Defines the length of the ray to create
  87442. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87443. * @param origin Defines the start point of the ray which defaults to the camera position
  87444. * @returns the forward ray
  87445. */
  87446. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87447. /**
  87448. * Releases resources associated with this node.
  87449. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87450. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87451. */
  87452. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87453. /** @hidden */
  87454. _isLeftCamera: boolean;
  87455. /**
  87456. * Gets the left camera of a rig setup in case of Rigged Camera
  87457. */
  87458. readonly isLeftCamera: boolean;
  87459. /** @hidden */
  87460. _isRightCamera: boolean;
  87461. /**
  87462. * Gets the right camera of a rig setup in case of Rigged Camera
  87463. */
  87464. readonly isRightCamera: boolean;
  87465. /**
  87466. * Gets the left camera of a rig setup in case of Rigged Camera
  87467. */
  87468. readonly leftCamera: Nullable<FreeCamera>;
  87469. /**
  87470. * Gets the right camera of a rig setup in case of Rigged Camera
  87471. */
  87472. readonly rightCamera: Nullable<FreeCamera>;
  87473. /**
  87474. * Gets the left camera target of a rig setup in case of Rigged Camera
  87475. * @returns the target position
  87476. */
  87477. getLeftTarget(): Nullable<Vector3>;
  87478. /**
  87479. * Gets the right camera target of a rig setup in case of Rigged Camera
  87480. * @returns the target position
  87481. */
  87482. getRightTarget(): Nullable<Vector3>;
  87483. /**
  87484. * @hidden
  87485. */
  87486. setCameraRigMode(mode: number, rigParams: any): void;
  87487. /** @hidden */
  87488. static _setStereoscopicRigMode(camera: Camera): void;
  87489. /** @hidden */
  87490. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87491. /** @hidden */
  87492. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87493. /** @hidden */
  87494. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87495. /** @hidden */
  87496. _getVRProjectionMatrix(): Matrix;
  87497. protected _updateCameraRotationMatrix(): void;
  87498. protected _updateWebVRCameraRotationMatrix(): void;
  87499. /**
  87500. * This function MUST be overwritten by the different WebVR cameras available.
  87501. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87502. * @hidden
  87503. */
  87504. _getWebVRProjectionMatrix(): Matrix;
  87505. /**
  87506. * This function MUST be overwritten by the different WebVR cameras available.
  87507. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87508. * @hidden
  87509. */
  87510. _getWebVRViewMatrix(): Matrix;
  87511. /** @hidden */
  87512. setCameraRigParameter(name: string, value: any): void;
  87513. /**
  87514. * needs to be overridden by children so sub has required properties to be copied
  87515. * @hidden
  87516. */
  87517. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87518. /**
  87519. * May need to be overridden by children
  87520. * @hidden
  87521. */
  87522. _updateRigCameras(): void;
  87523. /** @hidden */
  87524. _setupInputs(): void;
  87525. /**
  87526. * Serialiaze the camera setup to a json represention
  87527. * @returns the JSON representation
  87528. */
  87529. serialize(): any;
  87530. /**
  87531. * Clones the current camera.
  87532. * @param name The cloned camera name
  87533. * @returns the cloned camera
  87534. */
  87535. clone(name: string): Camera;
  87536. /**
  87537. * Gets the direction of the camera relative to a given local axis.
  87538. * @param localAxis Defines the reference axis to provide a relative direction.
  87539. * @return the direction
  87540. */
  87541. getDirection(localAxis: Vector3): Vector3;
  87542. /**
  87543. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87544. * @param localAxis Defines the reference axis to provide a relative direction.
  87545. * @param result Defines the vector to store the result in
  87546. */
  87547. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87548. /**
  87549. * Gets a camera constructor for a given camera type
  87550. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87551. * @param name The name of the camera the result will be able to instantiate
  87552. * @param scene The scene the result will construct the camera in
  87553. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87554. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87555. * @returns a factory method to construc the camera
  87556. */
  87557. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87558. /**
  87559. * Compute the world matrix of the camera.
  87560. * @returns the camera workd matrix
  87561. */
  87562. computeWorldMatrix(): Matrix;
  87563. /**
  87564. * Parse a JSON and creates the camera from the parsed information
  87565. * @param parsedCamera The JSON to parse
  87566. * @param scene The scene to instantiate the camera in
  87567. * @returns the newly constructed camera
  87568. */
  87569. static Parse(parsedCamera: any, scene: Scene): Camera;
  87570. }
  87571. }
  87572. declare module BABYLON {
  87573. /**
  87574. * Interface for any object that can request an animation frame
  87575. */
  87576. export interface ICustomAnimationFrameRequester {
  87577. /**
  87578. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87579. */
  87580. renderFunction?: Function;
  87581. /**
  87582. * Called to request the next frame to render to
  87583. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87584. */
  87585. requestAnimationFrame: Function;
  87586. /**
  87587. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87588. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87589. */
  87590. requestID?: number;
  87591. }
  87592. /**
  87593. * Interface containing an array of animations
  87594. */
  87595. export interface IAnimatable {
  87596. /**
  87597. * Array of animations
  87598. */
  87599. animations: Array<Animation>;
  87600. }
  87601. /** Interface used by value gradients (color, factor, ...) */
  87602. export interface IValueGradient {
  87603. /**
  87604. * Gets or sets the gradient value (between 0 and 1)
  87605. */
  87606. gradient: number;
  87607. }
  87608. /** Class used to store color4 gradient */
  87609. export class ColorGradient implements IValueGradient {
  87610. /**
  87611. * Gets or sets the gradient value (between 0 and 1)
  87612. */
  87613. gradient: number;
  87614. /**
  87615. * Gets or sets first associated color
  87616. */
  87617. color1: Color4;
  87618. /**
  87619. * Gets or sets second associated color
  87620. */
  87621. color2?: Color4;
  87622. /**
  87623. * Will get a color picked randomly between color1 and color2.
  87624. * If color2 is undefined then color1 will be used
  87625. * @param result defines the target Color4 to store the result in
  87626. */
  87627. getColorToRef(result: Color4): void;
  87628. }
  87629. /** Class used to store color 3 gradient */
  87630. export class Color3Gradient implements IValueGradient {
  87631. /**
  87632. * Gets or sets the gradient value (between 0 and 1)
  87633. */
  87634. gradient: number;
  87635. /**
  87636. * Gets or sets the associated color
  87637. */
  87638. color: Color3;
  87639. }
  87640. /** Class used to store factor gradient */
  87641. export class FactorGradient implements IValueGradient {
  87642. /**
  87643. * Gets or sets the gradient value (between 0 and 1)
  87644. */
  87645. gradient: number;
  87646. /**
  87647. * Gets or sets first associated factor
  87648. */
  87649. factor1: number;
  87650. /**
  87651. * Gets or sets second associated factor
  87652. */
  87653. factor2?: number;
  87654. /**
  87655. * Will get a number picked randomly between factor1 and factor2.
  87656. * If factor2 is undefined then factor1 will be used
  87657. * @returns the picked number
  87658. */
  87659. getFactor(): number;
  87660. }
  87661. /**
  87662. * @ignore
  87663. * Application error to support additional information when loading a file
  87664. */
  87665. export class LoadFileError extends Error {
  87666. /** defines the optional XHR request */
  87667. request?: XMLHttpRequest | undefined;
  87668. private static _setPrototypeOf;
  87669. /**
  87670. * Creates a new LoadFileError
  87671. * @param message defines the message of the error
  87672. * @param request defines the optional XHR request
  87673. */
  87674. constructor(message: string,
  87675. /** defines the optional XHR request */
  87676. request?: XMLHttpRequest | undefined);
  87677. }
  87678. /**
  87679. * Class used to define a retry strategy when error happens while loading assets
  87680. */
  87681. export class RetryStrategy {
  87682. /**
  87683. * Function used to defines an exponential back off strategy
  87684. * @param maxRetries defines the maximum number of retries (3 by default)
  87685. * @param baseInterval defines the interval between retries
  87686. * @returns the strategy function to use
  87687. */
  87688. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87689. }
  87690. /**
  87691. * File request interface
  87692. */
  87693. export interface IFileRequest {
  87694. /**
  87695. * Raised when the request is complete (success or error).
  87696. */
  87697. onCompleteObservable: Observable<IFileRequest>;
  87698. /**
  87699. * Aborts the request for a file.
  87700. */
  87701. abort: () => void;
  87702. }
  87703. /**
  87704. * Class containing a set of static utilities functions
  87705. */
  87706. export class Tools {
  87707. /**
  87708. * Gets or sets the base URL to use to load assets
  87709. */
  87710. static BaseUrl: string;
  87711. /**
  87712. * Enable/Disable Custom HTTP Request Headers globally.
  87713. * default = false
  87714. * @see CustomRequestHeaders
  87715. */
  87716. static UseCustomRequestHeaders: boolean;
  87717. /**
  87718. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87719. * i.e. when loading files, where the server/service expects an Authorization header.
  87720. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  87721. */
  87722. static CustomRequestHeaders: {
  87723. [key: string]: string;
  87724. };
  87725. /**
  87726. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87727. */
  87728. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87729. /**
  87730. * Default behaviour for cors in the application.
  87731. * It can be a string if the expected behavior is identical in the entire app.
  87732. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87733. */
  87734. static CorsBehavior: string | ((url: string | string[]) => string);
  87735. /**
  87736. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87737. * @ignorenaming
  87738. */
  87739. static UseFallbackTexture: boolean;
  87740. /**
  87741. * Use this object to register external classes like custom textures or material
  87742. * to allow the laoders to instantiate them
  87743. */
  87744. static RegisteredExternalClasses: {
  87745. [key: string]: Object;
  87746. };
  87747. /**
  87748. * Texture content used if a texture cannot loaded
  87749. * @ignorenaming
  87750. */
  87751. static fallbackTexture: string;
  87752. /**
  87753. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87754. * @param u defines the coordinate on X axis
  87755. * @param v defines the coordinate on Y axis
  87756. * @param width defines the width of the source data
  87757. * @param height defines the height of the source data
  87758. * @param pixels defines the source byte array
  87759. * @param color defines the output color
  87760. */
  87761. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87762. /**
  87763. * Interpolates between a and b via alpha
  87764. * @param a The lower value (returned when alpha = 0)
  87765. * @param b The upper value (returned when alpha = 1)
  87766. * @param alpha The interpolation-factor
  87767. * @return The mixed value
  87768. */
  87769. static Mix(a: number, b: number, alpha: number): number;
  87770. /**
  87771. * Tries to instantiate a new object from a given class name
  87772. * @param className defines the class name to instantiate
  87773. * @returns the new object or null if the system was not able to do the instantiation
  87774. */
  87775. static Instantiate(className: string): any;
  87776. /**
  87777. * Provides a slice function that will work even on IE
  87778. * @param data defines the array to slice
  87779. * @param start defines the start of the data (optional)
  87780. * @param end defines the end of the data (optional)
  87781. * @returns the new sliced array
  87782. */
  87783. static Slice<T>(data: T, start?: number, end?: number): T;
  87784. /**
  87785. * Polyfill for setImmediate
  87786. * @param action defines the action to execute after the current execution block
  87787. */
  87788. static SetImmediate(action: () => void): void;
  87789. /**
  87790. * Function indicating if a number is an exponent of 2
  87791. * @param value defines the value to test
  87792. * @returns true if the value is an exponent of 2
  87793. */
  87794. static IsExponentOfTwo(value: number): boolean;
  87795. private static _tmpFloatArray;
  87796. /**
  87797. * Returns the nearest 32-bit single precision float representation of a Number
  87798. * @param value A Number. If the parameter is of a different type, it will get converted
  87799. * to a number or to NaN if it cannot be converted
  87800. * @returns number
  87801. */
  87802. static FloatRound(value: number): number;
  87803. /**
  87804. * Find the next highest power of two.
  87805. * @param x Number to start search from.
  87806. * @return Next highest power of two.
  87807. */
  87808. static CeilingPOT(x: number): number;
  87809. /**
  87810. * Find the next lowest power of two.
  87811. * @param x Number to start search from.
  87812. * @return Next lowest power of two.
  87813. */
  87814. static FloorPOT(x: number): number;
  87815. /**
  87816. * Find the nearest power of two.
  87817. * @param x Number to start search from.
  87818. * @return Next nearest power of two.
  87819. */
  87820. static NearestPOT(x: number): number;
  87821. /**
  87822. * Get the closest exponent of two
  87823. * @param value defines the value to approximate
  87824. * @param max defines the maximum value to return
  87825. * @param mode defines how to define the closest value
  87826. * @returns closest exponent of two of the given value
  87827. */
  87828. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87829. /**
  87830. * Extracts the filename from a path
  87831. * @param path defines the path to use
  87832. * @returns the filename
  87833. */
  87834. static GetFilename(path: string): string;
  87835. /**
  87836. * Extracts the "folder" part of a path (everything before the filename).
  87837. * @param uri The URI to extract the info from
  87838. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87839. * @returns The "folder" part of the path
  87840. */
  87841. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87842. /**
  87843. * Extracts text content from a DOM element hierarchy
  87844. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87845. */
  87846. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87847. /**
  87848. * Convert an angle in radians to degrees
  87849. * @param angle defines the angle to convert
  87850. * @returns the angle in degrees
  87851. */
  87852. static ToDegrees(angle: number): number;
  87853. /**
  87854. * Convert an angle in degrees to radians
  87855. * @param angle defines the angle to convert
  87856. * @returns the angle in radians
  87857. */
  87858. static ToRadians(angle: number): number;
  87859. /**
  87860. * Encode a buffer to a base64 string
  87861. * @param buffer defines the buffer to encode
  87862. * @returns the encoded string
  87863. */
  87864. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87865. /**
  87866. * Extracts minimum and maximum values from a list of indexed positions
  87867. * @param positions defines the positions to use
  87868. * @param indices defines the indices to the positions
  87869. * @param indexStart defines the start index
  87870. * @param indexCount defines the end index
  87871. * @param bias defines bias value to add to the result
  87872. * @return minimum and maximum values
  87873. */
  87874. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87875. minimum: Vector3;
  87876. maximum: Vector3;
  87877. };
  87878. /**
  87879. * Extracts minimum and maximum values from a list of positions
  87880. * @param positions defines the positions to use
  87881. * @param start defines the start index in the positions array
  87882. * @param count defines the number of positions to handle
  87883. * @param bias defines bias value to add to the result
  87884. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87885. * @return minimum and maximum values
  87886. */
  87887. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87888. minimum: Vector3;
  87889. maximum: Vector3;
  87890. };
  87891. /**
  87892. * Returns an array if obj is not an array
  87893. * @param obj defines the object to evaluate as an array
  87894. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87895. * @returns either obj directly if obj is an array or a new array containing obj
  87896. */
  87897. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87898. /**
  87899. * Gets the pointer prefix to use
  87900. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87901. */
  87902. static GetPointerPrefix(): string;
  87903. /**
  87904. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87905. * @param func - the function to be called
  87906. * @param requester - the object that will request the next frame. Falls back to window.
  87907. * @returns frame number
  87908. */
  87909. static QueueNewFrame(func: () => void, requester?: any): number;
  87910. /**
  87911. * Ask the browser to promote the current element to fullscreen rendering mode
  87912. * @param element defines the DOM element to promote
  87913. */
  87914. static RequestFullscreen(element: HTMLElement): void;
  87915. /**
  87916. * Asks the browser to exit fullscreen mode
  87917. */
  87918. static ExitFullscreen(): void;
  87919. /**
  87920. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87921. * @param url define the url we are trying
  87922. * @param element define the dom element where to configure the cors policy
  87923. */
  87924. static SetCorsBehavior(url: string | string[], element: {
  87925. crossOrigin: string | null;
  87926. }): void;
  87927. /**
  87928. * Removes unwanted characters from an url
  87929. * @param url defines the url to clean
  87930. * @returns the cleaned url
  87931. */
  87932. static CleanUrl(url: string): string;
  87933. /**
  87934. * Gets or sets a function used to pre-process url before using them to load assets
  87935. */
  87936. static PreprocessUrl: (url: string) => string;
  87937. /**
  87938. * Loads an image as an HTMLImageElement.
  87939. * @param input url string, ArrayBuffer, or Blob to load
  87940. * @param onLoad callback called when the image successfully loads
  87941. * @param onError callback called when the image fails to load
  87942. * @param offlineProvider offline provider for caching
  87943. * @returns the HTMLImageElement of the loaded image
  87944. */
  87945. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87946. /**
  87947. * Loads a file
  87948. * @param url url string, ArrayBuffer, or Blob to load
  87949. * @param onSuccess callback called when the file successfully loads
  87950. * @param onProgress callback called while file is loading (if the server supports this mode)
  87951. * @param offlineProvider defines the offline provider for caching
  87952. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87953. * @param onError callback called when the file fails to load
  87954. * @returns a file request object
  87955. */
  87956. 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;
  87957. /**
  87958. * Load a script (identified by an url). When the url returns, the
  87959. * content of this file is added into a new script element, attached to the DOM (body element)
  87960. * @param scriptUrl defines the url of the script to laod
  87961. * @param onSuccess defines the callback called when the script is loaded
  87962. * @param onError defines the callback to call if an error occurs
  87963. */
  87964. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87965. /**
  87966. * Loads a file from a blob
  87967. * @param fileToLoad defines the blob to use
  87968. * @param callback defines the callback to call when data is loaded
  87969. * @param progressCallback defines the callback to call during loading process
  87970. * @returns a file request object
  87971. */
  87972. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87973. /**
  87974. * Loads a file
  87975. * @param fileToLoad defines the file to load
  87976. * @param callback defines the callback to call when data is loaded
  87977. * @param progressCallBack defines the callback to call during loading process
  87978. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87979. * @returns a file request object
  87980. */
  87981. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87982. /**
  87983. * Creates a data url from a given string content
  87984. * @param content defines the content to convert
  87985. * @returns the new data url link
  87986. */
  87987. static FileAsURL(content: string): string;
  87988. /**
  87989. * Format the given number to a specific decimal format
  87990. * @param value defines the number to format
  87991. * @param decimals defines the number of decimals to use
  87992. * @returns the formatted string
  87993. */
  87994. static Format(value: number, decimals?: number): string;
  87995. /**
  87996. * Checks if a given vector is inside a specific range
  87997. * @param v defines the vector to test
  87998. * @param min defines the minimum range
  87999. * @param max defines the maximum range
  88000. */
  88001. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88002. /**
  88003. * Tries to copy an object by duplicating every property
  88004. * @param source defines the source object
  88005. * @param destination defines the target object
  88006. * @param doNotCopyList defines a list of properties to avoid
  88007. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  88008. */
  88009. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  88010. /**
  88011. * Gets a boolean indicating if the given object has no own property
  88012. * @param obj defines the object to test
  88013. * @returns true if object has no own property
  88014. */
  88015. static IsEmpty(obj: any): boolean;
  88016. /**
  88017. * Function used to register events at window level
  88018. * @param events defines the events to register
  88019. */
  88020. static RegisterTopRootEvents(events: {
  88021. name: string;
  88022. handler: Nullable<(e: FocusEvent) => any>;
  88023. }[]): void;
  88024. /**
  88025. * Function used to unregister events from window level
  88026. * @param events defines the events to unregister
  88027. */
  88028. static UnregisterTopRootEvents(events: {
  88029. name: string;
  88030. handler: Nullable<(e: FocusEvent) => any>;
  88031. }[]): void;
  88032. /**
  88033. * @ignore
  88034. */
  88035. static _ScreenshotCanvas: HTMLCanvasElement;
  88036. /**
  88037. * Dumps the current bound framebuffer
  88038. * @param width defines the rendering width
  88039. * @param height defines the rendering height
  88040. * @param engine defines the hosting engine
  88041. * @param successCallback defines the callback triggered once the data are available
  88042. * @param mimeType defines the mime type of the result
  88043. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  88044. */
  88045. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88046. /**
  88047. * Converts the canvas data to blob.
  88048. * This acts as a polyfill for browsers not supporting the to blob function.
  88049. * @param canvas Defines the canvas to extract the data from
  88050. * @param successCallback Defines the callback triggered once the data are available
  88051. * @param mimeType Defines the mime type of the result
  88052. */
  88053. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  88054. /**
  88055. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  88056. * @param successCallback defines the callback triggered once the data are available
  88057. * @param mimeType defines the mime type of the result
  88058. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  88059. */
  88060. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88061. /**
  88062. * Downloads a blob in the browser
  88063. * @param blob defines the blob to download
  88064. * @param fileName defines the name of the downloaded file
  88065. */
  88066. static Download(blob: Blob, fileName: string): void;
  88067. /**
  88068. * Captures a screenshot of the current rendering
  88069. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88070. * @param engine defines the rendering engine
  88071. * @param camera defines the source camera
  88072. * @param size This parameter can be set to a single number or to an object with the
  88073. * following (optional) properties: precision, width, height. If a single number is passed,
  88074. * it will be used for both width and height. If an object is passed, the screenshot size
  88075. * will be derived from the parameters. The precision property is a multiplier allowing
  88076. * rendering at a higher or lower resolution
  88077. * @param successCallback defines the callback receives a single parameter which contains the
  88078. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88079. * src parameter of an <img> to display it
  88080. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  88081. * Check your browser for supported MIME types
  88082. */
  88083. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  88084. /**
  88085. * Generates an image screenshot from the specified camera.
  88086. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88087. * @param engine The engine to use for rendering
  88088. * @param camera The camera to use for rendering
  88089. * @param size This parameter can be set to a single number or to an object with the
  88090. * following (optional) properties: precision, width, height. If a single number is passed,
  88091. * it will be used for both width and height. If an object is passed, the screenshot size
  88092. * will be derived from the parameters. The precision property is a multiplier allowing
  88093. * rendering at a higher or lower resolution
  88094. * @param successCallback The callback receives a single parameter which contains the
  88095. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88096. * src parameter of an <img> to display it
  88097. * @param mimeType The MIME type of the screenshot image (default: image/png).
  88098. * Check your browser for supported MIME types
  88099. * @param samples Texture samples (default: 1)
  88100. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  88101. * @param fileName A name for for the downloaded file.
  88102. */
  88103. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  88104. /**
  88105. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88106. * Be aware Math.random() could cause collisions, but:
  88107. * "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"
  88108. * @returns a pseudo random id
  88109. */
  88110. static RandomId(): string;
  88111. /**
  88112. * Test if the given uri is a base64 string
  88113. * @param uri The uri to test
  88114. * @return True if the uri is a base64 string or false otherwise
  88115. */
  88116. static IsBase64(uri: string): boolean;
  88117. /**
  88118. * Decode the given base64 uri.
  88119. * @param uri The uri to decode
  88120. * @return The decoded base64 data.
  88121. */
  88122. static DecodeBase64(uri: string): ArrayBuffer;
  88123. /**
  88124. * No log
  88125. */
  88126. static readonly NoneLogLevel: number;
  88127. /**
  88128. * Only message logs
  88129. */
  88130. static readonly MessageLogLevel: number;
  88131. /**
  88132. * Only warning logs
  88133. */
  88134. static readonly WarningLogLevel: number;
  88135. /**
  88136. * Only error logs
  88137. */
  88138. static readonly ErrorLogLevel: number;
  88139. /**
  88140. * All logs
  88141. */
  88142. static readonly AllLogLevel: number;
  88143. /**
  88144. * Gets a value indicating the number of loading errors
  88145. * @ignorenaming
  88146. */
  88147. static readonly errorsCount: number;
  88148. /**
  88149. * Callback called when a new log is added
  88150. */
  88151. static OnNewCacheEntry: (entry: string) => void;
  88152. /**
  88153. * Log a message to the console
  88154. * @param message defines the message to log
  88155. */
  88156. static Log(message: string): void;
  88157. /**
  88158. * Write a warning message to the console
  88159. * @param message defines the message to log
  88160. */
  88161. static Warn(message: string): void;
  88162. /**
  88163. * Write an error message to the console
  88164. * @param message defines the message to log
  88165. */
  88166. static Error(message: string): void;
  88167. /**
  88168. * Gets current log cache (list of logs)
  88169. */
  88170. static readonly LogCache: string;
  88171. /**
  88172. * Clears the log cache
  88173. */
  88174. static ClearLogCache(): void;
  88175. /**
  88176. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  88177. */
  88178. static LogLevels: number;
  88179. /**
  88180. * Checks if the loaded document was accessed via `file:`-Protocol.
  88181. * @returns boolean
  88182. */
  88183. static IsFileURL(): boolean;
  88184. /**
  88185. * Checks if the window object exists
  88186. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  88187. */
  88188. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  88189. /**
  88190. * No performance log
  88191. */
  88192. static readonly PerformanceNoneLogLevel: number;
  88193. /**
  88194. * Use user marks to log performance
  88195. */
  88196. static readonly PerformanceUserMarkLogLevel: number;
  88197. /**
  88198. * Log performance to the console
  88199. */
  88200. static readonly PerformanceConsoleLogLevel: number;
  88201. private static _performance;
  88202. /**
  88203. * Sets the current performance log level
  88204. */
  88205. static PerformanceLogLevel: number;
  88206. private static _StartPerformanceCounterDisabled;
  88207. private static _EndPerformanceCounterDisabled;
  88208. private static _StartUserMark;
  88209. private static _EndUserMark;
  88210. private static _StartPerformanceConsole;
  88211. private static _EndPerformanceConsole;
  88212. /**
  88213. * Injects the @see CustomRequestHeaders into the given request
  88214. * @param request the request that should be used for injection
  88215. */
  88216. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  88217. /**
  88218. * Starts a performance counter
  88219. */
  88220. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88221. /**
  88222. * Ends a specific performance coutner
  88223. */
  88224. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88225. /**
  88226. * Gets either window.performance.now() if supported or Date.now() else
  88227. */
  88228. static readonly Now: number;
  88229. /**
  88230. * This method will return the name of the class used to create the instance of the given object.
  88231. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88232. * @param object the object to get the class name from
  88233. * @param isType defines if the object is actually a type
  88234. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88235. */
  88236. static GetClassName(object: any, isType?: boolean): string;
  88237. /**
  88238. * Gets the first element of an array satisfying a given predicate
  88239. * @param array defines the array to browse
  88240. * @param predicate defines the predicate to use
  88241. * @returns null if not found or the element
  88242. */
  88243. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88244. /**
  88245. * This method will return the name of the full name of the class, including its owning module (if any).
  88246. * 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).
  88247. * @param object the object to get the class name from
  88248. * @param isType defines if the object is actually a type
  88249. * @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.
  88250. * @ignorenaming
  88251. */
  88252. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88253. /**
  88254. * Returns a promise that resolves after the given amount of time.
  88255. * @param delay Number of milliseconds to delay
  88256. * @returns Promise that resolves after the given amount of time
  88257. */
  88258. static DelayAsync(delay: number): Promise<void>;
  88259. /**
  88260. * Gets the current gradient from an array of IValueGradient
  88261. * @param ratio defines the current ratio to get
  88262. * @param gradients defines the array of IValueGradient
  88263. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88264. */
  88265. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88266. }
  88267. /**
  88268. * This class is used to track a performance counter which is number based.
  88269. * The user has access to many properties which give statistics of different nature.
  88270. *
  88271. * The implementer can track two kinds of Performance Counter: time and count.
  88272. * 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.
  88273. * 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.
  88274. */
  88275. export class PerfCounter {
  88276. /**
  88277. * Gets or sets a global boolean to turn on and off all the counters
  88278. */
  88279. static Enabled: boolean;
  88280. /**
  88281. * Returns the smallest value ever
  88282. */
  88283. readonly min: number;
  88284. /**
  88285. * Returns the biggest value ever
  88286. */
  88287. readonly max: number;
  88288. /**
  88289. * Returns the average value since the performance counter is running
  88290. */
  88291. readonly average: number;
  88292. /**
  88293. * Returns the average value of the last second the counter was monitored
  88294. */
  88295. readonly lastSecAverage: number;
  88296. /**
  88297. * Returns the current value
  88298. */
  88299. readonly current: number;
  88300. /**
  88301. * Gets the accumulated total
  88302. */
  88303. readonly total: number;
  88304. /**
  88305. * Gets the total value count
  88306. */
  88307. readonly count: number;
  88308. /**
  88309. * Creates a new counter
  88310. */
  88311. constructor();
  88312. /**
  88313. * Call this method to start monitoring a new frame.
  88314. * 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.
  88315. */
  88316. fetchNewFrame(): void;
  88317. /**
  88318. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88319. * @param newCount the count value to add to the monitored count
  88320. * @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.
  88321. */
  88322. addCount(newCount: number, fetchResult: boolean): void;
  88323. /**
  88324. * Start monitoring this performance counter
  88325. */
  88326. beginMonitoring(): void;
  88327. /**
  88328. * Compute the time lapsed since the previous beginMonitoring() call.
  88329. * @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
  88330. */
  88331. endMonitoring(newFrame?: boolean): void;
  88332. private _fetchResult;
  88333. private _startMonitoringTime;
  88334. private _min;
  88335. private _max;
  88336. private _average;
  88337. private _current;
  88338. private _totalValueCount;
  88339. private _totalAccumulated;
  88340. private _lastSecAverage;
  88341. private _lastSecAccumulated;
  88342. private _lastSecTime;
  88343. private _lastSecValueCount;
  88344. }
  88345. /**
  88346. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88347. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88348. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88349. * @param name The name of the class, case should be preserved
  88350. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88351. */
  88352. export function className(name: string, module?: string): (target: Object) => void;
  88353. /**
  88354. * An implementation of a loop for asynchronous functions.
  88355. */
  88356. export class AsyncLoop {
  88357. /**
  88358. * Defines the number of iterations for the loop
  88359. */
  88360. iterations: number;
  88361. /**
  88362. * Defines the current index of the loop.
  88363. */
  88364. index: number;
  88365. private _done;
  88366. private _fn;
  88367. private _successCallback;
  88368. /**
  88369. * Constructor.
  88370. * @param iterations the number of iterations.
  88371. * @param func the function to run each iteration
  88372. * @param successCallback the callback that will be called upon succesful execution
  88373. * @param offset starting offset.
  88374. */
  88375. constructor(
  88376. /**
  88377. * Defines the number of iterations for the loop
  88378. */
  88379. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88380. /**
  88381. * Execute the next iteration. Must be called after the last iteration was finished.
  88382. */
  88383. executeNext(): void;
  88384. /**
  88385. * Break the loop and run the success callback.
  88386. */
  88387. breakLoop(): void;
  88388. /**
  88389. * Create and run an async loop.
  88390. * @param iterations the number of iterations.
  88391. * @param fn the function to run each iteration
  88392. * @param successCallback the callback that will be called upon succesful execution
  88393. * @param offset starting offset.
  88394. * @returns the created async loop object
  88395. */
  88396. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88397. /**
  88398. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88399. * @param iterations total number of iterations
  88400. * @param syncedIterations number of synchronous iterations in each async iteration.
  88401. * @param fn the function to call each iteration.
  88402. * @param callback a success call back that will be called when iterating stops.
  88403. * @param breakFunction a break condition (optional)
  88404. * @param timeout timeout settings for the setTimeout function. default - 0.
  88405. * @returns the created async loop object
  88406. */
  88407. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88408. }
  88409. }
  88410. declare module BABYLON {
  88411. /** @hidden */
  88412. export interface ICollisionCoordinator {
  88413. createCollider(): Collider;
  88414. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88415. init(scene: Scene): void;
  88416. }
  88417. /** @hidden */
  88418. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88419. private _scene;
  88420. private _scaledPosition;
  88421. private _scaledVelocity;
  88422. private _finalPosition;
  88423. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88424. createCollider(): Collider;
  88425. init(scene: Scene): void;
  88426. private _collideWithWorld;
  88427. }
  88428. }
  88429. declare module BABYLON {
  88430. /**
  88431. * This class defines the direct association between an animation and a target
  88432. */
  88433. export class TargetedAnimation {
  88434. /**
  88435. * Animation to perform
  88436. */
  88437. animation: Animation;
  88438. /**
  88439. * Target to animate
  88440. */
  88441. target: any;
  88442. }
  88443. /**
  88444. * Use this class to create coordinated animations on multiple targets
  88445. */
  88446. export class AnimationGroup implements IDisposable {
  88447. /** The name of the animation group */
  88448. name: string;
  88449. private _scene;
  88450. private _targetedAnimations;
  88451. private _animatables;
  88452. private _from;
  88453. private _to;
  88454. private _isStarted;
  88455. private _isPaused;
  88456. private _speedRatio;
  88457. /**
  88458. * Gets or sets the unique id of the node
  88459. */
  88460. uniqueId: number;
  88461. /**
  88462. * This observable will notify when one animation have ended
  88463. */
  88464. onAnimationEndObservable: Observable<TargetedAnimation>;
  88465. /**
  88466. * Observer raised when one animation loops
  88467. */
  88468. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88469. /**
  88470. * This observable will notify when all animations have ended.
  88471. */
  88472. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88473. /**
  88474. * This observable will notify when all animations have paused.
  88475. */
  88476. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88477. /**
  88478. * This observable will notify when all animations are playing.
  88479. */
  88480. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88481. /**
  88482. * Gets the first frame
  88483. */
  88484. readonly from: number;
  88485. /**
  88486. * Gets the last frame
  88487. */
  88488. readonly to: number;
  88489. /**
  88490. * Define if the animations are started
  88491. */
  88492. readonly isStarted: boolean;
  88493. /**
  88494. * Gets a value indicating that the current group is playing
  88495. */
  88496. readonly isPlaying: boolean;
  88497. /**
  88498. * Gets or sets the speed ratio to use for all animations
  88499. */
  88500. /**
  88501. * Gets or sets the speed ratio to use for all animations
  88502. */
  88503. speedRatio: number;
  88504. /**
  88505. * Gets the targeted animations for this animation group
  88506. */
  88507. readonly targetedAnimations: Array<TargetedAnimation>;
  88508. /**
  88509. * returning the list of animatables controlled by this animation group.
  88510. */
  88511. readonly animatables: Array<Animatable>;
  88512. /**
  88513. * Instantiates a new Animation Group.
  88514. * This helps managing several animations at once.
  88515. * @see http://doc.babylonjs.com/how_to/group
  88516. * @param name Defines the name of the group
  88517. * @param scene Defines the scene the group belongs to
  88518. */
  88519. constructor(
  88520. /** The name of the animation group */
  88521. name: string, scene?: Nullable<Scene>);
  88522. /**
  88523. * Add an animation (with its target) in the group
  88524. * @param animation defines the animation we want to add
  88525. * @param target defines the target of the animation
  88526. * @returns the TargetedAnimation object
  88527. */
  88528. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88529. /**
  88530. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88531. * It can add constant keys at begin or end
  88532. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88533. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88534. * @returns the animation group
  88535. */
  88536. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88537. /**
  88538. * Start all animations on given targets
  88539. * @param loop defines if animations must loop
  88540. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88541. * @param from defines the from key (optional)
  88542. * @param to defines the to key (optional)
  88543. * @returns the current animation group
  88544. */
  88545. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88546. /**
  88547. * Pause all animations
  88548. * @returns the animation group
  88549. */
  88550. pause(): AnimationGroup;
  88551. /**
  88552. * Play all animations to initial state
  88553. * This function will start() the animations if they were not started or will restart() them if they were paused
  88554. * @param loop defines if animations must loop
  88555. * @returns the animation group
  88556. */
  88557. play(loop?: boolean): AnimationGroup;
  88558. /**
  88559. * Reset all animations to initial state
  88560. * @returns the animation group
  88561. */
  88562. reset(): AnimationGroup;
  88563. /**
  88564. * Restart animations from key 0
  88565. * @returns the animation group
  88566. */
  88567. restart(): AnimationGroup;
  88568. /**
  88569. * Stop all animations
  88570. * @returns the animation group
  88571. */
  88572. stop(): AnimationGroup;
  88573. /**
  88574. * Set animation weight for all animatables
  88575. * @param weight defines the weight to use
  88576. * @return the animationGroup
  88577. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88578. */
  88579. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88580. /**
  88581. * Synchronize and normalize all animatables with a source animatable
  88582. * @param root defines the root animatable to synchronize with
  88583. * @return the animationGroup
  88584. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88585. */
  88586. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88587. /**
  88588. * Goes to a specific frame in this animation group
  88589. * @param frame the frame number to go to
  88590. * @return the animationGroup
  88591. */
  88592. goToFrame(frame: number): AnimationGroup;
  88593. /**
  88594. * Dispose all associated resources
  88595. */
  88596. dispose(): void;
  88597. private _checkAnimationGroupEnded;
  88598. /**
  88599. * Clone the current animation group and returns a copy
  88600. * @param newName defines the name of the new group
  88601. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88602. * @returns the new aniamtion group
  88603. */
  88604. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88605. /**
  88606. * Returns a new AnimationGroup object parsed from the source provided.
  88607. * @param parsedAnimationGroup defines the source
  88608. * @param scene defines the scene that will receive the animationGroup
  88609. * @returns a new AnimationGroup
  88610. */
  88611. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88612. /**
  88613. * Returns the string "AnimationGroup"
  88614. * @returns "AnimationGroup"
  88615. */
  88616. getClassName(): string;
  88617. /**
  88618. * Creates a detailled string about the object
  88619. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88620. * @returns a string representing the object
  88621. */
  88622. toString(fullDetails?: boolean): string;
  88623. }
  88624. }
  88625. declare module BABYLON {
  88626. /**
  88627. * Define an interface for all classes that will hold resources
  88628. */
  88629. export interface IDisposable {
  88630. /**
  88631. * Releases all held resources
  88632. */
  88633. dispose(): void;
  88634. }
  88635. /** Interface defining initialization parameters for Scene class */
  88636. export interface SceneOptions {
  88637. /**
  88638. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88639. * It will improve performance when the number of geometries becomes important.
  88640. */
  88641. useGeometryUniqueIdsMap?: boolean;
  88642. /**
  88643. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88644. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88645. */
  88646. useMaterialMeshMap?: boolean;
  88647. /**
  88648. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88649. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88650. */
  88651. useClonedMeshhMap?: boolean;
  88652. }
  88653. /**
  88654. * Represents a scene to be rendered by the engine.
  88655. * @see http://doc.babylonjs.com/features/scene
  88656. */
  88657. export class Scene extends AbstractScene implements IAnimatable {
  88658. private static _uniqueIdCounter;
  88659. /** The fog is deactivated */
  88660. static readonly FOGMODE_NONE: number;
  88661. /** The fog density is following an exponential function */
  88662. static readonly FOGMODE_EXP: number;
  88663. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88664. static readonly FOGMODE_EXP2: number;
  88665. /** The fog density is following a linear function. */
  88666. static readonly FOGMODE_LINEAR: number;
  88667. /**
  88668. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88669. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88670. */
  88671. static MinDeltaTime: number;
  88672. /**
  88673. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88674. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88675. */
  88676. static MaxDeltaTime: number;
  88677. /**
  88678. * Factory used to create the default material.
  88679. * @param name The name of the material to create
  88680. * @param scene The scene to create the material for
  88681. * @returns The default material
  88682. */
  88683. static DefaultMaterialFactory(scene: Scene): Material;
  88684. /**
  88685. * Factory used to create the a collision coordinator.
  88686. * @returns The collision coordinator
  88687. */
  88688. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88689. /** @hidden */
  88690. readonly _isScene: boolean;
  88691. /**
  88692. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88693. */
  88694. autoClear: boolean;
  88695. /**
  88696. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88697. */
  88698. autoClearDepthAndStencil: boolean;
  88699. /**
  88700. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88701. */
  88702. clearColor: Color4;
  88703. /**
  88704. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88705. */
  88706. ambientColor: Color3;
  88707. /** @hidden */
  88708. _environmentBRDFTexture: BaseTexture;
  88709. /** @hidden */
  88710. protected _environmentTexture: Nullable<BaseTexture>;
  88711. /**
  88712. * Texture used in all pbr material as the reflection texture.
  88713. * As in the majority of the scene they are the same (exception for multi room and so on),
  88714. * this is easier to reference from here than from all the materials.
  88715. */
  88716. /**
  88717. * Texture used in all pbr material as the reflection texture.
  88718. * As in the majority of the scene they are the same (exception for multi room and so on),
  88719. * this is easier to set here than in all the materials.
  88720. */
  88721. environmentTexture: Nullable<BaseTexture>;
  88722. /** @hidden */
  88723. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88724. /**
  88725. * Default image processing configuration used either in the rendering
  88726. * Forward main pass or through the imageProcessingPostProcess if present.
  88727. * As in the majority of the scene they are the same (exception for multi camera),
  88728. * this is easier to reference from here than from all the materials and post process.
  88729. *
  88730. * No setter as we it is a shared configuration, you can set the values instead.
  88731. */
  88732. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88733. private _forceWireframe;
  88734. /**
  88735. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88736. */
  88737. forceWireframe: boolean;
  88738. private _forcePointsCloud;
  88739. /**
  88740. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88741. */
  88742. forcePointsCloud: boolean;
  88743. /**
  88744. * Gets or sets the active clipplane 1
  88745. */
  88746. clipPlane: Nullable<Plane>;
  88747. /**
  88748. * Gets or sets the active clipplane 2
  88749. */
  88750. clipPlane2: Nullable<Plane>;
  88751. /**
  88752. * Gets or sets the active clipplane 3
  88753. */
  88754. clipPlane3: Nullable<Plane>;
  88755. /**
  88756. * Gets or sets the active clipplane 4
  88757. */
  88758. clipPlane4: Nullable<Plane>;
  88759. /**
  88760. * Gets or sets a boolean indicating if animations are enabled
  88761. */
  88762. animationsEnabled: boolean;
  88763. private _animationPropertiesOverride;
  88764. /**
  88765. * Gets or sets the animation properties override
  88766. */
  88767. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88768. /**
  88769. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88770. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88771. */
  88772. useConstantAnimationDeltaTime: boolean;
  88773. /**
  88774. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88775. * Please note that it requires to run a ray cast through the scene on every frame
  88776. */
  88777. constantlyUpdateMeshUnderPointer: boolean;
  88778. /**
  88779. * Defines the HTML cursor to use when hovering over interactive elements
  88780. */
  88781. hoverCursor: string;
  88782. /**
  88783. * Defines the HTML default cursor to use (empty by default)
  88784. */
  88785. defaultCursor: string;
  88786. /**
  88787. * This is used to call preventDefault() on pointer down
  88788. * in order to block unwanted artifacts like system double clicks
  88789. */
  88790. preventDefaultOnPointerDown: boolean;
  88791. /**
  88792. * This is used to call preventDefault() on pointer up
  88793. * in order to block unwanted artifacts like system double clicks
  88794. */
  88795. preventDefaultOnPointerUp: boolean;
  88796. /**
  88797. * Gets or sets user defined metadata
  88798. */
  88799. metadata: any;
  88800. /**
  88801. * For internal use only. Please do not use.
  88802. */
  88803. reservedDataStore: any;
  88804. /**
  88805. * Gets the name of the plugin used to load this scene (null by default)
  88806. */
  88807. loadingPluginName: string;
  88808. /**
  88809. * Use this array to add regular expressions used to disable offline support for specific urls
  88810. */
  88811. disableOfflineSupportExceptionRules: RegExp[];
  88812. /**
  88813. * An event triggered when the scene is disposed.
  88814. */
  88815. onDisposeObservable: Observable<Scene>;
  88816. private _onDisposeObserver;
  88817. /** Sets a function to be executed when this scene is disposed. */
  88818. onDispose: () => void;
  88819. /**
  88820. * An event triggered before rendering the scene (right after animations and physics)
  88821. */
  88822. onBeforeRenderObservable: Observable<Scene>;
  88823. private _onBeforeRenderObserver;
  88824. /** Sets a function to be executed before rendering this scene */
  88825. beforeRender: Nullable<() => void>;
  88826. /**
  88827. * An event triggered after rendering the scene
  88828. */
  88829. onAfterRenderObservable: Observable<Scene>;
  88830. private _onAfterRenderObserver;
  88831. /** Sets a function to be executed after rendering this scene */
  88832. afterRender: Nullable<() => void>;
  88833. /**
  88834. * An event triggered before animating the scene
  88835. */
  88836. onBeforeAnimationsObservable: Observable<Scene>;
  88837. /**
  88838. * An event triggered after animations processing
  88839. */
  88840. onAfterAnimationsObservable: Observable<Scene>;
  88841. /**
  88842. * An event triggered before draw calls are ready to be sent
  88843. */
  88844. onBeforeDrawPhaseObservable: Observable<Scene>;
  88845. /**
  88846. * An event triggered after draw calls have been sent
  88847. */
  88848. onAfterDrawPhaseObservable: Observable<Scene>;
  88849. /**
  88850. * An event triggered when the scene is ready
  88851. */
  88852. onReadyObservable: Observable<Scene>;
  88853. /**
  88854. * An event triggered before rendering a camera
  88855. */
  88856. onBeforeCameraRenderObservable: Observable<Camera>;
  88857. private _onBeforeCameraRenderObserver;
  88858. /** Sets a function to be executed before rendering a camera*/
  88859. beforeCameraRender: () => void;
  88860. /**
  88861. * An event triggered after rendering a camera
  88862. */
  88863. onAfterCameraRenderObservable: Observable<Camera>;
  88864. private _onAfterCameraRenderObserver;
  88865. /** Sets a function to be executed after rendering a camera*/
  88866. afterCameraRender: () => void;
  88867. /**
  88868. * An event triggered when active meshes evaluation is about to start
  88869. */
  88870. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88871. /**
  88872. * An event triggered when active meshes evaluation is done
  88873. */
  88874. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88875. /**
  88876. * An event triggered when particles rendering is about to start
  88877. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88878. */
  88879. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88880. /**
  88881. * An event triggered when particles rendering is done
  88882. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88883. */
  88884. onAfterParticlesRenderingObservable: Observable<Scene>;
  88885. /**
  88886. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88887. */
  88888. onDataLoadedObservable: Observable<Scene>;
  88889. /**
  88890. * An event triggered when a camera is created
  88891. */
  88892. onNewCameraAddedObservable: Observable<Camera>;
  88893. /**
  88894. * An event triggered when a camera is removed
  88895. */
  88896. onCameraRemovedObservable: Observable<Camera>;
  88897. /**
  88898. * An event triggered when a light is created
  88899. */
  88900. onNewLightAddedObservable: Observable<Light>;
  88901. /**
  88902. * An event triggered when a light is removed
  88903. */
  88904. onLightRemovedObservable: Observable<Light>;
  88905. /**
  88906. * An event triggered when a geometry is created
  88907. */
  88908. onNewGeometryAddedObservable: Observable<Geometry>;
  88909. /**
  88910. * An event triggered when a geometry is removed
  88911. */
  88912. onGeometryRemovedObservable: Observable<Geometry>;
  88913. /**
  88914. * An event triggered when a transform node is created
  88915. */
  88916. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88917. /**
  88918. * An event triggered when a transform node is removed
  88919. */
  88920. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88921. /**
  88922. * An event triggered when a mesh is created
  88923. */
  88924. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88925. /**
  88926. * An event triggered when a mesh is removed
  88927. */
  88928. onMeshRemovedObservable: Observable<AbstractMesh>;
  88929. /**
  88930. * An event triggered when a material is created
  88931. */
  88932. onNewMaterialAddedObservable: Observable<Material>;
  88933. /**
  88934. * An event triggered when a material is removed
  88935. */
  88936. onMaterialRemovedObservable: Observable<Material>;
  88937. /**
  88938. * An event triggered when a texture is created
  88939. */
  88940. onNewTextureAddedObservable: Observable<BaseTexture>;
  88941. /**
  88942. * An event triggered when a texture is removed
  88943. */
  88944. onTextureRemovedObservable: Observable<BaseTexture>;
  88945. /**
  88946. * An event triggered when render targets are about to be rendered
  88947. * Can happen multiple times per frame.
  88948. */
  88949. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88950. /**
  88951. * An event triggered when render targets were rendered.
  88952. * Can happen multiple times per frame.
  88953. */
  88954. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88955. /**
  88956. * An event triggered before calculating deterministic simulation step
  88957. */
  88958. onBeforeStepObservable: Observable<Scene>;
  88959. /**
  88960. * An event triggered after calculating deterministic simulation step
  88961. */
  88962. onAfterStepObservable: Observable<Scene>;
  88963. /**
  88964. * An event triggered when the activeCamera property is updated
  88965. */
  88966. onActiveCameraChanged: Observable<Scene>;
  88967. /**
  88968. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88969. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88970. * 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)
  88971. */
  88972. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88973. /**
  88974. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88975. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88976. * 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)
  88977. */
  88978. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88979. /**
  88980. * This Observable will when a mesh has been imported into the scene.
  88981. */
  88982. onMeshImportedObservable: Observable<AbstractMesh>;
  88983. /**
  88984. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  88985. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  88986. */
  88987. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  88988. /** @hidden */
  88989. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88990. /**
  88991. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88992. */
  88993. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88994. /**
  88995. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88996. */
  88997. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88998. /**
  88999. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  89000. */
  89001. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  89002. private _onPointerMove;
  89003. private _onPointerDown;
  89004. private _onPointerUp;
  89005. /** Callback called when a pointer move is detected */
  89006. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89007. /** Callback called when a pointer down is detected */
  89008. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89009. /** Callback called when a pointer up is detected */
  89010. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  89011. /** Callback called when a pointer pick is detected */
  89012. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  89013. /**
  89014. * 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).
  89015. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  89016. */
  89017. onPrePointerObservable: Observable<PointerInfoPre>;
  89018. /**
  89019. * Observable event triggered each time an input event is received from the rendering canvas
  89020. */
  89021. onPointerObservable: Observable<PointerInfo>;
  89022. /**
  89023. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  89024. */
  89025. readonly unTranslatedPointer: Vector2;
  89026. /** The distance in pixel that you have to move to prevent some events */
  89027. static DragMovementThreshold: number;
  89028. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  89029. static LongPressDelay: number;
  89030. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  89031. static DoubleClickDelay: number;
  89032. /** If you need to check double click without raising a single click at first click, enable this flag */
  89033. static ExclusiveDoubleClickMode: boolean;
  89034. private _initClickEvent;
  89035. private _initActionManager;
  89036. private _delayedSimpleClick;
  89037. private _delayedSimpleClickTimeout;
  89038. private _previousDelayedSimpleClickTimeout;
  89039. private _meshPickProceed;
  89040. private _previousButtonPressed;
  89041. private _currentPickResult;
  89042. private _previousPickResult;
  89043. private _totalPointersPressed;
  89044. private _doubleClickOccured;
  89045. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  89046. cameraToUseForPointers: Nullable<Camera>;
  89047. private _pointerX;
  89048. private _pointerY;
  89049. private _unTranslatedPointerX;
  89050. private _unTranslatedPointerY;
  89051. private _startingPointerPosition;
  89052. private _previousStartingPointerPosition;
  89053. private _startingPointerTime;
  89054. private _previousStartingPointerTime;
  89055. private _pointerCaptures;
  89056. private _timeAccumulator;
  89057. private _currentStepId;
  89058. private _currentInternalStep;
  89059. /** @hidden */
  89060. _mirroredCameraPosition: Nullable<Vector3>;
  89061. /**
  89062. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  89063. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  89064. */
  89065. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  89066. /**
  89067. * Observable event triggered each time an keyboard event is received from the hosting window
  89068. */
  89069. onKeyboardObservable: Observable<KeyboardInfo>;
  89070. private _onKeyDown;
  89071. private _onKeyUp;
  89072. private _onCanvasFocusObserver;
  89073. private _onCanvasBlurObserver;
  89074. private _useRightHandedSystem;
  89075. /**
  89076. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  89077. */
  89078. useRightHandedSystem: boolean;
  89079. /**
  89080. * Sets the step Id used by deterministic lock step
  89081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89082. * @param newStepId defines the step Id
  89083. */
  89084. setStepId(newStepId: number): void;
  89085. /**
  89086. * Gets the step Id used by deterministic lock step
  89087. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89088. * @returns the step Id
  89089. */
  89090. getStepId(): number;
  89091. /**
  89092. * Gets the internal step used by deterministic lock step
  89093. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89094. * @returns the internal step
  89095. */
  89096. getInternalStep(): number;
  89097. private _fogEnabled;
  89098. /**
  89099. * Gets or sets a boolean indicating if fog is enabled on this scene
  89100. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89101. * (Default is true)
  89102. */
  89103. fogEnabled: boolean;
  89104. private _fogMode;
  89105. /**
  89106. * Gets or sets the fog mode to use
  89107. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89108. * | mode | value |
  89109. * | --- | --- |
  89110. * | FOGMODE_NONE | 0 |
  89111. * | FOGMODE_EXP | 1 |
  89112. * | FOGMODE_EXP2 | 2 |
  89113. * | FOGMODE_LINEAR | 3 |
  89114. */
  89115. fogMode: number;
  89116. /**
  89117. * Gets or sets the fog color to use
  89118. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89119. * (Default is Color3(0.2, 0.2, 0.3))
  89120. */
  89121. fogColor: Color3;
  89122. /**
  89123. * Gets or sets the fog density to use
  89124. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89125. * (Default is 0.1)
  89126. */
  89127. fogDensity: number;
  89128. /**
  89129. * Gets or sets the fog start distance to use
  89130. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89131. * (Default is 0)
  89132. */
  89133. fogStart: number;
  89134. /**
  89135. * Gets or sets the fog end distance to use
  89136. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89137. * (Default is 1000)
  89138. */
  89139. fogEnd: number;
  89140. private _shadowsEnabled;
  89141. /**
  89142. * Gets or sets a boolean indicating if shadows are enabled on this scene
  89143. */
  89144. shadowsEnabled: boolean;
  89145. private _lightsEnabled;
  89146. /**
  89147. * Gets or sets a boolean indicating if lights are enabled on this scene
  89148. */
  89149. lightsEnabled: boolean;
  89150. /** All of the active cameras added to this scene. */
  89151. activeCameras: Camera[];
  89152. private _activeCamera;
  89153. /** Gets or sets the current active camera */
  89154. activeCamera: Nullable<Camera>;
  89155. private _defaultMaterial;
  89156. /** The default material used on meshes when no material is affected */
  89157. /** The default material used on meshes when no material is affected */
  89158. defaultMaterial: Material;
  89159. private _texturesEnabled;
  89160. /**
  89161. * Gets or sets a boolean indicating if textures are enabled on this scene
  89162. */
  89163. texturesEnabled: boolean;
  89164. /**
  89165. * Gets or sets a boolean indicating if particles are enabled on this scene
  89166. */
  89167. particlesEnabled: boolean;
  89168. /**
  89169. * Gets or sets a boolean indicating if sprites are enabled on this scene
  89170. */
  89171. spritesEnabled: boolean;
  89172. private _skeletonsEnabled;
  89173. /**
  89174. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  89175. */
  89176. skeletonsEnabled: boolean;
  89177. /**
  89178. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  89179. */
  89180. lensFlaresEnabled: boolean;
  89181. /**
  89182. * Gets or sets a boolean indicating if collisions are enabled on this scene
  89183. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89184. */
  89185. collisionsEnabled: boolean;
  89186. private _collisionCoordinator;
  89187. /** @hidden */
  89188. readonly collisionCoordinator: ICollisionCoordinator;
  89189. /**
  89190. * Defines the gravity applied to this scene (used only for collisions)
  89191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89192. */
  89193. gravity: Vector3;
  89194. /**
  89195. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  89196. */
  89197. postProcessesEnabled: boolean;
  89198. /**
  89199. * The list of postprocesses added to the scene
  89200. */
  89201. postProcesses: PostProcess[];
  89202. /**
  89203. * Gets the current postprocess manager
  89204. */
  89205. postProcessManager: PostProcessManager;
  89206. /**
  89207. * Gets or sets a boolean indicating if render targets are enabled on this scene
  89208. */
  89209. renderTargetsEnabled: boolean;
  89210. /**
  89211. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  89212. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  89213. */
  89214. dumpNextRenderTargets: boolean;
  89215. /**
  89216. * The list of user defined render targets added to the scene
  89217. */
  89218. customRenderTargets: RenderTargetTexture[];
  89219. /**
  89220. * Defines if texture loading must be delayed
  89221. * If true, textures will only be loaded when they need to be rendered
  89222. */
  89223. useDelayedTextureLoading: boolean;
  89224. /**
  89225. * Gets the list of meshes imported to the scene through SceneLoader
  89226. */
  89227. importedMeshesFiles: String[];
  89228. /**
  89229. * Gets or sets a boolean indicating if probes are enabled on this scene
  89230. */
  89231. probesEnabled: boolean;
  89232. /**
  89233. * Gets or sets the current offline provider to use to store scene data
  89234. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89235. */
  89236. offlineProvider: IOfflineProvider;
  89237. /**
  89238. * Gets or sets the action manager associated with the scene
  89239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89240. */
  89241. actionManager: AbstractActionManager;
  89242. private _meshesForIntersections;
  89243. /**
  89244. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89245. */
  89246. proceduralTexturesEnabled: boolean;
  89247. private _engine;
  89248. private _totalVertices;
  89249. /** @hidden */
  89250. _activeIndices: PerfCounter;
  89251. /** @hidden */
  89252. _activeParticles: PerfCounter;
  89253. /** @hidden */
  89254. _activeBones: PerfCounter;
  89255. private _animationRatio;
  89256. /** @hidden */
  89257. _animationTimeLast: number;
  89258. /** @hidden */
  89259. _animationTime: number;
  89260. /**
  89261. * Gets or sets a general scale for animation speed
  89262. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89263. */
  89264. animationTimeScale: number;
  89265. /** @hidden */
  89266. _cachedMaterial: Nullable<Material>;
  89267. /** @hidden */
  89268. _cachedEffect: Nullable<Effect>;
  89269. /** @hidden */
  89270. _cachedVisibility: Nullable<number>;
  89271. private _renderId;
  89272. private _frameId;
  89273. private _executeWhenReadyTimeoutId;
  89274. private _intermediateRendering;
  89275. private _viewUpdateFlag;
  89276. private _projectionUpdateFlag;
  89277. private _alternateViewUpdateFlag;
  89278. private _alternateProjectionUpdateFlag;
  89279. /** @hidden */
  89280. _toBeDisposed: Nullable<IDisposable>[];
  89281. private _activeRequests;
  89282. /** @hidden */
  89283. _pendingData: any[];
  89284. private _isDisposed;
  89285. /**
  89286. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89287. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89288. */
  89289. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89290. private _activeMeshes;
  89291. private _processedMaterials;
  89292. private _renderTargets;
  89293. /** @hidden */
  89294. _activeParticleSystems: SmartArray<IParticleSystem>;
  89295. private _activeSkeletons;
  89296. private _softwareSkinnedMeshes;
  89297. private _renderingManager;
  89298. /** @hidden */
  89299. _activeAnimatables: Animatable[];
  89300. private _transformMatrix;
  89301. private _sceneUbo;
  89302. private _alternateSceneUbo;
  89303. private _viewMatrix;
  89304. private _projectionMatrix;
  89305. private _alternateViewMatrix;
  89306. private _alternateProjectionMatrix;
  89307. private _alternateTransformMatrix;
  89308. private _useAlternateCameraConfiguration;
  89309. private _alternateRendering;
  89310. private _wheelEventName;
  89311. /** @hidden */
  89312. _forcedViewPosition: Nullable<Vector3>;
  89313. /** @hidden */
  89314. readonly _isAlternateRenderingEnabled: boolean;
  89315. private _frustumPlanes;
  89316. /**
  89317. * Gets the list of frustum planes (built from the active camera)
  89318. */
  89319. readonly frustumPlanes: Plane[];
  89320. /**
  89321. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89322. * This is useful if there are more lights that the maximum simulteanous authorized
  89323. */
  89324. requireLightSorting: boolean;
  89325. /** @hidden */
  89326. readonly useMaterialMeshMap: boolean;
  89327. /** @hidden */
  89328. readonly useClonedMeshhMap: boolean;
  89329. private _pointerOverMesh;
  89330. private _pickedDownMesh;
  89331. private _pickedUpMesh;
  89332. private _externalData;
  89333. private _uid;
  89334. /**
  89335. * @hidden
  89336. * Backing store of defined scene components.
  89337. */
  89338. _components: ISceneComponent[];
  89339. /**
  89340. * @hidden
  89341. * Backing store of defined scene components.
  89342. */
  89343. _serializableComponents: ISceneSerializableComponent[];
  89344. /**
  89345. * List of components to register on the next registration step.
  89346. */
  89347. private _transientComponents;
  89348. /**
  89349. * Registers the transient components if needed.
  89350. */
  89351. private _registerTransientComponents;
  89352. /**
  89353. * @hidden
  89354. * Add a component to the scene.
  89355. * Note that the ccomponent could be registered on th next frame if this is called after
  89356. * the register component stage.
  89357. * @param component Defines the component to add to the scene
  89358. */
  89359. _addComponent(component: ISceneComponent): void;
  89360. /**
  89361. * @hidden
  89362. * Gets a component from the scene.
  89363. * @param name defines the name of the component to retrieve
  89364. * @returns the component or null if not present
  89365. */
  89366. _getComponent(name: string): Nullable<ISceneComponent>;
  89367. /**
  89368. * @hidden
  89369. * Defines the actions happening before camera updates.
  89370. */
  89371. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89372. /**
  89373. * @hidden
  89374. * Defines the actions happening before clear the canvas.
  89375. */
  89376. _beforeClearStage: Stage<SimpleStageAction>;
  89377. /**
  89378. * @hidden
  89379. * Defines the actions when collecting render targets for the frame.
  89380. */
  89381. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89382. /**
  89383. * @hidden
  89384. * Defines the actions happening for one camera in the frame.
  89385. */
  89386. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89387. /**
  89388. * @hidden
  89389. * Defines the actions happening during the per mesh ready checks.
  89390. */
  89391. _isReadyForMeshStage: Stage<MeshStageAction>;
  89392. /**
  89393. * @hidden
  89394. * Defines the actions happening before evaluate active mesh checks.
  89395. */
  89396. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89397. /**
  89398. * @hidden
  89399. * Defines the actions happening during the evaluate sub mesh checks.
  89400. */
  89401. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89402. /**
  89403. * @hidden
  89404. * Defines the actions happening during the active mesh stage.
  89405. */
  89406. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89407. /**
  89408. * @hidden
  89409. * Defines the actions happening during the per camera render target step.
  89410. */
  89411. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89412. /**
  89413. * @hidden
  89414. * Defines the actions happening just before the active camera is drawing.
  89415. */
  89416. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89417. /**
  89418. * @hidden
  89419. * Defines the actions happening just before a render target is drawing.
  89420. */
  89421. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89422. /**
  89423. * @hidden
  89424. * Defines the actions happening just before a rendering group is drawing.
  89425. */
  89426. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89427. /**
  89428. * @hidden
  89429. * Defines the actions happening just before a mesh is drawing.
  89430. */
  89431. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89432. /**
  89433. * @hidden
  89434. * Defines the actions happening just after a mesh has been drawn.
  89435. */
  89436. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89437. /**
  89438. * @hidden
  89439. * Defines the actions happening just after a rendering group has been drawn.
  89440. */
  89441. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89442. /**
  89443. * @hidden
  89444. * Defines the actions happening just after the active camera has been drawn.
  89445. */
  89446. _afterCameraDrawStage: Stage<CameraStageAction>;
  89447. /**
  89448. * @hidden
  89449. * Defines the actions happening just after a render target has been drawn.
  89450. */
  89451. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89452. /**
  89453. * @hidden
  89454. * Defines the actions happening just after rendering all cameras and computing intersections.
  89455. */
  89456. _afterRenderStage: Stage<SimpleStageAction>;
  89457. /**
  89458. * @hidden
  89459. * Defines the actions happening when a pointer move event happens.
  89460. */
  89461. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89462. /**
  89463. * @hidden
  89464. * Defines the actions happening when a pointer down event happens.
  89465. */
  89466. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89467. /**
  89468. * @hidden
  89469. * Defines the actions happening when a pointer up event happens.
  89470. */
  89471. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89472. /**
  89473. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89474. */
  89475. private geometriesByUniqueId;
  89476. /**
  89477. * Creates a new Scene
  89478. * @param engine defines the engine to use to render this scene
  89479. * @param options defines the scene options
  89480. */
  89481. constructor(engine: Engine, options?: SceneOptions);
  89482. private _defaultMeshCandidates;
  89483. /**
  89484. * @hidden
  89485. */
  89486. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89487. private _defaultSubMeshCandidates;
  89488. /**
  89489. * @hidden
  89490. */
  89491. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89492. /**
  89493. * Sets the default candidate providers for the scene.
  89494. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89495. * and getCollidingSubMeshCandidates to their default function
  89496. */
  89497. setDefaultCandidateProviders(): void;
  89498. /**
  89499. * Gets the mesh that is currently under the pointer
  89500. */
  89501. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89502. /**
  89503. * Gets or sets the current on-screen X position of the pointer
  89504. */
  89505. pointerX: number;
  89506. /**
  89507. * Gets or sets the current on-screen Y position of the pointer
  89508. */
  89509. pointerY: number;
  89510. /**
  89511. * Gets the cached material (ie. the latest rendered one)
  89512. * @returns the cached material
  89513. */
  89514. getCachedMaterial(): Nullable<Material>;
  89515. /**
  89516. * Gets the cached effect (ie. the latest rendered one)
  89517. * @returns the cached effect
  89518. */
  89519. getCachedEffect(): Nullable<Effect>;
  89520. /**
  89521. * Gets the cached visibility state (ie. the latest rendered one)
  89522. * @returns the cached visibility state
  89523. */
  89524. getCachedVisibility(): Nullable<number>;
  89525. /**
  89526. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89527. * @param material defines the current material
  89528. * @param effect defines the current effect
  89529. * @param visibility defines the current visibility state
  89530. * @returns true if one parameter is not cached
  89531. */
  89532. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89533. /**
  89534. * Gets the engine associated with the scene
  89535. * @returns an Engine
  89536. */
  89537. getEngine(): Engine;
  89538. /**
  89539. * Gets the total number of vertices rendered per frame
  89540. * @returns the total number of vertices rendered per frame
  89541. */
  89542. getTotalVertices(): number;
  89543. /**
  89544. * Gets the performance counter for total vertices
  89545. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89546. */
  89547. readonly totalVerticesPerfCounter: PerfCounter;
  89548. /**
  89549. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89550. * @returns the total number of active indices rendered per frame
  89551. */
  89552. getActiveIndices(): number;
  89553. /**
  89554. * Gets the performance counter for active indices
  89555. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89556. */
  89557. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89558. /**
  89559. * Gets the total number of active particles rendered per frame
  89560. * @returns the total number of active particles rendered per frame
  89561. */
  89562. getActiveParticles(): number;
  89563. /**
  89564. * Gets the performance counter for active particles
  89565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89566. */
  89567. readonly activeParticlesPerfCounter: PerfCounter;
  89568. /**
  89569. * Gets the total number of active bones rendered per frame
  89570. * @returns the total number of active bones rendered per frame
  89571. */
  89572. getActiveBones(): number;
  89573. /**
  89574. * Gets the performance counter for active bones
  89575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89576. */
  89577. readonly activeBonesPerfCounter: PerfCounter;
  89578. /**
  89579. * Gets the array of active meshes
  89580. * @returns an array of AbstractMesh
  89581. */
  89582. getActiveMeshes(): SmartArray<AbstractMesh>;
  89583. /**
  89584. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89585. * @returns a number
  89586. */
  89587. getAnimationRatio(): number;
  89588. /**
  89589. * Gets an unique Id for the current render phase
  89590. * @returns a number
  89591. */
  89592. getRenderId(): number;
  89593. /**
  89594. * Gets an unique Id for the current frame
  89595. * @returns a number
  89596. */
  89597. getFrameId(): number;
  89598. /** Call this function if you want to manually increment the render Id*/
  89599. incrementRenderId(): void;
  89600. private _updatePointerPosition;
  89601. private _createUbo;
  89602. private _createAlternateUbo;
  89603. private _setRayOnPointerInfo;
  89604. /**
  89605. * Use this method to simulate a pointer move 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. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89612. private _processPointerMove;
  89613. private _checkPrePointerObservable;
  89614. /**
  89615. * Use this method to simulate a pointer down on a mesh
  89616. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89617. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89618. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89619. * @returns the current scene
  89620. */
  89621. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89622. private _processPointerDown;
  89623. /**
  89624. * Use this method to simulate a pointer up on a mesh
  89625. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89626. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89627. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89628. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89629. * @returns the current scene
  89630. */
  89631. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89632. private _processPointerUp;
  89633. /**
  89634. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89635. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89636. * @returns true if the pointer was captured
  89637. */
  89638. isPointerCaptured(pointerId?: number): boolean;
  89639. /** @hidden */
  89640. _isPointerSwiping(): boolean;
  89641. /**
  89642. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89643. * @param attachUp defines if you want to attach events to pointerup
  89644. * @param attachDown defines if you want to attach events to pointerdown
  89645. * @param attachMove defines if you want to attach events to pointermove
  89646. */
  89647. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89648. /** Detaches all event handlers*/
  89649. detachControl(): void;
  89650. /**
  89651. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89652. * Delay loaded resources are not taking in account
  89653. * @return true if all required resources are ready
  89654. */
  89655. isReady(): boolean;
  89656. /** Resets all cached information relative to material (including effect and visibility) */
  89657. resetCachedMaterial(): void;
  89658. /**
  89659. * Registers a function to be called before every frame render
  89660. * @param func defines the function to register
  89661. */
  89662. registerBeforeRender(func: () => void): void;
  89663. /**
  89664. * Unregisters a function called before every frame render
  89665. * @param func defines the function to unregister
  89666. */
  89667. unregisterBeforeRender(func: () => void): void;
  89668. /**
  89669. * Registers a function to be called after every frame render
  89670. * @param func defines the function to register
  89671. */
  89672. registerAfterRender(func: () => void): void;
  89673. /**
  89674. * Unregisters a function called after every frame render
  89675. * @param func defines the function to unregister
  89676. */
  89677. unregisterAfterRender(func: () => void): void;
  89678. private _executeOnceBeforeRender;
  89679. /**
  89680. * The provided function will run before render once and will be disposed afterwards.
  89681. * A timeout delay can be provided so that the function will be executed in N ms.
  89682. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89683. * @param func The function to be executed.
  89684. * @param timeout optional delay in ms
  89685. */
  89686. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89687. /** @hidden */
  89688. _addPendingData(data: any): void;
  89689. /** @hidden */
  89690. _removePendingData(data: any): void;
  89691. /**
  89692. * Returns the number of items waiting to be loaded
  89693. * @returns the number of items waiting to be loaded
  89694. */
  89695. getWaitingItemsCount(): number;
  89696. /**
  89697. * Returns a boolean indicating if the scene is still loading data
  89698. */
  89699. readonly isLoading: boolean;
  89700. /**
  89701. * Registers a function to be executed when the scene is ready
  89702. * @param {Function} func - the function to be executed
  89703. */
  89704. executeWhenReady(func: () => void): void;
  89705. /**
  89706. * Returns a promise that resolves when the scene is ready
  89707. * @returns A promise that resolves when the scene is ready
  89708. */
  89709. whenReadyAsync(): Promise<void>;
  89710. /** @hidden */
  89711. _checkIsReady(): void;
  89712. /**
  89713. * Gets all animatable attached to the scene
  89714. */
  89715. readonly animatables: Animatable[];
  89716. /**
  89717. * Resets the last animation time frame.
  89718. * Useful to override when animations start running when loading a scene for the first time.
  89719. */
  89720. resetLastAnimationTimeFrame(): void;
  89721. /** @hidden */
  89722. _switchToAlternateCameraConfiguration(active: boolean): void;
  89723. /**
  89724. * Gets the current view matrix
  89725. * @returns a Matrix
  89726. */
  89727. getViewMatrix(): Matrix;
  89728. /**
  89729. * Gets the current projection matrix
  89730. * @returns a Matrix
  89731. */
  89732. getProjectionMatrix(): Matrix;
  89733. /**
  89734. * Gets the current transform matrix
  89735. * @returns a Matrix made of View * Projection
  89736. */
  89737. getTransformMatrix(): Matrix;
  89738. /**
  89739. * Sets the current transform matrix
  89740. * @param view defines the View matrix to use
  89741. * @param projection defines the Projection matrix to use
  89742. */
  89743. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89744. /** @hidden */
  89745. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89746. /**
  89747. * Gets the uniform buffer used to store scene data
  89748. * @returns a UniformBuffer
  89749. */
  89750. getSceneUniformBuffer(): UniformBuffer;
  89751. /**
  89752. * Gets an unique (relatively to the current scene) Id
  89753. * @returns an unique number for the scene
  89754. */
  89755. getUniqueId(): number;
  89756. /**
  89757. * Add a mesh to the list of scene's meshes
  89758. * @param newMesh defines the mesh to add
  89759. * @param recursive if all child meshes should also be added to the scene
  89760. */
  89761. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89762. /**
  89763. * Remove a mesh for the list of scene's meshes
  89764. * @param toRemove defines the mesh to remove
  89765. * @param recursive if all child meshes should also be removed from the scene
  89766. * @returns the index where the mesh was in the mesh list
  89767. */
  89768. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89769. /**
  89770. * Add a transform node to the list of scene's transform nodes
  89771. * @param newTransformNode defines the transform node to add
  89772. */
  89773. addTransformNode(newTransformNode: TransformNode): void;
  89774. /**
  89775. * Remove a transform node for the list of scene's transform nodes
  89776. * @param toRemove defines the transform node to remove
  89777. * @returns the index where the transform node was in the transform node list
  89778. */
  89779. removeTransformNode(toRemove: TransformNode): number;
  89780. /**
  89781. * Remove a skeleton for the list of scene's skeletons
  89782. * @param toRemove defines the skeleton to remove
  89783. * @returns the index where the skeleton was in the skeleton list
  89784. */
  89785. removeSkeleton(toRemove: Skeleton): number;
  89786. /**
  89787. * Remove a morph target for the list of scene's morph targets
  89788. * @param toRemove defines the morph target to remove
  89789. * @returns the index where the morph target was in the morph target list
  89790. */
  89791. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89792. /**
  89793. * Remove a light for the list of scene's lights
  89794. * @param toRemove defines the light to remove
  89795. * @returns the index where the light was in the light list
  89796. */
  89797. removeLight(toRemove: Light): number;
  89798. /**
  89799. * Remove a camera for the list of scene's cameras
  89800. * @param toRemove defines the camera to remove
  89801. * @returns the index where the camera was in the camera list
  89802. */
  89803. removeCamera(toRemove: Camera): number;
  89804. /**
  89805. * Remove a particle system for the list of scene's particle systems
  89806. * @param toRemove defines the particle system to remove
  89807. * @returns the index where the particle system was in the particle system list
  89808. */
  89809. removeParticleSystem(toRemove: IParticleSystem): number;
  89810. /**
  89811. * Remove a animation for the list of scene's animations
  89812. * @param toRemove defines the animation to remove
  89813. * @returns the index where the animation was in the animation list
  89814. */
  89815. removeAnimation(toRemove: Animation): number;
  89816. /**
  89817. * Removes the given animation group from this scene.
  89818. * @param toRemove The animation group to remove
  89819. * @returns The index of the removed animation group
  89820. */
  89821. removeAnimationGroup(toRemove: AnimationGroup): number;
  89822. /**
  89823. * Removes the given multi-material from this scene.
  89824. * @param toRemove The multi-material to remove
  89825. * @returns The index of the removed multi-material
  89826. */
  89827. removeMultiMaterial(toRemove: MultiMaterial): number;
  89828. /**
  89829. * Removes the given material from this scene.
  89830. * @param toRemove The material to remove
  89831. * @returns The index of the removed material
  89832. */
  89833. removeMaterial(toRemove: Material): number;
  89834. /**
  89835. * Removes the given action manager from this scene.
  89836. * @param toRemove The action manager to remove
  89837. * @returns The index of the removed action manager
  89838. */
  89839. removeActionManager(toRemove: AbstractActionManager): number;
  89840. /**
  89841. * Removes the given texture from this scene.
  89842. * @param toRemove The texture to remove
  89843. * @returns The index of the removed texture
  89844. */
  89845. removeTexture(toRemove: BaseTexture): number;
  89846. /**
  89847. * Adds the given light to this scene
  89848. * @param newLight The light to add
  89849. */
  89850. addLight(newLight: Light): void;
  89851. /**
  89852. * Sorts the list list based on light priorities
  89853. */
  89854. sortLightsByPriority(): void;
  89855. /**
  89856. * Adds the given camera to this scene
  89857. * @param newCamera The camera to add
  89858. */
  89859. addCamera(newCamera: Camera): void;
  89860. /**
  89861. * Adds the given skeleton to this scene
  89862. * @param newSkeleton The skeleton to add
  89863. */
  89864. addSkeleton(newSkeleton: Skeleton): void;
  89865. /**
  89866. * Adds the given particle system to this scene
  89867. * @param newParticleSystem The particle system to add
  89868. */
  89869. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89870. /**
  89871. * Adds the given animation to this scene
  89872. * @param newAnimation The animation to add
  89873. */
  89874. addAnimation(newAnimation: Animation): void;
  89875. /**
  89876. * Adds the given animation group to this scene.
  89877. * @param newAnimationGroup The animation group to add
  89878. */
  89879. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89880. /**
  89881. * Adds the given multi-material to this scene
  89882. * @param newMultiMaterial The multi-material to add
  89883. */
  89884. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89885. /**
  89886. * Adds the given material to this scene
  89887. * @param newMaterial The material to add
  89888. */
  89889. addMaterial(newMaterial: Material): void;
  89890. /**
  89891. * Adds the given morph target to this scene
  89892. * @param newMorphTargetManager The morph target to add
  89893. */
  89894. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89895. /**
  89896. * Adds the given geometry to this scene
  89897. * @param newGeometry The geometry to add
  89898. */
  89899. addGeometry(newGeometry: Geometry): void;
  89900. /**
  89901. * Adds the given action manager to this scene
  89902. * @param newActionManager The action manager to add
  89903. */
  89904. addActionManager(newActionManager: AbstractActionManager): void;
  89905. /**
  89906. * Adds the given texture to this scene.
  89907. * @param newTexture The texture to add
  89908. */
  89909. addTexture(newTexture: BaseTexture): void;
  89910. /**
  89911. * Switch active camera
  89912. * @param newCamera defines the new active camera
  89913. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89914. */
  89915. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89916. /**
  89917. * sets the active camera of the scene using its ID
  89918. * @param id defines the camera's ID
  89919. * @return the new active camera or null if none found.
  89920. */
  89921. setActiveCameraByID(id: string): Nullable<Camera>;
  89922. /**
  89923. * sets the active camera of the scene using its name
  89924. * @param name defines the camera's name
  89925. * @returns the new active camera or null if none found.
  89926. */
  89927. setActiveCameraByName(name: string): Nullable<Camera>;
  89928. /**
  89929. * get an animation group using its name
  89930. * @param name defines the material's name
  89931. * @return the animation group or null if none found.
  89932. */
  89933. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89934. /**
  89935. * get a material using its id
  89936. * @param id defines the material's ID
  89937. * @return the material or null if none found.
  89938. */
  89939. getMaterialByID(id: string): Nullable<Material>;
  89940. /**
  89941. * Gets a material using its name
  89942. * @param name defines the material's name
  89943. * @return the material or null if none found.
  89944. */
  89945. getMaterialByName(name: string): Nullable<Material>;
  89946. /**
  89947. * Gets a camera using its id
  89948. * @param id defines the id to look for
  89949. * @returns the camera or null if not found
  89950. */
  89951. getCameraByID(id: string): Nullable<Camera>;
  89952. /**
  89953. * Gets a camera using its unique id
  89954. * @param uniqueId defines the unique id to look for
  89955. * @returns the camera or null if not found
  89956. */
  89957. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89958. /**
  89959. * Gets a camera using its name
  89960. * @param name defines the camera's name
  89961. * @return the camera or null if none found.
  89962. */
  89963. getCameraByName(name: string): Nullable<Camera>;
  89964. /**
  89965. * Gets a bone using its id
  89966. * @param id defines the bone's id
  89967. * @return the bone or null if not found
  89968. */
  89969. getBoneByID(id: string): Nullable<Bone>;
  89970. /**
  89971. * Gets a bone using its id
  89972. * @param name defines the bone's name
  89973. * @return the bone or null if not found
  89974. */
  89975. getBoneByName(name: string): Nullable<Bone>;
  89976. /**
  89977. * Gets a light node using its name
  89978. * @param name defines the the light's name
  89979. * @return the light or null if none found.
  89980. */
  89981. getLightByName(name: string): Nullable<Light>;
  89982. /**
  89983. * Gets a light node using its id
  89984. * @param id defines the light's id
  89985. * @return the light or null if none found.
  89986. */
  89987. getLightByID(id: string): Nullable<Light>;
  89988. /**
  89989. * Gets a light node using its scene-generated unique ID
  89990. * @param uniqueId defines the light's unique id
  89991. * @return the light or null if none found.
  89992. */
  89993. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89994. /**
  89995. * Gets a particle system by id
  89996. * @param id defines the particle system id
  89997. * @return the corresponding system or null if none found
  89998. */
  89999. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  90000. /**
  90001. * Gets a geometry using its ID
  90002. * @param id defines the geometry's id
  90003. * @return the geometry or null if none found.
  90004. */
  90005. getGeometryByID(id: string): Nullable<Geometry>;
  90006. private _getGeometryByUniqueID;
  90007. /**
  90008. * Add a new geometry to this scene
  90009. * @param geometry defines the geometry to be added to the scene.
  90010. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  90011. * @return a boolean defining if the geometry was added or not
  90012. */
  90013. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  90014. /**
  90015. * Removes an existing geometry
  90016. * @param geometry defines the geometry to be removed from the scene
  90017. * @return a boolean defining if the geometry was removed or not
  90018. */
  90019. removeGeometry(geometry: Geometry): boolean;
  90020. /**
  90021. * Gets the list of geometries attached to the scene
  90022. * @returns an array of Geometry
  90023. */
  90024. getGeometries(): Geometry[];
  90025. /**
  90026. * Gets the first added mesh found of a given ID
  90027. * @param id defines the id to search for
  90028. * @return the mesh found or null if not found at all
  90029. */
  90030. getMeshByID(id: string): Nullable<AbstractMesh>;
  90031. /**
  90032. * Gets a list of meshes using their id
  90033. * @param id defines the id to search for
  90034. * @returns a list of meshes
  90035. */
  90036. getMeshesByID(id: string): Array<AbstractMesh>;
  90037. /**
  90038. * Gets the first added transform node found of a given ID
  90039. * @param id defines the id to search for
  90040. * @return the found transform node or null if not found at all.
  90041. */
  90042. getTransformNodeByID(id: string): Nullable<TransformNode>;
  90043. /**
  90044. * Gets a list of transform nodes using their id
  90045. * @param id defines the id to search for
  90046. * @returns a list of transform nodes
  90047. */
  90048. getTransformNodesByID(id: string): Array<TransformNode>;
  90049. /**
  90050. * Gets a mesh with its auto-generated unique id
  90051. * @param uniqueId defines the unique id to search for
  90052. * @return the found mesh or null if not found at all.
  90053. */
  90054. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  90055. /**
  90056. * Gets a the last added mesh using a given id
  90057. * @param id defines the id to search for
  90058. * @return the found mesh or null if not found at all.
  90059. */
  90060. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  90061. /**
  90062. * Gets a the last added node (Mesh, Camera, Light) using a given id
  90063. * @param id defines the id to search for
  90064. * @return the found node or null if not found at all
  90065. */
  90066. getLastEntryByID(id: string): Nullable<Node>;
  90067. /**
  90068. * Gets a node (Mesh, Camera, Light) using a given id
  90069. * @param id defines the id to search for
  90070. * @return the found node or null if not found at all
  90071. */
  90072. getNodeByID(id: string): Nullable<Node>;
  90073. /**
  90074. * Gets a node (Mesh, Camera, Light) using a given name
  90075. * @param name defines the name to search for
  90076. * @return the found node or null if not found at all.
  90077. */
  90078. getNodeByName(name: string): Nullable<Node>;
  90079. /**
  90080. * Gets a mesh using a given name
  90081. * @param name defines the name to search for
  90082. * @return the found mesh or null if not found at all.
  90083. */
  90084. getMeshByName(name: string): Nullable<AbstractMesh>;
  90085. /**
  90086. * Gets a transform node using a given name
  90087. * @param name defines the name to search for
  90088. * @return the found transform node or null if not found at all.
  90089. */
  90090. getTransformNodeByName(name: string): Nullable<TransformNode>;
  90091. /**
  90092. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  90093. * @param id defines the id to search for
  90094. * @return the found skeleton or null if not found at all.
  90095. */
  90096. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  90097. /**
  90098. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  90099. * @param id defines the id to search for
  90100. * @return the found skeleton or null if not found at all.
  90101. */
  90102. getSkeletonById(id: string): Nullable<Skeleton>;
  90103. /**
  90104. * Gets a skeleton using a given name
  90105. * @param name defines the name to search for
  90106. * @return the found skeleton or null if not found at all.
  90107. */
  90108. getSkeletonByName(name: string): Nullable<Skeleton>;
  90109. /**
  90110. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  90111. * @param id defines the id to search for
  90112. * @return the found morph target manager or null if not found at all.
  90113. */
  90114. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  90115. /**
  90116. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  90117. * @param id defines the id to search for
  90118. * @return the found morph target or null if not found at all.
  90119. */
  90120. getMorphTargetById(id: string): Nullable<MorphTarget>;
  90121. /**
  90122. * Gets a boolean indicating if the given mesh is active
  90123. * @param mesh defines the mesh to look for
  90124. * @returns true if the mesh is in the active list
  90125. */
  90126. isActiveMesh(mesh: AbstractMesh): boolean;
  90127. /**
  90128. * Return a unique id as a string which can serve as an identifier for the scene
  90129. */
  90130. readonly uid: string;
  90131. /**
  90132. * Add an externaly attached data from its key.
  90133. * This method call will fail and return false, if such key already exists.
  90134. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  90135. * @param key the unique key that identifies the data
  90136. * @param data the data object to associate to the key for this Engine instance
  90137. * @return true if no such key were already present and the data was added successfully, false otherwise
  90138. */
  90139. addExternalData<T>(key: string, data: T): boolean;
  90140. /**
  90141. * Get an externaly attached data from its key
  90142. * @param key the unique key that identifies the data
  90143. * @return the associated data, if present (can be null), or undefined if not present
  90144. */
  90145. getExternalData<T>(key: string): Nullable<T>;
  90146. /**
  90147. * Get an externaly attached data from its key, create it using a factory if it's not already present
  90148. * @param key the unique key that identifies the data
  90149. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  90150. * @return the associated data, can be null if the factory returned null.
  90151. */
  90152. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  90153. /**
  90154. * Remove an externaly attached data from the Engine instance
  90155. * @param key the unique key that identifies the data
  90156. * @return true if the data was successfully removed, false if it doesn't exist
  90157. */
  90158. removeExternalData(key: string): boolean;
  90159. private _evaluateSubMesh;
  90160. /**
  90161. * Clear the processed materials smart array preventing retention point in material dispose.
  90162. */
  90163. freeProcessedMaterials(): void;
  90164. private _preventFreeActiveMeshesAndRenderingGroups;
  90165. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  90166. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  90167. * when disposing several meshes in a row or a hierarchy of meshes.
  90168. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  90169. */
  90170. blockfreeActiveMeshesAndRenderingGroups: boolean;
  90171. /**
  90172. * Clear the active meshes smart array preventing retention point in mesh dispose.
  90173. */
  90174. freeActiveMeshes(): void;
  90175. /**
  90176. * Clear the info related to rendering groups preventing retention points during dispose.
  90177. */
  90178. freeRenderingGroups(): void;
  90179. /** @hidden */
  90180. _isInIntermediateRendering(): boolean;
  90181. /**
  90182. * Lambda returning the list of potentially active meshes.
  90183. */
  90184. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  90185. /**
  90186. * Lambda returning the list of potentially active sub meshes.
  90187. */
  90188. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  90189. /**
  90190. * Lambda returning the list of potentially intersecting sub meshes.
  90191. */
  90192. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  90193. /**
  90194. * Lambda returning the list of potentially colliding sub meshes.
  90195. */
  90196. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  90197. private _activeMeshesFrozen;
  90198. /**
  90199. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  90200. * @returns the current scene
  90201. */
  90202. freezeActiveMeshes(): Scene;
  90203. /**
  90204. * Use this function to restart evaluating active meshes on every frame
  90205. * @returns the current scene
  90206. */
  90207. unfreezeActiveMeshes(): Scene;
  90208. private _evaluateActiveMeshes;
  90209. private _activeMesh;
  90210. /**
  90211. * Update the transform matrix to update from the current active camera
  90212. * @param force defines a boolean used to force the update even if cache is up to date
  90213. */
  90214. updateTransformMatrix(force?: boolean): void;
  90215. /**
  90216. * 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)
  90217. * @param alternateCamera defines the camera to use
  90218. */
  90219. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  90220. /** @hidden */
  90221. _allowPostProcessClearColor: boolean;
  90222. private _renderForCamera;
  90223. private _processSubCameras;
  90224. private _checkIntersections;
  90225. /** @hidden */
  90226. _advancePhysicsEngineStep(step: number): void;
  90227. /**
  90228. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90229. */
  90230. getDeterministicFrameTime: () => number;
  90231. /** @hidden */
  90232. _animate(): void;
  90233. /**
  90234. * Render the scene
  90235. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90236. */
  90237. render(updateCameras?: boolean): void;
  90238. /**
  90239. * Freeze all materials
  90240. * A frozen material will not be updatable but should be faster to render
  90241. */
  90242. freezeMaterials(): void;
  90243. /**
  90244. * Unfreeze all materials
  90245. * A frozen material will not be updatable but should be faster to render
  90246. */
  90247. unfreezeMaterials(): void;
  90248. /**
  90249. * Releases all held ressources
  90250. */
  90251. dispose(): void;
  90252. /**
  90253. * Gets if the scene is already disposed
  90254. */
  90255. readonly isDisposed: boolean;
  90256. /**
  90257. * Call this function to reduce memory footprint of the scene.
  90258. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90259. */
  90260. clearCachedVertexData(): void;
  90261. /**
  90262. * This function will remove the local cached buffer data from texture.
  90263. * It will save memory but will prevent the texture from being rebuilt
  90264. */
  90265. cleanCachedTextureBuffer(): void;
  90266. /**
  90267. * Get the world extend vectors with an optional filter
  90268. *
  90269. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90270. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90271. */
  90272. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90273. min: Vector3;
  90274. max: Vector3;
  90275. };
  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 camera defines the camera to use for the picking
  90282. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90283. * @returns a Ray
  90284. */
  90285. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90286. /**
  90287. * Creates a ray that can be used to pick in the scene
  90288. * @param x defines the x coordinate of the origin (on-screen)
  90289. * @param y defines the y coordinate of the origin (on-screen)
  90290. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90291. * @param result defines the ray where to store the picking ray
  90292. * @param camera defines the camera to use for the picking
  90293. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90294. * @returns the current scene
  90295. */
  90296. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90297. /**
  90298. * Creates a ray that can be used to pick in the scene
  90299. * @param x defines the x coordinate of the origin (on-screen)
  90300. * @param y defines the y coordinate of the origin (on-screen)
  90301. * @param camera defines the camera to use for the picking
  90302. * @returns a Ray
  90303. */
  90304. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90305. /**
  90306. * Creates a ray that can be used to pick in the scene
  90307. * @param x defines the x coordinate of the origin (on-screen)
  90308. * @param y defines the y coordinate of the origin (on-screen)
  90309. * @param result defines the ray where to store the picking ray
  90310. * @param camera defines the camera to use for the picking
  90311. * @returns the current scene
  90312. */
  90313. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90314. /** Launch a ray to try to pick a mesh in the scene
  90315. * @param x position on screen
  90316. * @param y position on screen
  90317. * @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
  90318. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90319. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90320. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90321. * @returns a PickingInfo
  90322. */
  90323. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90324. /** Use the given ray to pick a mesh in the scene
  90325. * @param ray The ray to use to pick meshes
  90326. * @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
  90327. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90328. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90329. * @returns a PickingInfo
  90330. */
  90331. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90332. /**
  90333. * Launch a ray to try to pick a mesh in the scene
  90334. * @param x X position on screen
  90335. * @param y Y position on screen
  90336. * @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
  90337. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90338. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90339. * @returns an array of PickingInfo
  90340. */
  90341. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90342. /**
  90343. * Launch a ray to try to pick a mesh in the scene
  90344. * @param ray Ray to use
  90345. * @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
  90346. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90347. * @returns an array of PickingInfo
  90348. */
  90349. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90350. /**
  90351. * Force the value of meshUnderPointer
  90352. * @param mesh defines the mesh to use
  90353. */
  90354. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90355. /**
  90356. * Gets the mesh under the pointer
  90357. * @returns a Mesh or null if no mesh is under the pointer
  90358. */
  90359. getPointerOverMesh(): Nullable<AbstractMesh>;
  90360. /** @hidden */
  90361. _rebuildGeometries(): void;
  90362. /** @hidden */
  90363. _rebuildTextures(): void;
  90364. private _getByTags;
  90365. /**
  90366. * Get a list of meshes by tags
  90367. * @param tagsQuery defines the tags query to use
  90368. * @param forEach defines a predicate used to filter results
  90369. * @returns an array of Mesh
  90370. */
  90371. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90372. /**
  90373. * Get a list of cameras by tags
  90374. * @param tagsQuery defines the tags query to use
  90375. * @param forEach defines a predicate used to filter results
  90376. * @returns an array of Camera
  90377. */
  90378. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90379. /**
  90380. * Get a list of lights by tags
  90381. * @param tagsQuery defines the tags query to use
  90382. * @param forEach defines a predicate used to filter results
  90383. * @returns an array of Light
  90384. */
  90385. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90386. /**
  90387. * Get a list of materials by tags
  90388. * @param tagsQuery defines the tags query to use
  90389. * @param forEach defines a predicate used to filter results
  90390. * @returns an array of Material
  90391. */
  90392. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90393. /**
  90394. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90395. * This allowed control for front to back rendering or reversly depending of the special needs.
  90396. *
  90397. * @param renderingGroupId The rendering group id corresponding to its index
  90398. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90399. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90400. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90401. */
  90402. 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;
  90403. /**
  90404. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90405. *
  90406. * @param renderingGroupId The rendering group id corresponding to its index
  90407. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90408. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90409. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90410. */
  90411. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90412. /**
  90413. * Gets the current auto clear configuration for one rendering group of the rendering
  90414. * manager.
  90415. * @param index the rendering group index to get the information for
  90416. * @returns The auto clear setup for the requested rendering group
  90417. */
  90418. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90419. private _blockMaterialDirtyMechanism;
  90420. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90421. blockMaterialDirtyMechanism: boolean;
  90422. /**
  90423. * Will flag all materials as dirty to trigger new shader compilation
  90424. * @param flag defines the flag used to specify which material part must be marked as dirty
  90425. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90426. */
  90427. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90428. /** @hidden */
  90429. _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;
  90430. /** @hidden */
  90431. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90432. }
  90433. }
  90434. declare module BABYLON {
  90435. /**
  90436. * Set of assets to keep when moving a scene into an asset container.
  90437. */
  90438. export class KeepAssets extends AbstractScene {
  90439. }
  90440. /**
  90441. * Container with a set of assets that can be added or removed from a scene.
  90442. */
  90443. export class AssetContainer extends AbstractScene {
  90444. /**
  90445. * The scene the AssetContainer belongs to.
  90446. */
  90447. scene: Scene;
  90448. /**
  90449. * Instantiates an AssetContainer.
  90450. * @param scene The scene the AssetContainer belongs to.
  90451. */
  90452. constructor(scene: Scene);
  90453. /**
  90454. * Adds all the assets from the container to the scene.
  90455. */
  90456. addAllToScene(): void;
  90457. /**
  90458. * Removes all the assets in the container from the scene
  90459. */
  90460. removeAllFromScene(): void;
  90461. /**
  90462. * Disposes all the assets in the container
  90463. */
  90464. dispose(): void;
  90465. private _moveAssets;
  90466. /**
  90467. * Removes all the assets contained in the scene and adds them to the container.
  90468. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90469. */
  90470. moveAllFromScene(keepAssets?: KeepAssets): void;
  90471. /**
  90472. * 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.
  90473. * @returns the root mesh
  90474. */
  90475. createRootMesh(): Mesh;
  90476. }
  90477. }
  90478. declare module BABYLON {
  90479. /**
  90480. * Defines how the parser contract is defined.
  90481. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90482. */
  90483. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90484. /**
  90485. * Defines how the individual parser contract is defined.
  90486. * These parser can parse an individual asset
  90487. */
  90488. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90489. /**
  90490. * Base class of the scene acting as a container for the different elements composing a scene.
  90491. * This class is dynamically extended by the different components of the scene increasing
  90492. * flexibility and reducing coupling
  90493. */
  90494. export abstract class AbstractScene {
  90495. /**
  90496. * Stores the list of available parsers in the application.
  90497. */
  90498. private static _BabylonFileParsers;
  90499. /**
  90500. * Stores the list of available individual parsers in the application.
  90501. */
  90502. private static _IndividualBabylonFileParsers;
  90503. /**
  90504. * Adds a parser in the list of available ones
  90505. * @param name Defines the name of the parser
  90506. * @param parser Defines the parser to add
  90507. */
  90508. static AddParser(name: string, parser: BabylonFileParser): void;
  90509. /**
  90510. * Gets a general parser from the list of avaialble ones
  90511. * @param name Defines the name of the parser
  90512. * @returns the requested parser or null
  90513. */
  90514. static GetParser(name: string): Nullable<BabylonFileParser>;
  90515. /**
  90516. * Adds n individual parser in the list of available ones
  90517. * @param name Defines the name of the parser
  90518. * @param parser Defines the parser to add
  90519. */
  90520. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90521. /**
  90522. * Gets an individual parser from the list of avaialble ones
  90523. * @param name Defines the name of the parser
  90524. * @returns the requested parser or null
  90525. */
  90526. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90527. /**
  90528. * Parser json data and populate both a scene and its associated container object
  90529. * @param jsonData Defines the data to parse
  90530. * @param scene Defines the scene to parse the data for
  90531. * @param container Defines the container attached to the parsing sequence
  90532. * @param rootUrl Defines the root url of the data
  90533. */
  90534. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90535. /**
  90536. * Gets the list of root nodes (ie. nodes with no parent)
  90537. */
  90538. rootNodes: Node[];
  90539. /** All of the cameras added to this scene
  90540. * @see http://doc.babylonjs.com/babylon101/cameras
  90541. */
  90542. cameras: Camera[];
  90543. /**
  90544. * All of the lights added to this scene
  90545. * @see http://doc.babylonjs.com/babylon101/lights
  90546. */
  90547. lights: Light[];
  90548. /**
  90549. * All of the (abstract) meshes added to this scene
  90550. */
  90551. meshes: AbstractMesh[];
  90552. /**
  90553. * The list of skeletons added to the scene
  90554. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90555. */
  90556. skeletons: Skeleton[];
  90557. /**
  90558. * All of the particle systems added to this scene
  90559. * @see http://doc.babylonjs.com/babylon101/particles
  90560. */
  90561. particleSystems: IParticleSystem[];
  90562. /**
  90563. * Gets a list of Animations associated with the scene
  90564. */
  90565. animations: Animation[];
  90566. /**
  90567. * All of the animation groups added to this scene
  90568. * @see http://doc.babylonjs.com/how_to/group
  90569. */
  90570. animationGroups: AnimationGroup[];
  90571. /**
  90572. * All of the multi-materials added to this scene
  90573. * @see http://doc.babylonjs.com/how_to/multi_materials
  90574. */
  90575. multiMaterials: MultiMaterial[];
  90576. /**
  90577. * All of the materials added to this scene
  90578. * In the context of a Scene, it is not supposed to be modified manually.
  90579. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90580. * Note also that the order of the Material wihin the array is not significant and might change.
  90581. * @see http://doc.babylonjs.com/babylon101/materials
  90582. */
  90583. materials: Material[];
  90584. /**
  90585. * The list of morph target managers added to the scene
  90586. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90587. */
  90588. morphTargetManagers: MorphTargetManager[];
  90589. /**
  90590. * The list of geometries used in the scene.
  90591. */
  90592. geometries: Geometry[];
  90593. /**
  90594. * All of the tranform nodes added to this scene
  90595. * In the context of a Scene, it is not supposed to be modified manually.
  90596. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90597. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90598. * @see http://doc.babylonjs.com/how_to/transformnode
  90599. */
  90600. transformNodes: TransformNode[];
  90601. /**
  90602. * ActionManagers available on the scene.
  90603. */
  90604. actionManagers: AbstractActionManager[];
  90605. /**
  90606. * Textures to keep.
  90607. */
  90608. textures: BaseTexture[];
  90609. }
  90610. }
  90611. declare module BABYLON {
  90612. /**
  90613. * Defines a sound that can be played in the application.
  90614. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90616. */
  90617. export class Sound {
  90618. /**
  90619. * The name of the sound in the scene.
  90620. */
  90621. name: string;
  90622. /**
  90623. * Does the sound autoplay once loaded.
  90624. */
  90625. autoplay: boolean;
  90626. /**
  90627. * Does the sound loop after it finishes playing once.
  90628. */
  90629. loop: boolean;
  90630. /**
  90631. * Does the sound use a custom attenuation curve to simulate the falloff
  90632. * happening when the source gets further away from the camera.
  90633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90634. */
  90635. useCustomAttenuation: boolean;
  90636. /**
  90637. * The sound track id this sound belongs to.
  90638. */
  90639. soundTrackId: number;
  90640. /**
  90641. * Is this sound currently played.
  90642. */
  90643. isPlaying: boolean;
  90644. /**
  90645. * Is this sound currently paused.
  90646. */
  90647. isPaused: boolean;
  90648. /**
  90649. * Does this sound enables spatial sound.
  90650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90651. */
  90652. spatialSound: boolean;
  90653. /**
  90654. * Define the reference distance the sound should be heard perfectly.
  90655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90656. */
  90657. refDistance: number;
  90658. /**
  90659. * Define the roll off factor of spatial sounds.
  90660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90661. */
  90662. rolloffFactor: number;
  90663. /**
  90664. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90666. */
  90667. maxDistance: number;
  90668. /**
  90669. * Define the distance attenuation model the sound will follow.
  90670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90671. */
  90672. distanceModel: string;
  90673. /**
  90674. * @hidden
  90675. * Back Compat
  90676. **/
  90677. onended: () => any;
  90678. /**
  90679. * Observable event when the current playing sound finishes.
  90680. */
  90681. onEndedObservable: Observable<Sound>;
  90682. private _panningModel;
  90683. private _playbackRate;
  90684. private _streaming;
  90685. private _startTime;
  90686. private _startOffset;
  90687. private _position;
  90688. /** @hidden */
  90689. _positionInEmitterSpace: boolean;
  90690. private _localDirection;
  90691. private _volume;
  90692. private _isReadyToPlay;
  90693. private _isDirectional;
  90694. private _readyToPlayCallback;
  90695. private _audioBuffer;
  90696. private _soundSource;
  90697. private _streamingSource;
  90698. private _soundPanner;
  90699. private _soundGain;
  90700. private _inputAudioNode;
  90701. private _outputAudioNode;
  90702. private _coneInnerAngle;
  90703. private _coneOuterAngle;
  90704. private _coneOuterGain;
  90705. private _scene;
  90706. private _connectedTransformNode;
  90707. private _customAttenuationFunction;
  90708. private _registerFunc;
  90709. private _isOutputConnected;
  90710. private _htmlAudioElement;
  90711. private _urlType;
  90712. /** @hidden */
  90713. static _SceneComponentInitialization: (scene: Scene) => void;
  90714. /**
  90715. * Create a sound and attach it to a scene
  90716. * @param name Name of your sound
  90717. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90718. * @param scene defines the scene the sound belongs to
  90719. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90720. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90721. */
  90722. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90723. /**
  90724. * Release the sound and its associated resources
  90725. */
  90726. dispose(): void;
  90727. /**
  90728. * Gets if the sounds is ready to be played or not.
  90729. * @returns true if ready, otherwise false
  90730. */
  90731. isReady(): boolean;
  90732. private _soundLoaded;
  90733. /**
  90734. * Sets the data of the sound from an audiobuffer
  90735. * @param audioBuffer The audioBuffer containing the data
  90736. */
  90737. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90738. /**
  90739. * Updates the current sounds options such as maxdistance, loop...
  90740. * @param options A JSON object containing values named as the object properties
  90741. */
  90742. updateOptions(options: any): void;
  90743. private _createSpatialParameters;
  90744. private _updateSpatialParameters;
  90745. /**
  90746. * Switch the panning model to HRTF:
  90747. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90749. */
  90750. switchPanningModelToHRTF(): void;
  90751. /**
  90752. * Switch the panning model to Equal Power:
  90753. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90755. */
  90756. switchPanningModelToEqualPower(): void;
  90757. private _switchPanningModel;
  90758. /**
  90759. * Connect this sound to a sound track audio node like gain...
  90760. * @param soundTrackAudioNode the sound track audio node to connect to
  90761. */
  90762. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90763. /**
  90764. * Transform this sound into a directional source
  90765. * @param coneInnerAngle Size of the inner cone in degree
  90766. * @param coneOuterAngle Size of the outer cone in degree
  90767. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90768. */
  90769. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90770. /**
  90771. * Gets or sets the inner angle for the directional cone.
  90772. */
  90773. /**
  90774. * Gets or sets the inner angle for the directional cone.
  90775. */
  90776. directionalConeInnerAngle: number;
  90777. /**
  90778. * Gets or sets the outer angle for the directional cone.
  90779. */
  90780. /**
  90781. * Gets or sets the outer angle for the directional cone.
  90782. */
  90783. directionalConeOuterAngle: number;
  90784. /**
  90785. * Sets the position of the emitter if spatial sound is enabled
  90786. * @param newPosition Defines the new posisiton
  90787. */
  90788. setPosition(newPosition: Vector3): void;
  90789. /**
  90790. * Sets the local direction of the emitter if spatial sound is enabled
  90791. * @param newLocalDirection Defines the new local direction
  90792. */
  90793. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90794. private _updateDirection;
  90795. /** @hidden */
  90796. updateDistanceFromListener(): void;
  90797. /**
  90798. * Sets a new custom attenuation function for the sound.
  90799. * @param callback Defines the function used for the attenuation
  90800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90801. */
  90802. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90803. /**
  90804. * Play the sound
  90805. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90806. * @param offset (optional) Start the sound setting it at a specific time
  90807. */
  90808. play(time?: number, offset?: number): void;
  90809. private _onended;
  90810. /**
  90811. * Stop the sound
  90812. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90813. */
  90814. stop(time?: number): void;
  90815. /**
  90816. * Put the sound in pause
  90817. */
  90818. pause(): void;
  90819. /**
  90820. * Sets a dedicated volume for this sounds
  90821. * @param newVolume Define the new volume of the sound
  90822. * @param time Define in how long the sound should be at this value
  90823. */
  90824. setVolume(newVolume: number, time?: number): void;
  90825. /**
  90826. * Set the sound play back rate
  90827. * @param newPlaybackRate Define the playback rate the sound should be played at
  90828. */
  90829. setPlaybackRate(newPlaybackRate: number): void;
  90830. /**
  90831. * Gets the volume of the sound.
  90832. * @returns the volume of the sound
  90833. */
  90834. getVolume(): number;
  90835. /**
  90836. * Attach the sound to a dedicated mesh
  90837. * @param transformNode The transform node to connect the sound with
  90838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90839. */
  90840. attachToMesh(transformNode: TransformNode): void;
  90841. /**
  90842. * Detach the sound from the previously attached mesh
  90843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90844. */
  90845. detachFromMesh(): void;
  90846. private _onRegisterAfterWorldMatrixUpdate;
  90847. /**
  90848. * Clone the current sound in the scene.
  90849. * @returns the new sound clone
  90850. */
  90851. clone(): Nullable<Sound>;
  90852. /**
  90853. * Gets the current underlying audio buffer containing the data
  90854. * @returns the audio buffer
  90855. */
  90856. getAudioBuffer(): Nullable<AudioBuffer>;
  90857. /**
  90858. * Serializes the Sound in a JSON representation
  90859. * @returns the JSON representation of the sound
  90860. */
  90861. serialize(): any;
  90862. /**
  90863. * Parse a JSON representation of a sound to innstantiate in a given scene
  90864. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90865. * @param scene Define the scene the new parsed sound should be created in
  90866. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90867. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90868. * @returns the newly parsed sound
  90869. */
  90870. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90871. }
  90872. }
  90873. declare module BABYLON {
  90874. /**
  90875. * This defines an action helpful to play a defined sound on a triggered action.
  90876. */
  90877. export class PlaySoundAction extends Action {
  90878. private _sound;
  90879. /**
  90880. * Instantiate the action
  90881. * @param triggerOptions defines the trigger options
  90882. * @param sound defines the sound to play
  90883. * @param condition defines the trigger related conditions
  90884. */
  90885. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90886. /** @hidden */
  90887. _prepare(): void;
  90888. /**
  90889. * Execute the action and play the sound.
  90890. */
  90891. execute(): void;
  90892. /**
  90893. * Serializes the actions and its related information.
  90894. * @param parent defines the object to serialize in
  90895. * @returns the serialized object
  90896. */
  90897. serialize(parent: any): any;
  90898. }
  90899. /**
  90900. * This defines an action helpful to stop a defined sound on a triggered action.
  90901. */
  90902. export class StopSoundAction extends Action {
  90903. private _sound;
  90904. /**
  90905. * Instantiate the action
  90906. * @param triggerOptions defines the trigger options
  90907. * @param sound defines the sound to stop
  90908. * @param condition defines the trigger related conditions
  90909. */
  90910. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90911. /** @hidden */
  90912. _prepare(): void;
  90913. /**
  90914. * Execute the action and stop the sound.
  90915. */
  90916. execute(): void;
  90917. /**
  90918. * Serializes the actions and its related information.
  90919. * @param parent defines the object to serialize in
  90920. * @returns the serialized object
  90921. */
  90922. serialize(parent: any): any;
  90923. }
  90924. }
  90925. declare module BABYLON {
  90926. /**
  90927. * This defines an action responsible to change the value of a property
  90928. * by interpolating between its current value and the newly set one once triggered.
  90929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90930. */
  90931. export class InterpolateValueAction extends Action {
  90932. /**
  90933. * Defines the path of the property where the value should be interpolated
  90934. */
  90935. propertyPath: string;
  90936. /**
  90937. * Defines the target value at the end of the interpolation.
  90938. */
  90939. value: any;
  90940. /**
  90941. * Defines the time it will take for the property to interpolate to the value.
  90942. */
  90943. duration: number;
  90944. /**
  90945. * Defines if the other scene animations should be stopped when the action has been triggered
  90946. */
  90947. stopOtherAnimations?: boolean;
  90948. /**
  90949. * Defines a callback raised once the interpolation animation has been done.
  90950. */
  90951. onInterpolationDone?: () => void;
  90952. /**
  90953. * Observable triggered once the interpolation animation has been done.
  90954. */
  90955. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90956. private _target;
  90957. private _effectiveTarget;
  90958. private _property;
  90959. /**
  90960. * Instantiate the action
  90961. * @param triggerOptions defines the trigger options
  90962. * @param target defines the object containing the value to interpolate
  90963. * @param propertyPath defines the path to the property in the target object
  90964. * @param value defines the target value at the end of the interpolation
  90965. * @param duration deines the time it will take for the property to interpolate to the value.
  90966. * @param condition defines the trigger related conditions
  90967. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90968. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90969. */
  90970. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90971. /** @hidden */
  90972. _prepare(): void;
  90973. /**
  90974. * Execute the action starts the value interpolation.
  90975. */
  90976. execute(): void;
  90977. /**
  90978. * Serializes the actions and its related information.
  90979. * @param parent defines the object to serialize in
  90980. * @returns the serialized object
  90981. */
  90982. serialize(parent: any): any;
  90983. }
  90984. }
  90985. declare module BABYLON {
  90986. /**
  90987. * Options allowed during the creation of a sound track.
  90988. */
  90989. export interface ISoundTrackOptions {
  90990. /**
  90991. * The volume the sound track should take during creation
  90992. */
  90993. volume?: number;
  90994. /**
  90995. * Define if the sound track is the main sound track of the scene
  90996. */
  90997. mainTrack?: boolean;
  90998. }
  90999. /**
  91000. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  91001. * It will be also used in a future release to apply effects on a specific track.
  91002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91003. */
  91004. export class SoundTrack {
  91005. /**
  91006. * The unique identifier of the sound track in the scene.
  91007. */
  91008. id: number;
  91009. /**
  91010. * The list of sounds included in the sound track.
  91011. */
  91012. soundCollection: Array<Sound>;
  91013. private _outputAudioNode;
  91014. private _scene;
  91015. private _isMainTrack;
  91016. private _connectedAnalyser;
  91017. private _options;
  91018. private _isInitialized;
  91019. /**
  91020. * Creates a new sound track.
  91021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91022. * @param scene Define the scene the sound track belongs to
  91023. * @param options
  91024. */
  91025. constructor(scene: Scene, options?: ISoundTrackOptions);
  91026. private _initializeSoundTrackAudioGraph;
  91027. /**
  91028. * Release the sound track and its associated resources
  91029. */
  91030. dispose(): void;
  91031. /**
  91032. * Adds a sound to this sound track
  91033. * @param sound define the cound to add
  91034. * @ignoreNaming
  91035. */
  91036. AddSound(sound: Sound): void;
  91037. /**
  91038. * Removes a sound to this sound track
  91039. * @param sound define the cound to remove
  91040. * @ignoreNaming
  91041. */
  91042. RemoveSound(sound: Sound): void;
  91043. /**
  91044. * Set a global volume for the full sound track.
  91045. * @param newVolume Define the new volume of the sound track
  91046. */
  91047. setVolume(newVolume: number): void;
  91048. /**
  91049. * Switch the panning model to HRTF:
  91050. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91052. */
  91053. switchPanningModelToHRTF(): void;
  91054. /**
  91055. * Switch the panning model to Equal Power:
  91056. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91058. */
  91059. switchPanningModelToEqualPower(): void;
  91060. /**
  91061. * Connect the sound track to an audio analyser allowing some amazing
  91062. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  91063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  91064. * @param analyser The analyser to connect to the engine
  91065. */
  91066. connectToAnalyser(analyser: Analyser): void;
  91067. }
  91068. }
  91069. declare module BABYLON {
  91070. interface AbstractScene {
  91071. /**
  91072. * The list of sounds used in the scene.
  91073. */
  91074. sounds: Nullable<Array<Sound>>;
  91075. }
  91076. interface Scene {
  91077. /**
  91078. * @hidden
  91079. * Backing field
  91080. */
  91081. _mainSoundTrack: SoundTrack;
  91082. /**
  91083. * The main sound track played by the scene.
  91084. * It cotains your primary collection of sounds.
  91085. */
  91086. mainSoundTrack: SoundTrack;
  91087. /**
  91088. * The list of sound tracks added to the scene
  91089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91090. */
  91091. soundTracks: Nullable<Array<SoundTrack>>;
  91092. /**
  91093. * Gets a sound using a given name
  91094. * @param name defines the name to search for
  91095. * @return the found sound or null if not found at all.
  91096. */
  91097. getSoundByName(name: string): Nullable<Sound>;
  91098. /**
  91099. * Gets or sets if audio support is enabled
  91100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91101. */
  91102. audioEnabled: boolean;
  91103. /**
  91104. * Gets or sets if audio will be output to headphones
  91105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91106. */
  91107. headphone: boolean;
  91108. }
  91109. /**
  91110. * Defines the sound scene component responsible to manage any sounds
  91111. * in a given scene.
  91112. */
  91113. export class AudioSceneComponent implements ISceneSerializableComponent {
  91114. /**
  91115. * The component name helpfull to identify the component in the list of scene components.
  91116. */
  91117. readonly name: string;
  91118. /**
  91119. * The scene the component belongs to.
  91120. */
  91121. scene: Scene;
  91122. private _audioEnabled;
  91123. /**
  91124. * Gets whether audio is enabled or not.
  91125. * Please use related enable/disable method to switch state.
  91126. */
  91127. readonly audioEnabled: boolean;
  91128. private _headphone;
  91129. /**
  91130. * Gets whether audio is outputing to headphone or not.
  91131. * Please use the according Switch methods to change output.
  91132. */
  91133. readonly headphone: boolean;
  91134. /**
  91135. * Creates a new instance of the component for the given scene
  91136. * @param scene Defines the scene to register the component in
  91137. */
  91138. constructor(scene: Scene);
  91139. /**
  91140. * Registers the component in a given scene
  91141. */
  91142. register(): void;
  91143. /**
  91144. * Rebuilds the elements related to this component in case of
  91145. * context lost for instance.
  91146. */
  91147. rebuild(): void;
  91148. /**
  91149. * Serializes the component data to the specified json object
  91150. * @param serializationObject The object to serialize to
  91151. */
  91152. serialize(serializationObject: any): void;
  91153. /**
  91154. * Adds all the element from the container to the scene
  91155. * @param container the container holding the elements
  91156. */
  91157. addFromContainer(container: AbstractScene): void;
  91158. /**
  91159. * Removes all the elements in the container from the scene
  91160. * @param container contains the elements to remove
  91161. */
  91162. removeFromContainer(container: AbstractScene): void;
  91163. /**
  91164. * Disposes the component and the associated ressources.
  91165. */
  91166. dispose(): void;
  91167. /**
  91168. * Disables audio in the associated scene.
  91169. */
  91170. disableAudio(): void;
  91171. /**
  91172. * Enables audio in the associated scene.
  91173. */
  91174. enableAudio(): void;
  91175. /**
  91176. * Switch audio to headphone output.
  91177. */
  91178. switchAudioModeForHeadphones(): void;
  91179. /**
  91180. * Switch audio to normal speakers.
  91181. */
  91182. switchAudioModeForNormalSpeakers(): void;
  91183. private _afterRender;
  91184. }
  91185. }
  91186. declare module BABYLON {
  91187. /**
  91188. * Wraps one or more Sound objects and selects one with random weight for playback.
  91189. */
  91190. export class WeightedSound {
  91191. /** When true a Sound will be selected and played when the current playing Sound completes. */
  91192. loop: boolean;
  91193. private _coneInnerAngle;
  91194. private _coneOuterAngle;
  91195. private _volume;
  91196. /** A Sound is currently playing. */
  91197. isPlaying: boolean;
  91198. /** A Sound is currently paused. */
  91199. isPaused: boolean;
  91200. private _sounds;
  91201. private _weights;
  91202. private _currentIndex?;
  91203. /**
  91204. * Creates a new WeightedSound from the list of sounds given.
  91205. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  91206. * @param sounds Array of Sounds that will be selected from.
  91207. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  91208. */
  91209. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  91210. /**
  91211. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  91212. */
  91213. /**
  91214. * The size of cone in degress for a directional sound in which there will be no attenuation.
  91215. */
  91216. directionalConeInnerAngle: number;
  91217. /**
  91218. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91219. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91220. */
  91221. /**
  91222. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91223. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91224. */
  91225. directionalConeOuterAngle: number;
  91226. /**
  91227. * Playback volume.
  91228. */
  91229. /**
  91230. * Playback volume.
  91231. */
  91232. volume: number;
  91233. private _onended;
  91234. /**
  91235. * Suspend playback
  91236. */
  91237. pause(): void;
  91238. /**
  91239. * Stop playback
  91240. */
  91241. stop(): void;
  91242. /**
  91243. * Start playback.
  91244. * @param startOffset Position the clip head at a specific time in seconds.
  91245. */
  91246. play(startOffset?: number): void;
  91247. }
  91248. }
  91249. declare module BABYLON {
  91250. /**
  91251. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91252. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91253. */
  91254. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91255. /**
  91256. * Gets the name of the behavior.
  91257. */
  91258. readonly name: string;
  91259. /**
  91260. * The easing function used by animations
  91261. */
  91262. static EasingFunction: BackEase;
  91263. /**
  91264. * The easing mode used by animations
  91265. */
  91266. static EasingMode: number;
  91267. /**
  91268. * The duration of the animation, in milliseconds
  91269. */
  91270. transitionDuration: number;
  91271. /**
  91272. * Length of the distance animated by the transition when lower radius is reached
  91273. */
  91274. lowerRadiusTransitionRange: number;
  91275. /**
  91276. * Length of the distance animated by the transition when upper radius is reached
  91277. */
  91278. upperRadiusTransitionRange: number;
  91279. private _autoTransitionRange;
  91280. /**
  91281. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91282. */
  91283. /**
  91284. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91285. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91286. */
  91287. autoTransitionRange: boolean;
  91288. private _attachedCamera;
  91289. private _onAfterCheckInputsObserver;
  91290. private _onMeshTargetChangedObserver;
  91291. /**
  91292. * Initializes the behavior.
  91293. */
  91294. init(): void;
  91295. /**
  91296. * Attaches the behavior to its arc rotate camera.
  91297. * @param camera Defines the camera to attach the behavior to
  91298. */
  91299. attach(camera: ArcRotateCamera): void;
  91300. /**
  91301. * Detaches the behavior from its current arc rotate camera.
  91302. */
  91303. detach(): void;
  91304. private _radiusIsAnimating;
  91305. private _radiusBounceTransition;
  91306. private _animatables;
  91307. private _cachedWheelPrecision;
  91308. /**
  91309. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91310. * @param radiusLimit The limit to check against.
  91311. * @return Bool to indicate if at limit.
  91312. */
  91313. private _isRadiusAtLimit;
  91314. /**
  91315. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91316. * @param radiusDelta The delta by which to animate to. Can be negative.
  91317. */
  91318. private _applyBoundRadiusAnimation;
  91319. /**
  91320. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91321. */
  91322. protected _clearAnimationLocks(): void;
  91323. /**
  91324. * Stops and removes all animations that have been applied to the camera
  91325. */
  91326. stopAllAnimations(): void;
  91327. }
  91328. }
  91329. declare module BABYLON {
  91330. /**
  91331. * 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.
  91332. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91333. */
  91334. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91335. /**
  91336. * Gets the name of the behavior.
  91337. */
  91338. readonly name: string;
  91339. private _mode;
  91340. private _radiusScale;
  91341. private _positionScale;
  91342. private _defaultElevation;
  91343. private _elevationReturnTime;
  91344. private _elevationReturnWaitTime;
  91345. private _zoomStopsAnimation;
  91346. private _framingTime;
  91347. /**
  91348. * The easing function used by animations
  91349. */
  91350. static EasingFunction: ExponentialEase;
  91351. /**
  91352. * The easing mode used by animations
  91353. */
  91354. static EasingMode: number;
  91355. /**
  91356. * Sets the current mode used by the behavior
  91357. */
  91358. /**
  91359. * Gets current mode used by the behavior.
  91360. */
  91361. mode: number;
  91362. /**
  91363. * Sets the scale applied to the radius (1 by default)
  91364. */
  91365. /**
  91366. * Gets the scale applied to the radius
  91367. */
  91368. radiusScale: number;
  91369. /**
  91370. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91371. */
  91372. /**
  91373. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91374. */
  91375. positionScale: number;
  91376. /**
  91377. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91378. * behaviour is triggered, in radians.
  91379. */
  91380. /**
  91381. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91382. * behaviour is triggered, in radians.
  91383. */
  91384. defaultElevation: number;
  91385. /**
  91386. * Sets the time (in milliseconds) taken to return to the default beta position.
  91387. * Negative value indicates camera should not return to default.
  91388. */
  91389. /**
  91390. * Gets the time (in milliseconds) taken to return to the default beta position.
  91391. * Negative value indicates camera should not return to default.
  91392. */
  91393. elevationReturnTime: number;
  91394. /**
  91395. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91396. */
  91397. /**
  91398. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91399. */
  91400. elevationReturnWaitTime: number;
  91401. /**
  91402. * Sets the flag that indicates if user zooming should stop animation.
  91403. */
  91404. /**
  91405. * Gets the flag that indicates if user zooming should stop animation.
  91406. */
  91407. zoomStopsAnimation: boolean;
  91408. /**
  91409. * Sets the transition time when framing the mesh, in milliseconds
  91410. */
  91411. /**
  91412. * Gets the transition time when framing the mesh, in milliseconds
  91413. */
  91414. framingTime: number;
  91415. /**
  91416. * Define if the behavior should automatically change the configured
  91417. * camera limits and sensibilities.
  91418. */
  91419. autoCorrectCameraLimitsAndSensibility: boolean;
  91420. private _onPrePointerObservableObserver;
  91421. private _onAfterCheckInputsObserver;
  91422. private _onMeshTargetChangedObserver;
  91423. private _attachedCamera;
  91424. private _isPointerDown;
  91425. private _lastInteractionTime;
  91426. /**
  91427. * Initializes the behavior.
  91428. */
  91429. init(): void;
  91430. /**
  91431. * Attaches the behavior to its arc rotate camera.
  91432. * @param camera Defines the camera to attach the behavior to
  91433. */
  91434. attach(camera: ArcRotateCamera): void;
  91435. /**
  91436. * Detaches the behavior from its current arc rotate camera.
  91437. */
  91438. detach(): void;
  91439. private _animatables;
  91440. private _betaIsAnimating;
  91441. private _betaTransition;
  91442. private _radiusTransition;
  91443. private _vectorTransition;
  91444. /**
  91445. * Targets the given mesh and updates zoom level accordingly.
  91446. * @param mesh The mesh to target.
  91447. * @param radius Optional. If a cached radius position already exists, overrides default.
  91448. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91449. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91450. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91451. */
  91452. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91453. /**
  91454. * Targets the given mesh with its children and updates zoom level accordingly.
  91455. * @param mesh The mesh to target.
  91456. * @param radius Optional. If a cached radius position already exists, overrides default.
  91457. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91458. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91459. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91460. */
  91461. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91462. /**
  91463. * Targets the given meshes with their children and updates zoom level accordingly.
  91464. * @param meshes The mesh to target.
  91465. * @param radius Optional. If a cached radius position already exists, overrides default.
  91466. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91467. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91468. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91469. */
  91470. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91471. /**
  91472. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91473. * @param minimumWorld Determines the smaller position of the bounding box extend
  91474. * @param maximumWorld Determines the bigger position of the bounding box extend
  91475. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91476. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91477. */
  91478. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91479. /**
  91480. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91481. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91482. * frustum width.
  91483. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91484. * to fully enclose the mesh in the viewing frustum.
  91485. */
  91486. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91487. /**
  91488. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91489. * is automatically returned to its default position (expected to be above ground plane).
  91490. */
  91491. private _maintainCameraAboveGround;
  91492. /**
  91493. * Returns the frustum slope based on the canvas ratio and camera FOV
  91494. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91495. */
  91496. private _getFrustumSlope;
  91497. /**
  91498. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91499. */
  91500. private _clearAnimationLocks;
  91501. /**
  91502. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91503. */
  91504. private _applyUserInteraction;
  91505. /**
  91506. * Stops and removes all animations that have been applied to the camera
  91507. */
  91508. stopAllAnimations(): void;
  91509. /**
  91510. * Gets a value indicating if the user is moving the camera
  91511. */
  91512. readonly isUserIsMoving: boolean;
  91513. /**
  91514. * The camera can move all the way towards the mesh.
  91515. */
  91516. static IgnoreBoundsSizeMode: number;
  91517. /**
  91518. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91519. */
  91520. static FitFrustumSidesMode: number;
  91521. }
  91522. }
  91523. declare module BABYLON {
  91524. /**
  91525. * Base class for Camera Pointer Inputs.
  91526. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91527. * for example usage.
  91528. */
  91529. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91530. /**
  91531. * Defines the camera the input is attached to.
  91532. */
  91533. abstract camera: Camera;
  91534. /**
  91535. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91536. */
  91537. protected _altKey: boolean;
  91538. protected _ctrlKey: boolean;
  91539. protected _metaKey: boolean;
  91540. protected _shiftKey: boolean;
  91541. /**
  91542. * Which mouse buttons were pressed at time of last mouse event.
  91543. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91544. */
  91545. protected _buttonsPressed: number;
  91546. /**
  91547. * Defines the buttons associated with the input to handle camera move.
  91548. */
  91549. buttons: number[];
  91550. /**
  91551. * Attach the input controls to a specific dom element to get the input from.
  91552. * @param element Defines the element the controls should be listened from
  91553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91554. */
  91555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91556. /**
  91557. * Detach the current controls from the specified dom element.
  91558. * @param element Defines the element to stop listening the inputs from
  91559. */
  91560. detachControl(element: Nullable<HTMLElement>): void;
  91561. /**
  91562. * Gets the class name of the current input.
  91563. * @returns the class name
  91564. */
  91565. getClassName(): string;
  91566. /**
  91567. * Get the friendly name associated with the input class.
  91568. * @returns the input friendly name
  91569. */
  91570. getSimpleName(): string;
  91571. /**
  91572. * Called on pointer POINTERDOUBLETAP event.
  91573. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91574. */
  91575. protected onDoubleTap(type: string): void;
  91576. /**
  91577. * Called on pointer POINTERMOVE event if only a single touch is active.
  91578. * Override this method to provide functionality.
  91579. */
  91580. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91581. /**
  91582. * Called on pointer POINTERMOVE event if multiple touches are active.
  91583. * Override this method to provide functionality.
  91584. */
  91585. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91586. /**
  91587. * Called on JS contextmenu event.
  91588. * Override this method to provide functionality.
  91589. */
  91590. protected onContextMenu(evt: PointerEvent): void;
  91591. /**
  91592. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91593. * press.
  91594. * Override this method to provide functionality.
  91595. */
  91596. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91597. /**
  91598. * Called each time a new POINTERUP event occurs. Ie, for each button
  91599. * release.
  91600. * Override this method to provide functionality.
  91601. */
  91602. protected onButtonUp(evt: PointerEvent): void;
  91603. /**
  91604. * Called when window becomes inactive.
  91605. * Override this method to provide functionality.
  91606. */
  91607. protected onLostFocus(): void;
  91608. private _pointerInput;
  91609. private _observer;
  91610. private _onLostFocus;
  91611. }
  91612. }
  91613. declare module BABYLON {
  91614. /**
  91615. * Manage the pointers inputs to control an arc rotate camera.
  91616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91617. */
  91618. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91619. /**
  91620. * Defines the camera the input is attached to.
  91621. */
  91622. camera: ArcRotateCamera;
  91623. /**
  91624. * Gets the class name of the current input.
  91625. * @returns the class name
  91626. */
  91627. getClassName(): string;
  91628. /**
  91629. * Defines the buttons associated with the input to handle camera move.
  91630. */
  91631. buttons: number[];
  91632. /**
  91633. * Defines the pointer angular sensibility along the X axis or how fast is
  91634. * the camera rotating.
  91635. */
  91636. angularSensibilityX: number;
  91637. /**
  91638. * Defines the pointer angular sensibility along the Y axis or how fast is
  91639. * the camera rotating.
  91640. */
  91641. angularSensibilityY: number;
  91642. /**
  91643. * Defines the pointer pinch precision or how fast is the camera zooming.
  91644. */
  91645. pinchPrecision: number;
  91646. /**
  91647. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91648. * from 0.
  91649. * It defines the percentage of current camera.radius to use as delta when
  91650. * pinch zoom is used.
  91651. */
  91652. pinchDeltaPercentage: number;
  91653. /**
  91654. * Defines the pointer panning sensibility or how fast is the camera moving.
  91655. */
  91656. panningSensibility: number;
  91657. /**
  91658. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91659. */
  91660. multiTouchPanning: boolean;
  91661. /**
  91662. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91663. * zoom (pinch) through multitouch.
  91664. */
  91665. multiTouchPanAndZoom: boolean;
  91666. /**
  91667. * Revers pinch action direction.
  91668. */
  91669. pinchInwards: boolean;
  91670. private _isPanClick;
  91671. private _twoFingerActivityCount;
  91672. private _isPinching;
  91673. /**
  91674. * Called on pointer POINTERMOVE event if only a single touch is active.
  91675. */
  91676. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91677. /**
  91678. * Called on pointer POINTERDOUBLETAP event.
  91679. */
  91680. protected onDoubleTap(type: string): void;
  91681. /**
  91682. * Called on pointer POINTERMOVE event if multiple touches are active.
  91683. */
  91684. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91685. /**
  91686. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91687. * press.
  91688. */
  91689. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91690. /**
  91691. * Called each time a new POINTERUP event occurs. Ie, for each button
  91692. * release.
  91693. */
  91694. protected onButtonUp(evt: PointerEvent): void;
  91695. /**
  91696. * Called when window becomes inactive.
  91697. */
  91698. protected onLostFocus(): void;
  91699. }
  91700. }
  91701. declare module BABYLON {
  91702. /**
  91703. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91705. */
  91706. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91707. /**
  91708. * Defines the camera the input is attached to.
  91709. */
  91710. camera: ArcRotateCamera;
  91711. /**
  91712. * Defines the list of key codes associated with the up action (increase alpha)
  91713. */
  91714. keysUp: number[];
  91715. /**
  91716. * Defines the list of key codes associated with the down action (decrease alpha)
  91717. */
  91718. keysDown: number[];
  91719. /**
  91720. * Defines the list of key codes associated with the left action (increase beta)
  91721. */
  91722. keysLeft: number[];
  91723. /**
  91724. * Defines the list of key codes associated with the right action (decrease beta)
  91725. */
  91726. keysRight: number[];
  91727. /**
  91728. * Defines the list of key codes associated with the reset action.
  91729. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91730. */
  91731. keysReset: number[];
  91732. /**
  91733. * Defines the panning sensibility of the inputs.
  91734. * (How fast is the camera paning)
  91735. */
  91736. panningSensibility: number;
  91737. /**
  91738. * Defines the zooming sensibility of the inputs.
  91739. * (How fast is the camera zooming)
  91740. */
  91741. zoomingSensibility: number;
  91742. /**
  91743. * Defines wether maintaining the alt key down switch the movement mode from
  91744. * orientation to zoom.
  91745. */
  91746. useAltToZoom: boolean;
  91747. /**
  91748. * Rotation speed of the camera
  91749. */
  91750. angularSpeed: number;
  91751. private _keys;
  91752. private _ctrlPressed;
  91753. private _altPressed;
  91754. private _onCanvasBlurObserver;
  91755. private _onKeyboardObserver;
  91756. private _engine;
  91757. private _scene;
  91758. /**
  91759. * Attach the input controls to a specific dom element to get the input from.
  91760. * @param element Defines the element the controls should be listened from
  91761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91762. */
  91763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91764. /**
  91765. * Detach the current controls from the specified dom element.
  91766. * @param element Defines the element to stop listening the inputs from
  91767. */
  91768. detachControl(element: Nullable<HTMLElement>): void;
  91769. /**
  91770. * Update the current camera state depending on the inputs that have been used this frame.
  91771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91772. */
  91773. checkInputs(): void;
  91774. /**
  91775. * Gets the class name of the current intput.
  91776. * @returns the class name
  91777. */
  91778. getClassName(): string;
  91779. /**
  91780. * Get the friendly name associated with the input class.
  91781. * @returns the input friendly name
  91782. */
  91783. getSimpleName(): string;
  91784. }
  91785. }
  91786. declare module BABYLON {
  91787. /**
  91788. * Manage the mouse wheel inputs to control an arc rotate camera.
  91789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91790. */
  91791. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91792. /**
  91793. * Defines the camera the input is attached to.
  91794. */
  91795. camera: ArcRotateCamera;
  91796. /**
  91797. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91798. */
  91799. wheelPrecision: number;
  91800. /**
  91801. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91802. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91803. */
  91804. wheelDeltaPercentage: number;
  91805. private _wheel;
  91806. private _observer;
  91807. /**
  91808. * Attach the input controls to a specific dom element to get the input from.
  91809. * @param element Defines the element the controls should be listened from
  91810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91811. */
  91812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91813. /**
  91814. * Detach the current controls from the specified dom element.
  91815. * @param element Defines the element to stop listening the inputs from
  91816. */
  91817. detachControl(element: Nullable<HTMLElement>): void;
  91818. /**
  91819. * Gets the class name of the current intput.
  91820. * @returns the class name
  91821. */
  91822. getClassName(): string;
  91823. /**
  91824. * Get the friendly name associated with the input class.
  91825. * @returns the input friendly name
  91826. */
  91827. getSimpleName(): string;
  91828. }
  91829. }
  91830. declare module BABYLON {
  91831. /**
  91832. * Default Inputs manager for the ArcRotateCamera.
  91833. * It groups all the default supported inputs for ease of use.
  91834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91835. */
  91836. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91837. /**
  91838. * Instantiates a new ArcRotateCameraInputsManager.
  91839. * @param camera Defines the camera the inputs belong to
  91840. */
  91841. constructor(camera: ArcRotateCamera);
  91842. /**
  91843. * Add mouse wheel input support to the input manager.
  91844. * @returns the current input manager
  91845. */
  91846. addMouseWheel(): ArcRotateCameraInputsManager;
  91847. /**
  91848. * Add pointers input support to the input manager.
  91849. * @returns the current input manager
  91850. */
  91851. addPointers(): ArcRotateCameraInputsManager;
  91852. /**
  91853. * Add keyboard input support to the input manager.
  91854. * @returns the current input manager
  91855. */
  91856. addKeyboard(): ArcRotateCameraInputsManager;
  91857. }
  91858. }
  91859. declare module BABYLON {
  91860. /**
  91861. * This represents an orbital type of camera.
  91862. *
  91863. * 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.
  91864. * 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.
  91865. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91866. */
  91867. export class ArcRotateCamera extends TargetCamera {
  91868. /**
  91869. * Defines the rotation angle of the camera along the longitudinal axis.
  91870. */
  91871. alpha: number;
  91872. /**
  91873. * Defines the rotation angle of the camera along the latitudinal axis.
  91874. */
  91875. beta: number;
  91876. /**
  91877. * Defines the radius of the camera from it s target point.
  91878. */
  91879. radius: number;
  91880. protected _target: Vector3;
  91881. protected _targetHost: Nullable<AbstractMesh>;
  91882. /**
  91883. * Defines the target point of the camera.
  91884. * The camera looks towards it form the radius distance.
  91885. */
  91886. target: Vector3;
  91887. /**
  91888. * Define the current local position of the camera in the scene
  91889. */
  91890. position: Vector3;
  91891. /**
  91892. * Current inertia value on the longitudinal axis.
  91893. * The bigger this number the longer it will take for the camera to stop.
  91894. */
  91895. inertialAlphaOffset: number;
  91896. /**
  91897. * Current inertia value on the latitudinal axis.
  91898. * The bigger this number the longer it will take for the camera to stop.
  91899. */
  91900. inertialBetaOffset: number;
  91901. /**
  91902. * Current inertia value on the radius axis.
  91903. * The bigger this number the longer it will take for the camera to stop.
  91904. */
  91905. inertialRadiusOffset: number;
  91906. /**
  91907. * Minimum allowed angle on the longitudinal axis.
  91908. * This can help limiting how the Camera is able to move in the scene.
  91909. */
  91910. lowerAlphaLimit: Nullable<number>;
  91911. /**
  91912. * Maximum allowed angle on the longitudinal axis.
  91913. * This can help limiting how the Camera is able to move in the scene.
  91914. */
  91915. upperAlphaLimit: Nullable<number>;
  91916. /**
  91917. * Minimum allowed angle on the latitudinal axis.
  91918. * This can help limiting how the Camera is able to move in the scene.
  91919. */
  91920. lowerBetaLimit: number;
  91921. /**
  91922. * Maximum allowed angle on the latitudinal axis.
  91923. * This can help limiting how the Camera is able to move in the scene.
  91924. */
  91925. upperBetaLimit: number;
  91926. /**
  91927. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91928. * This can help limiting how the Camera is able to move in the scene.
  91929. */
  91930. lowerRadiusLimit: Nullable<number>;
  91931. /**
  91932. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91933. * This can help limiting how the Camera is able to move in the scene.
  91934. */
  91935. upperRadiusLimit: Nullable<number>;
  91936. /**
  91937. * Defines the current inertia value used during panning of the camera along the X axis.
  91938. */
  91939. inertialPanningX: number;
  91940. /**
  91941. * Defines the current inertia value used during panning of the camera along the Y axis.
  91942. */
  91943. inertialPanningY: number;
  91944. /**
  91945. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91946. * Basically if your fingers moves away from more than this distance you will be considered
  91947. * in pinch mode.
  91948. */
  91949. pinchToPanMaxDistance: number;
  91950. /**
  91951. * Defines the maximum distance the camera can pan.
  91952. * This could help keeping the cammera always in your scene.
  91953. */
  91954. panningDistanceLimit: Nullable<number>;
  91955. /**
  91956. * Defines the target of the camera before paning.
  91957. */
  91958. panningOriginTarget: Vector3;
  91959. /**
  91960. * Defines the value of the inertia used during panning.
  91961. * 0 would mean stop inertia and one would mean no decelleration at all.
  91962. */
  91963. panningInertia: number;
  91964. /**
  91965. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91966. */
  91967. angularSensibilityX: number;
  91968. /**
  91969. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91970. */
  91971. angularSensibilityY: number;
  91972. /**
  91973. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91974. */
  91975. pinchPrecision: number;
  91976. /**
  91977. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91978. * It will be used instead of pinchDeltaPrecision if different from 0.
  91979. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91980. */
  91981. pinchDeltaPercentage: number;
  91982. /**
  91983. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91984. */
  91985. panningSensibility: number;
  91986. /**
  91987. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91988. */
  91989. keysUp: number[];
  91990. /**
  91991. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91992. */
  91993. keysDown: number[];
  91994. /**
  91995. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91996. */
  91997. keysLeft: number[];
  91998. /**
  91999. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  92000. */
  92001. keysRight: number[];
  92002. /**
  92003. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92004. */
  92005. wheelPrecision: number;
  92006. /**
  92007. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  92008. * It will be used instead of pinchDeltaPrecision if different from 0.
  92009. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92010. */
  92011. wheelDeltaPercentage: number;
  92012. /**
  92013. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  92014. */
  92015. zoomOnFactor: number;
  92016. /**
  92017. * Defines a screen offset for the camera position.
  92018. */
  92019. targetScreenOffset: Vector2;
  92020. /**
  92021. * Allows the camera to be completely reversed.
  92022. * If false the camera can not arrive upside down.
  92023. */
  92024. allowUpsideDown: boolean;
  92025. /**
  92026. * Define if double tap/click is used to restore the previously saved state of the camera.
  92027. */
  92028. useInputToRestoreState: boolean;
  92029. /** @hidden */
  92030. _viewMatrix: Matrix;
  92031. /** @hidden */
  92032. _useCtrlForPanning: boolean;
  92033. /** @hidden */
  92034. _panningMouseButton: number;
  92035. /**
  92036. * Defines the input associated to the camera.
  92037. */
  92038. inputs: ArcRotateCameraInputsManager;
  92039. /** @hidden */
  92040. _reset: () => void;
  92041. /**
  92042. * Defines the allowed panning axis.
  92043. */
  92044. panningAxis: Vector3;
  92045. protected _localDirection: Vector3;
  92046. protected _transformedDirection: Vector3;
  92047. private _bouncingBehavior;
  92048. /**
  92049. * Gets the bouncing behavior of the camera if it has been enabled.
  92050. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92051. */
  92052. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  92053. /**
  92054. * Defines if the bouncing behavior of the camera is enabled on the camera.
  92055. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92056. */
  92057. useBouncingBehavior: boolean;
  92058. private _framingBehavior;
  92059. /**
  92060. * Gets the framing behavior of the camera if it has been enabled.
  92061. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92062. */
  92063. readonly framingBehavior: Nullable<FramingBehavior>;
  92064. /**
  92065. * Defines if the framing behavior of the camera is enabled on the camera.
  92066. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92067. */
  92068. useFramingBehavior: boolean;
  92069. private _autoRotationBehavior;
  92070. /**
  92071. * Gets the auto rotation behavior of the camera if it has been enabled.
  92072. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92073. */
  92074. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  92075. /**
  92076. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  92077. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92078. */
  92079. useAutoRotationBehavior: boolean;
  92080. /**
  92081. * Observable triggered when the mesh target has been changed on the camera.
  92082. */
  92083. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  92084. /**
  92085. * Event raised when the camera is colliding with a mesh.
  92086. */
  92087. onCollide: (collidedMesh: AbstractMesh) => void;
  92088. /**
  92089. * Defines whether the camera should check collision with the objects oh the scene.
  92090. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  92091. */
  92092. checkCollisions: boolean;
  92093. /**
  92094. * Defines the collision radius of the camera.
  92095. * This simulates a sphere around the camera.
  92096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92097. */
  92098. collisionRadius: Vector3;
  92099. protected _collider: Collider;
  92100. protected _previousPosition: Vector3;
  92101. protected _collisionVelocity: Vector3;
  92102. protected _newPosition: Vector3;
  92103. protected _previousAlpha: number;
  92104. protected _previousBeta: number;
  92105. protected _previousRadius: number;
  92106. protected _collisionTriggered: boolean;
  92107. protected _targetBoundingCenter: Nullable<Vector3>;
  92108. private _computationVector;
  92109. private _tempAxisVector;
  92110. private _tempAxisRotationMatrix;
  92111. /**
  92112. * Instantiates a new ArcRotateCamera in a given scene
  92113. * @param name Defines the name of the camera
  92114. * @param alpha Defines the camera rotation along the logitudinal axis
  92115. * @param beta Defines the camera rotation along the latitudinal axis
  92116. * @param radius Defines the camera distance from its target
  92117. * @param target Defines the camera target
  92118. * @param scene Defines the scene the camera belongs to
  92119. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92120. */
  92121. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92122. /** @hidden */
  92123. _initCache(): void;
  92124. /** @hidden */
  92125. _updateCache(ignoreParentClass?: boolean): void;
  92126. protected _getTargetPosition(): Vector3;
  92127. private _storedAlpha;
  92128. private _storedBeta;
  92129. private _storedRadius;
  92130. private _storedTarget;
  92131. /**
  92132. * Stores the current state of the camera (alpha, beta, radius and target)
  92133. * @returns the camera itself
  92134. */
  92135. storeState(): Camera;
  92136. /**
  92137. * @hidden
  92138. * Restored camera state. You must call storeState() first
  92139. */
  92140. _restoreStateValues(): boolean;
  92141. /** @hidden */
  92142. _isSynchronizedViewMatrix(): boolean;
  92143. /**
  92144. * Attached controls to the current camera.
  92145. * @param element Defines the element the controls should be listened from
  92146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92147. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  92148. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  92149. */
  92150. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  92151. /**
  92152. * Detach the current controls from the camera.
  92153. * The camera will stop reacting to inputs.
  92154. * @param element Defines the element to stop listening the inputs from
  92155. */
  92156. detachControl(element: HTMLElement): void;
  92157. /** @hidden */
  92158. _checkInputs(): void;
  92159. protected _checkLimits(): void;
  92160. /**
  92161. * Rebuilds angles (alpha, beta) and radius from the give position and target
  92162. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  92163. */
  92164. rebuildAnglesAndRadius(updateView?: boolean): void;
  92165. /**
  92166. * Use a position to define the current camera related information like aplha, beta and radius
  92167. * @param position Defines the position to set the camera at
  92168. */
  92169. setPosition(position: Vector3): void;
  92170. /**
  92171. * Defines the target the camera should look at.
  92172. * This will automatically adapt alpha beta and radius to fit within the new target.
  92173. * @param target Defines the new target as a Vector or a mesh
  92174. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  92175. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  92176. */
  92177. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  92178. /** @hidden */
  92179. _getViewMatrix(): Matrix;
  92180. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  92181. /**
  92182. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  92183. * @param meshes Defines the mesh to zoom on
  92184. * @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)
  92185. */
  92186. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  92187. /**
  92188. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  92189. * The target will be changed but the radius
  92190. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  92191. * @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)
  92192. */
  92193. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  92194. min: Vector3;
  92195. max: Vector3;
  92196. distance: number;
  92197. }, doNotUpdateMaxZ?: boolean): void;
  92198. /**
  92199. * @override
  92200. * Override Camera.createRigCamera
  92201. */
  92202. createRigCamera(name: string, cameraIndex: number): Camera;
  92203. /**
  92204. * @hidden
  92205. * @override
  92206. * Override Camera._updateRigCameras
  92207. */
  92208. _updateRigCameras(): void;
  92209. /**
  92210. * Destroy the camera and release the current resources hold by it.
  92211. */
  92212. dispose(): void;
  92213. /**
  92214. * Gets the current object class name.
  92215. * @return the class name
  92216. */
  92217. getClassName(): string;
  92218. }
  92219. }
  92220. declare module BABYLON {
  92221. /**
  92222. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92223. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92224. */
  92225. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92226. /**
  92227. * Gets the name of the behavior.
  92228. */
  92229. readonly name: string;
  92230. private _zoomStopsAnimation;
  92231. private _idleRotationSpeed;
  92232. private _idleRotationWaitTime;
  92233. private _idleRotationSpinupTime;
  92234. /**
  92235. * Sets the flag that indicates if user zooming should stop animation.
  92236. */
  92237. /**
  92238. * Gets the flag that indicates if user zooming should stop animation.
  92239. */
  92240. zoomStopsAnimation: boolean;
  92241. /**
  92242. * Sets the default speed at which the camera rotates around the model.
  92243. */
  92244. /**
  92245. * Gets the default speed at which the camera rotates around the model.
  92246. */
  92247. idleRotationSpeed: number;
  92248. /**
  92249. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92250. */
  92251. /**
  92252. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92253. */
  92254. idleRotationWaitTime: number;
  92255. /**
  92256. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92257. */
  92258. /**
  92259. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92260. */
  92261. idleRotationSpinupTime: number;
  92262. /**
  92263. * Gets a value indicating if the camera is currently rotating because of this behavior
  92264. */
  92265. readonly rotationInProgress: boolean;
  92266. private _onPrePointerObservableObserver;
  92267. private _onAfterCheckInputsObserver;
  92268. private _attachedCamera;
  92269. private _isPointerDown;
  92270. private _lastFrameTime;
  92271. private _lastInteractionTime;
  92272. private _cameraRotationSpeed;
  92273. /**
  92274. * Initializes the behavior.
  92275. */
  92276. init(): void;
  92277. /**
  92278. * Attaches the behavior to its arc rotate camera.
  92279. * @param camera Defines the camera to attach the behavior to
  92280. */
  92281. attach(camera: ArcRotateCamera): void;
  92282. /**
  92283. * Detaches the behavior from its current arc rotate camera.
  92284. */
  92285. detach(): void;
  92286. /**
  92287. * Returns true if user is scrolling.
  92288. * @return true if user is scrolling.
  92289. */
  92290. private _userIsZooming;
  92291. private _lastFrameRadius;
  92292. private _shouldAnimationStopForInteraction;
  92293. /**
  92294. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92295. */
  92296. private _applyUserInteraction;
  92297. private _userIsMoving;
  92298. }
  92299. }
  92300. declare module BABYLON {
  92301. /**
  92302. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92303. */
  92304. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92305. private ui;
  92306. /**
  92307. * The name of the behavior
  92308. */
  92309. name: string;
  92310. /**
  92311. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92312. */
  92313. distanceAwayFromFace: number;
  92314. /**
  92315. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92316. */
  92317. distanceAwayFromBottomOfFace: number;
  92318. private _faceVectors;
  92319. private _target;
  92320. private _scene;
  92321. private _onRenderObserver;
  92322. private _tmpMatrix;
  92323. private _tmpVector;
  92324. /**
  92325. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92326. * @param ui The transform node that should be attched to the mesh
  92327. */
  92328. constructor(ui: TransformNode);
  92329. /**
  92330. * Initializes the behavior
  92331. */
  92332. init(): void;
  92333. private _closestFace;
  92334. private _zeroVector;
  92335. private _lookAtTmpMatrix;
  92336. private _lookAtToRef;
  92337. /**
  92338. * Attaches the AttachToBoxBehavior to the passed in mesh
  92339. * @param target The mesh that the specified node will be attached to
  92340. */
  92341. attach(target: Mesh): void;
  92342. /**
  92343. * Detaches the behavior from the mesh
  92344. */
  92345. detach(): void;
  92346. }
  92347. }
  92348. declare module BABYLON {
  92349. /**
  92350. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92351. */
  92352. export class FadeInOutBehavior implements Behavior<Mesh> {
  92353. /**
  92354. * Time in milliseconds to delay before fading in (Default: 0)
  92355. */
  92356. delay: number;
  92357. /**
  92358. * Time in milliseconds for the mesh to fade in (Default: 300)
  92359. */
  92360. fadeInTime: number;
  92361. private _millisecondsPerFrame;
  92362. private _hovered;
  92363. private _hoverValue;
  92364. private _ownerNode;
  92365. /**
  92366. * Instatiates the FadeInOutBehavior
  92367. */
  92368. constructor();
  92369. /**
  92370. * The name of the behavior
  92371. */
  92372. readonly name: string;
  92373. /**
  92374. * Initializes the behavior
  92375. */
  92376. init(): void;
  92377. /**
  92378. * Attaches the fade behavior on the passed in mesh
  92379. * @param ownerNode The mesh that will be faded in/out once attached
  92380. */
  92381. attach(ownerNode: Mesh): void;
  92382. /**
  92383. * Detaches the behavior from the mesh
  92384. */
  92385. detach(): void;
  92386. /**
  92387. * Triggers the mesh to begin fading in or out
  92388. * @param value if the object should fade in or out (true to fade in)
  92389. */
  92390. fadeIn(value: boolean): void;
  92391. private _update;
  92392. private _setAllVisibility;
  92393. }
  92394. }
  92395. declare module BABYLON {
  92396. /**
  92397. * Class containing a set of static utilities functions for managing Pivots
  92398. * @hidden
  92399. */
  92400. export class PivotTools {
  92401. private static _PivotCached;
  92402. private static _OldPivotPoint;
  92403. private static _PivotTranslation;
  92404. private static _PivotTmpVector;
  92405. /** @hidden */
  92406. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92407. /** @hidden */
  92408. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92409. }
  92410. }
  92411. declare module BABYLON {
  92412. /**
  92413. * Class containing static functions to help procedurally build meshes
  92414. */
  92415. export class PlaneBuilder {
  92416. /**
  92417. * Creates a plane mesh
  92418. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92419. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92420. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92424. * @param name defines the name of the mesh
  92425. * @param options defines the options used to create the mesh
  92426. * @param scene defines the hosting scene
  92427. * @returns the plane mesh
  92428. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92429. */
  92430. static CreatePlane(name: string, options: {
  92431. size?: number;
  92432. width?: number;
  92433. height?: number;
  92434. sideOrientation?: number;
  92435. frontUVs?: Vector4;
  92436. backUVs?: Vector4;
  92437. updatable?: boolean;
  92438. sourcePlane?: Plane;
  92439. }, scene: Scene): Mesh;
  92440. }
  92441. }
  92442. declare module BABYLON {
  92443. /**
  92444. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92445. */
  92446. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92447. private static _AnyMouseID;
  92448. private _attachedNode;
  92449. private _dragPlane;
  92450. private _scene;
  92451. private _pointerObserver;
  92452. private _beforeRenderObserver;
  92453. private static _planeScene;
  92454. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92455. /**
  92456. * 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)
  92457. */
  92458. maxDragAngle: number;
  92459. /**
  92460. * @hidden
  92461. */
  92462. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92463. /**
  92464. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92465. */
  92466. currentDraggingPointerID: number;
  92467. /**
  92468. * The last position where the pointer hit the drag plane in world space
  92469. */
  92470. lastDragPosition: Vector3;
  92471. /**
  92472. * If the behavior is currently in a dragging state
  92473. */
  92474. dragging: boolean;
  92475. /**
  92476. * 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)
  92477. */
  92478. dragDeltaRatio: number;
  92479. /**
  92480. * If the drag plane orientation should be updated during the dragging (Default: true)
  92481. */
  92482. updateDragPlane: boolean;
  92483. private _debugMode;
  92484. private _moving;
  92485. /**
  92486. * Fires each time the attached mesh is dragged with the pointer
  92487. * * delta between last drag position and current drag position in world space
  92488. * * dragDistance along the drag axis
  92489. * * dragPlaneNormal normal of the current drag plane used during the drag
  92490. * * dragPlanePoint in world space where the drag intersects the drag plane
  92491. */
  92492. onDragObservable: Observable<{
  92493. delta: Vector3;
  92494. dragPlanePoint: Vector3;
  92495. dragPlaneNormal: Vector3;
  92496. dragDistance: number;
  92497. pointerId: number;
  92498. }>;
  92499. /**
  92500. * Fires each time a drag begins (eg. mouse down on mesh)
  92501. */
  92502. onDragStartObservable: Observable<{
  92503. dragPlanePoint: Vector3;
  92504. pointerId: number;
  92505. }>;
  92506. /**
  92507. * Fires each time a drag ends (eg. mouse release after drag)
  92508. */
  92509. onDragEndObservable: Observable<{
  92510. dragPlanePoint: Vector3;
  92511. pointerId: number;
  92512. }>;
  92513. /**
  92514. * If the attached mesh should be moved when dragged
  92515. */
  92516. moveAttached: boolean;
  92517. /**
  92518. * If the drag behavior will react to drag events (Default: true)
  92519. */
  92520. enabled: boolean;
  92521. /**
  92522. * If camera controls should be detached during the drag
  92523. */
  92524. detachCameraControls: boolean;
  92525. /**
  92526. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92527. */
  92528. useObjectOrienationForDragging: boolean;
  92529. private _options;
  92530. /**
  92531. * Creates a pointer drag behavior that can be attached to a mesh
  92532. * @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)
  92533. */
  92534. constructor(options?: {
  92535. dragAxis?: Vector3;
  92536. dragPlaneNormal?: Vector3;
  92537. });
  92538. /**
  92539. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92540. */
  92541. validateDrag: (targetPosition: Vector3) => boolean;
  92542. /**
  92543. * The name of the behavior
  92544. */
  92545. readonly name: string;
  92546. /**
  92547. * Initializes the behavior
  92548. */
  92549. init(): void;
  92550. private _tmpVector;
  92551. private _alternatePickedPoint;
  92552. private _worldDragAxis;
  92553. private _targetPosition;
  92554. private _attachedElement;
  92555. /**
  92556. * Attaches the drag behavior the passed in mesh
  92557. * @param ownerNode The mesh that will be dragged around once attached
  92558. */
  92559. attach(ownerNode: AbstractMesh): void;
  92560. /**
  92561. * Force relase the drag action by code.
  92562. */
  92563. releaseDrag(): void;
  92564. private _startDragRay;
  92565. private _lastPointerRay;
  92566. /**
  92567. * Simulates the start of a pointer drag event on the behavior
  92568. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92569. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92570. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92571. */
  92572. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92573. private _startDrag;
  92574. private _dragDelta;
  92575. private _moveDrag;
  92576. private _pickWithRayOnDragPlane;
  92577. private _pointA;
  92578. private _pointB;
  92579. private _pointC;
  92580. private _lineA;
  92581. private _lineB;
  92582. private _localAxis;
  92583. private _lookAt;
  92584. private _updateDragPlanePosition;
  92585. /**
  92586. * Detaches the behavior from the mesh
  92587. */
  92588. detach(): void;
  92589. }
  92590. }
  92591. declare module BABYLON {
  92592. /**
  92593. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92594. */
  92595. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92596. private _dragBehaviorA;
  92597. private _dragBehaviorB;
  92598. private _startDistance;
  92599. private _initialScale;
  92600. private _targetScale;
  92601. private _ownerNode;
  92602. private _sceneRenderObserver;
  92603. /**
  92604. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92605. */
  92606. constructor();
  92607. /**
  92608. * The name of the behavior
  92609. */
  92610. readonly name: string;
  92611. /**
  92612. * Initializes the behavior
  92613. */
  92614. init(): void;
  92615. private _getCurrentDistance;
  92616. /**
  92617. * Attaches the scale behavior the passed in mesh
  92618. * @param ownerNode The mesh that will be scaled around once attached
  92619. */
  92620. attach(ownerNode: Mesh): void;
  92621. /**
  92622. * Detaches the behavior from the mesh
  92623. */
  92624. detach(): void;
  92625. }
  92626. }
  92627. declare module BABYLON {
  92628. /**
  92629. * 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
  92630. */
  92631. export class SixDofDragBehavior implements Behavior<Mesh> {
  92632. private static _virtualScene;
  92633. private _ownerNode;
  92634. private _sceneRenderObserver;
  92635. private _scene;
  92636. private _targetPosition;
  92637. private _virtualOriginMesh;
  92638. private _virtualDragMesh;
  92639. private _pointerObserver;
  92640. private _moving;
  92641. private _startingOrientation;
  92642. /**
  92643. * 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)
  92644. */
  92645. private zDragFactor;
  92646. /**
  92647. * If the object should rotate to face the drag origin
  92648. */
  92649. rotateDraggedObject: boolean;
  92650. /**
  92651. * If the behavior is currently in a dragging state
  92652. */
  92653. dragging: boolean;
  92654. /**
  92655. * 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)
  92656. */
  92657. dragDeltaRatio: number;
  92658. /**
  92659. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92660. */
  92661. currentDraggingPointerID: number;
  92662. /**
  92663. * If camera controls should be detached during the drag
  92664. */
  92665. detachCameraControls: boolean;
  92666. /**
  92667. * Fires each time a drag starts
  92668. */
  92669. onDragStartObservable: Observable<{}>;
  92670. /**
  92671. * Fires each time a drag ends (eg. mouse release after drag)
  92672. */
  92673. onDragEndObservable: Observable<{}>;
  92674. /**
  92675. * 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
  92676. */
  92677. constructor();
  92678. /**
  92679. * The name of the behavior
  92680. */
  92681. readonly name: string;
  92682. /**
  92683. * Initializes the behavior
  92684. */
  92685. init(): void;
  92686. /**
  92687. * Attaches the scale behavior the passed in mesh
  92688. * @param ownerNode The mesh that will be scaled around once attached
  92689. */
  92690. attach(ownerNode: Mesh): void;
  92691. /**
  92692. * Detaches the behavior from the mesh
  92693. */
  92694. detach(): void;
  92695. }
  92696. }
  92697. declare module BABYLON {
  92698. /**
  92699. * Class used to apply inverse kinematics to bones
  92700. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92701. */
  92702. export class BoneIKController {
  92703. private static _tmpVecs;
  92704. private static _tmpQuat;
  92705. private static _tmpMats;
  92706. /**
  92707. * Gets or sets the target mesh
  92708. */
  92709. targetMesh: AbstractMesh;
  92710. /** Gets or sets the mesh used as pole */
  92711. poleTargetMesh: AbstractMesh;
  92712. /**
  92713. * Gets or sets the bone used as pole
  92714. */
  92715. poleTargetBone: Nullable<Bone>;
  92716. /**
  92717. * Gets or sets the target position
  92718. */
  92719. targetPosition: Vector3;
  92720. /**
  92721. * Gets or sets the pole target position
  92722. */
  92723. poleTargetPosition: Vector3;
  92724. /**
  92725. * Gets or sets the pole target local offset
  92726. */
  92727. poleTargetLocalOffset: Vector3;
  92728. /**
  92729. * Gets or sets the pole angle
  92730. */
  92731. poleAngle: number;
  92732. /**
  92733. * Gets or sets the mesh associated with the controller
  92734. */
  92735. mesh: AbstractMesh;
  92736. /**
  92737. * 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)
  92738. */
  92739. slerpAmount: number;
  92740. private _bone1Quat;
  92741. private _bone1Mat;
  92742. private _bone2Ang;
  92743. private _bone1;
  92744. private _bone2;
  92745. private _bone1Length;
  92746. private _bone2Length;
  92747. private _maxAngle;
  92748. private _maxReach;
  92749. private _rightHandedSystem;
  92750. private _bendAxis;
  92751. private _slerping;
  92752. private _adjustRoll;
  92753. /**
  92754. * Gets or sets maximum allowed angle
  92755. */
  92756. maxAngle: number;
  92757. /**
  92758. * Creates a new BoneIKController
  92759. * @param mesh defines the mesh to control
  92760. * @param bone defines the bone to control
  92761. * @param options defines options to set up the controller
  92762. */
  92763. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92764. targetMesh?: AbstractMesh;
  92765. poleTargetMesh?: AbstractMesh;
  92766. poleTargetBone?: Bone;
  92767. poleTargetLocalOffset?: Vector3;
  92768. poleAngle?: number;
  92769. bendAxis?: Vector3;
  92770. maxAngle?: number;
  92771. slerpAmount?: number;
  92772. });
  92773. private _setMaxAngle;
  92774. /**
  92775. * Force the controller to update the bones
  92776. */
  92777. update(): void;
  92778. }
  92779. }
  92780. declare module BABYLON {
  92781. /**
  92782. * Class used to make a bone look toward a point in space
  92783. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92784. */
  92785. export class BoneLookController {
  92786. private static _tmpVecs;
  92787. private static _tmpQuat;
  92788. private static _tmpMats;
  92789. /**
  92790. * The target Vector3 that the bone will look at
  92791. */
  92792. target: Vector3;
  92793. /**
  92794. * The mesh that the bone is attached to
  92795. */
  92796. mesh: AbstractMesh;
  92797. /**
  92798. * The bone that will be looking to the target
  92799. */
  92800. bone: Bone;
  92801. /**
  92802. * The up axis of the coordinate system that is used when the bone is rotated
  92803. */
  92804. upAxis: Vector3;
  92805. /**
  92806. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92807. */
  92808. upAxisSpace: Space;
  92809. /**
  92810. * Used to make an adjustment to the yaw of the bone
  92811. */
  92812. adjustYaw: number;
  92813. /**
  92814. * Used to make an adjustment to the pitch of the bone
  92815. */
  92816. adjustPitch: number;
  92817. /**
  92818. * Used to make an adjustment to the roll of the bone
  92819. */
  92820. adjustRoll: number;
  92821. /**
  92822. * 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)
  92823. */
  92824. slerpAmount: number;
  92825. private _minYaw;
  92826. private _maxYaw;
  92827. private _minPitch;
  92828. private _maxPitch;
  92829. private _minYawSin;
  92830. private _minYawCos;
  92831. private _maxYawSin;
  92832. private _maxYawCos;
  92833. private _midYawConstraint;
  92834. private _minPitchTan;
  92835. private _maxPitchTan;
  92836. private _boneQuat;
  92837. private _slerping;
  92838. private _transformYawPitch;
  92839. private _transformYawPitchInv;
  92840. private _firstFrameSkipped;
  92841. private _yawRange;
  92842. private _fowardAxis;
  92843. /**
  92844. * Gets or sets the minimum yaw angle that the bone can look to
  92845. */
  92846. minYaw: number;
  92847. /**
  92848. * Gets or sets the maximum yaw angle that the bone can look to
  92849. */
  92850. maxYaw: number;
  92851. /**
  92852. * Gets or sets the minimum pitch angle that the bone can look to
  92853. */
  92854. minPitch: number;
  92855. /**
  92856. * Gets or sets the maximum pitch angle that the bone can look to
  92857. */
  92858. maxPitch: number;
  92859. /**
  92860. * Create a BoneLookController
  92861. * @param mesh the mesh that the bone belongs to
  92862. * @param bone the bone that will be looking to the target
  92863. * @param target the target Vector3 to look at
  92864. * @param options optional settings:
  92865. * * maxYaw: the maximum angle the bone will yaw to
  92866. * * minYaw: the minimum angle the bone will yaw to
  92867. * * maxPitch: the maximum angle the bone will pitch to
  92868. * * minPitch: the minimum angle the bone will yaw to
  92869. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92870. * * upAxis: the up axis of the coordinate system
  92871. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92872. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92873. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92874. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92875. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92876. * * adjustRoll: used to make an adjustment to the roll of the bone
  92877. **/
  92878. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92879. maxYaw?: number;
  92880. minYaw?: number;
  92881. maxPitch?: number;
  92882. minPitch?: number;
  92883. slerpAmount?: number;
  92884. upAxis?: Vector3;
  92885. upAxisSpace?: Space;
  92886. yawAxis?: Vector3;
  92887. pitchAxis?: Vector3;
  92888. adjustYaw?: number;
  92889. adjustPitch?: number;
  92890. adjustRoll?: number;
  92891. });
  92892. /**
  92893. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92894. */
  92895. update(): void;
  92896. private _getAngleDiff;
  92897. private _getAngleBetween;
  92898. private _isAngleBetween;
  92899. }
  92900. }
  92901. declare module BABYLON {
  92902. /**
  92903. * Manage the gamepad inputs to control an arc rotate camera.
  92904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92905. */
  92906. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92907. /**
  92908. * Defines the camera the input is attached to.
  92909. */
  92910. camera: ArcRotateCamera;
  92911. /**
  92912. * Defines the gamepad the input is gathering event from.
  92913. */
  92914. gamepad: Nullable<Gamepad>;
  92915. /**
  92916. * Defines the gamepad rotation sensiblity.
  92917. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92918. */
  92919. gamepadRotationSensibility: number;
  92920. /**
  92921. * Defines the gamepad move sensiblity.
  92922. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92923. */
  92924. gamepadMoveSensibility: number;
  92925. private _onGamepadConnectedObserver;
  92926. private _onGamepadDisconnectedObserver;
  92927. /**
  92928. * Attach the input controls to a specific dom element to get the input from.
  92929. * @param element Defines the element the controls should be listened from
  92930. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92931. */
  92932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92933. /**
  92934. * Detach the current controls from the specified dom element.
  92935. * @param element Defines the element to stop listening the inputs from
  92936. */
  92937. detachControl(element: Nullable<HTMLElement>): void;
  92938. /**
  92939. * Update the current camera state depending on the inputs that have been used this frame.
  92940. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92941. */
  92942. checkInputs(): void;
  92943. /**
  92944. * Gets the class name of the current intput.
  92945. * @returns the class name
  92946. */
  92947. getClassName(): string;
  92948. /**
  92949. * Get the friendly name associated with the input class.
  92950. * @returns the input friendly name
  92951. */
  92952. getSimpleName(): string;
  92953. }
  92954. }
  92955. declare module BABYLON {
  92956. interface ArcRotateCameraInputsManager {
  92957. /**
  92958. * Add orientation input support to the input manager.
  92959. * @returns the current input manager
  92960. */
  92961. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92962. }
  92963. /**
  92964. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92966. */
  92967. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92968. /**
  92969. * Defines the camera the input is attached to.
  92970. */
  92971. camera: ArcRotateCamera;
  92972. /**
  92973. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92974. */
  92975. alphaCorrection: number;
  92976. /**
  92977. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92978. */
  92979. gammaCorrection: number;
  92980. private _alpha;
  92981. private _gamma;
  92982. private _dirty;
  92983. private _deviceOrientationHandler;
  92984. /**
  92985. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92986. */
  92987. constructor();
  92988. /**
  92989. * Attach the input controls to a specific dom element to get the input from.
  92990. * @param element Defines the element the controls should be listened from
  92991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92992. */
  92993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92994. /** @hidden */
  92995. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92996. /**
  92997. * Update the current camera state depending on the inputs that have been used this frame.
  92998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92999. */
  93000. checkInputs(): void;
  93001. /**
  93002. * Detach the current controls from the specified dom element.
  93003. * @param element Defines the element to stop listening the inputs from
  93004. */
  93005. detachControl(element: Nullable<HTMLElement>): void;
  93006. /**
  93007. * Gets the class name of the current intput.
  93008. * @returns the class name
  93009. */
  93010. getClassName(): string;
  93011. /**
  93012. * Get the friendly name associated with the input class.
  93013. * @returns the input friendly name
  93014. */
  93015. getSimpleName(): string;
  93016. }
  93017. }
  93018. declare module BABYLON {
  93019. /**
  93020. * Listen to mouse events to control the camera.
  93021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93022. */
  93023. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  93024. /**
  93025. * Defines the camera the input is attached to.
  93026. */
  93027. camera: FlyCamera;
  93028. /**
  93029. * Defines if touch is enabled. (Default is true.)
  93030. */
  93031. touchEnabled: boolean;
  93032. /**
  93033. * Defines the buttons associated with the input to handle camera rotation.
  93034. */
  93035. buttons: number[];
  93036. /**
  93037. * Assign buttons for Yaw control.
  93038. */
  93039. buttonsYaw: number[];
  93040. /**
  93041. * Assign buttons for Pitch control.
  93042. */
  93043. buttonsPitch: number[];
  93044. /**
  93045. * Assign buttons for Roll control.
  93046. */
  93047. buttonsRoll: number[];
  93048. /**
  93049. * Detect if any button is being pressed while mouse is moved.
  93050. * -1 = Mouse locked.
  93051. * 0 = Left button.
  93052. * 1 = Middle Button.
  93053. * 2 = Right Button.
  93054. */
  93055. activeButton: number;
  93056. /**
  93057. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  93058. * Higher values reduce its sensitivity.
  93059. */
  93060. angularSensibility: number;
  93061. private _mousemoveCallback;
  93062. private _observer;
  93063. private _rollObserver;
  93064. private previousPosition;
  93065. private noPreventDefault;
  93066. private element;
  93067. /**
  93068. * Listen to mouse events to control the camera.
  93069. * @param touchEnabled Define if touch is enabled. (Default is true.)
  93070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93071. */
  93072. constructor(touchEnabled?: boolean);
  93073. /**
  93074. * Attach the mouse control to the HTML DOM element.
  93075. * @param element Defines the element that listens to the input events.
  93076. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  93077. */
  93078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93079. /**
  93080. * Detach the current controls from the specified dom element.
  93081. * @param element Defines the element to stop listening the inputs from
  93082. */
  93083. detachControl(element: Nullable<HTMLElement>): void;
  93084. /**
  93085. * Gets the class name of the current input.
  93086. * @returns the class name.
  93087. */
  93088. getClassName(): string;
  93089. /**
  93090. * Get the friendly name associated with the input class.
  93091. * @returns the input's friendly name.
  93092. */
  93093. getSimpleName(): string;
  93094. private _pointerInput;
  93095. private _onMouseMove;
  93096. /**
  93097. * Rotate camera by mouse offset.
  93098. */
  93099. private rotateCamera;
  93100. }
  93101. }
  93102. declare module BABYLON {
  93103. /**
  93104. * Default Inputs manager for the FlyCamera.
  93105. * It groups all the default supported inputs for ease of use.
  93106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93107. */
  93108. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  93109. /**
  93110. * Instantiates a new FlyCameraInputsManager.
  93111. * @param camera Defines the camera the inputs belong to.
  93112. */
  93113. constructor(camera: FlyCamera);
  93114. /**
  93115. * Add keyboard input support to the input manager.
  93116. * @returns the new FlyCameraKeyboardMoveInput().
  93117. */
  93118. addKeyboard(): FlyCameraInputsManager;
  93119. /**
  93120. * Add mouse input support to the input manager.
  93121. * @param touchEnabled Enable touch screen support.
  93122. * @returns the new FlyCameraMouseInput().
  93123. */
  93124. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  93125. }
  93126. }
  93127. declare module BABYLON {
  93128. /**
  93129. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93130. * such as in a 3D Space Shooter or a Flight Simulator.
  93131. */
  93132. export class FlyCamera extends TargetCamera {
  93133. /**
  93134. * Define the collision ellipsoid of the camera.
  93135. * This is helpful for simulating a camera body, like a player's body.
  93136. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93137. */
  93138. ellipsoid: Vector3;
  93139. /**
  93140. * Define an offset for the position of the ellipsoid around the camera.
  93141. * This can be helpful if the camera is attached away from the player's body center,
  93142. * such as at its head.
  93143. */
  93144. ellipsoidOffset: Vector3;
  93145. /**
  93146. * Enable or disable collisions of the camera with the rest of the scene objects.
  93147. */
  93148. checkCollisions: boolean;
  93149. /**
  93150. * Enable or disable gravity on the camera.
  93151. */
  93152. applyGravity: boolean;
  93153. /**
  93154. * Define the current direction the camera is moving to.
  93155. */
  93156. cameraDirection: Vector3;
  93157. /**
  93158. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  93159. * This overrides and empties cameraRotation.
  93160. */
  93161. rotationQuaternion: Quaternion;
  93162. /**
  93163. * Track Roll to maintain the wanted Rolling when looking around.
  93164. */
  93165. _trackRoll: number;
  93166. /**
  93167. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  93168. */
  93169. rollCorrect: number;
  93170. /**
  93171. * Mimic a banked turn, Rolling the camera when Yawing.
  93172. * It's recommended to use rollCorrect = 10 for faster banking correction.
  93173. */
  93174. bankedTurn: boolean;
  93175. /**
  93176. * Limit in radians for how much Roll banking will add. (Default: 90°)
  93177. */
  93178. bankedTurnLimit: number;
  93179. /**
  93180. * Value of 0 disables the banked Roll.
  93181. * Value of 1 is equal to the Yaw angle in radians.
  93182. */
  93183. bankedTurnMultiplier: number;
  93184. /**
  93185. * The inputs manager loads all the input sources, such as keyboard and mouse.
  93186. */
  93187. inputs: FlyCameraInputsManager;
  93188. /**
  93189. * Gets the input sensibility for mouse input.
  93190. * Higher values reduce sensitivity.
  93191. */
  93192. /**
  93193. * Sets the input sensibility for a mouse input.
  93194. * Higher values reduce sensitivity.
  93195. */
  93196. angularSensibility: number;
  93197. /**
  93198. * Get the keys for camera movement forward.
  93199. */
  93200. /**
  93201. * Set the keys for camera movement forward.
  93202. */
  93203. keysForward: number[];
  93204. /**
  93205. * Get the keys for camera movement backward.
  93206. */
  93207. keysBackward: number[];
  93208. /**
  93209. * Get the keys for camera movement up.
  93210. */
  93211. /**
  93212. * Set the keys for camera movement up.
  93213. */
  93214. keysUp: number[];
  93215. /**
  93216. * Get the keys for camera movement down.
  93217. */
  93218. /**
  93219. * Set the keys for camera movement down.
  93220. */
  93221. keysDown: number[];
  93222. /**
  93223. * Get the keys for camera movement left.
  93224. */
  93225. /**
  93226. * Set the keys for camera movement left.
  93227. */
  93228. keysLeft: number[];
  93229. /**
  93230. * Set the keys for camera movement right.
  93231. */
  93232. /**
  93233. * Set the keys for camera movement right.
  93234. */
  93235. keysRight: number[];
  93236. /**
  93237. * Event raised when the camera collides with a mesh in the scene.
  93238. */
  93239. onCollide: (collidedMesh: AbstractMesh) => void;
  93240. private _collider;
  93241. private _needMoveForGravity;
  93242. private _oldPosition;
  93243. private _diffPosition;
  93244. private _newPosition;
  93245. /** @hidden */
  93246. _localDirection: Vector3;
  93247. /** @hidden */
  93248. _transformedDirection: Vector3;
  93249. /**
  93250. * Instantiates a FlyCamera.
  93251. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93252. * such as in a 3D Space Shooter or a Flight Simulator.
  93253. * @param name Define the name of the camera in the scene.
  93254. * @param position Define the starting position of the camera in the scene.
  93255. * @param scene Define the scene the camera belongs to.
  93256. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93257. */
  93258. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93259. /**
  93260. * Attach a control to the HTML DOM element.
  93261. * @param element Defines the element that listens to the input events.
  93262. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93263. */
  93264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93265. /**
  93266. * Detach a control from the HTML DOM element.
  93267. * The camera will stop reacting to that input.
  93268. * @param element Defines the element that listens to the input events.
  93269. */
  93270. detachControl(element: HTMLElement): void;
  93271. private _collisionMask;
  93272. /**
  93273. * Get the mask that the camera ignores in collision events.
  93274. */
  93275. /**
  93276. * Set the mask that the camera ignores in collision events.
  93277. */
  93278. collisionMask: number;
  93279. /** @hidden */
  93280. _collideWithWorld(displacement: Vector3): void;
  93281. /** @hidden */
  93282. private _onCollisionPositionChange;
  93283. /** @hidden */
  93284. _checkInputs(): void;
  93285. /** @hidden */
  93286. _decideIfNeedsToMove(): boolean;
  93287. /** @hidden */
  93288. _updatePosition(): void;
  93289. /**
  93290. * Restore the Roll to its target value at the rate specified.
  93291. * @param rate - Higher means slower restoring.
  93292. * @hidden
  93293. */
  93294. restoreRoll(rate: number): void;
  93295. /**
  93296. * Destroy the camera and release the current resources held by it.
  93297. */
  93298. dispose(): void;
  93299. /**
  93300. * Get the current object class name.
  93301. * @returns the class name.
  93302. */
  93303. getClassName(): string;
  93304. }
  93305. }
  93306. declare module BABYLON {
  93307. /**
  93308. * Listen to keyboard events to control the camera.
  93309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93310. */
  93311. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93312. /**
  93313. * Defines the camera the input is attached to.
  93314. */
  93315. camera: FlyCamera;
  93316. /**
  93317. * The list of keyboard keys used to control the forward move of the camera.
  93318. */
  93319. keysForward: number[];
  93320. /**
  93321. * The list of keyboard keys used to control the backward move of the camera.
  93322. */
  93323. keysBackward: number[];
  93324. /**
  93325. * The list of keyboard keys used to control the forward move of the camera.
  93326. */
  93327. keysUp: number[];
  93328. /**
  93329. * The list of keyboard keys used to control the backward move of the camera.
  93330. */
  93331. keysDown: number[];
  93332. /**
  93333. * The list of keyboard keys used to control the right strafe move of the camera.
  93334. */
  93335. keysRight: number[];
  93336. /**
  93337. * The list of keyboard keys used to control the left strafe move of the camera.
  93338. */
  93339. keysLeft: number[];
  93340. private _keys;
  93341. private _onCanvasBlurObserver;
  93342. private _onKeyboardObserver;
  93343. private _engine;
  93344. private _scene;
  93345. /**
  93346. * Attach the input controls to a specific dom element to get the input from.
  93347. * @param element Defines the element the controls should be listened from
  93348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93349. */
  93350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93351. /**
  93352. * Detach the current controls from the specified dom element.
  93353. * @param element Defines the element to stop listening the inputs from
  93354. */
  93355. detachControl(element: Nullable<HTMLElement>): void;
  93356. /**
  93357. * Gets the class name of the current intput.
  93358. * @returns the class name
  93359. */
  93360. getClassName(): string;
  93361. /** @hidden */
  93362. _onLostFocus(e: FocusEvent): void;
  93363. /**
  93364. * Get the friendly name associated with the input class.
  93365. * @returns the input friendly name
  93366. */
  93367. getSimpleName(): string;
  93368. /**
  93369. * Update the current camera state depending on the inputs that have been used this frame.
  93370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93371. */
  93372. checkInputs(): void;
  93373. }
  93374. }
  93375. declare module BABYLON {
  93376. /**
  93377. * Manage the mouse wheel inputs to control a follow camera.
  93378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93379. */
  93380. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93381. /**
  93382. * Defines the camera the input is attached to.
  93383. */
  93384. camera: FollowCamera;
  93385. /**
  93386. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93387. */
  93388. axisControlRadius: boolean;
  93389. /**
  93390. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93391. */
  93392. axisControlHeight: boolean;
  93393. /**
  93394. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93395. */
  93396. axisControlRotation: boolean;
  93397. /**
  93398. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93399. * relation to mouseWheel events.
  93400. */
  93401. wheelPrecision: number;
  93402. /**
  93403. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93404. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93405. */
  93406. wheelDeltaPercentage: number;
  93407. private _wheel;
  93408. private _observer;
  93409. /**
  93410. * Attach the input controls to a specific dom element to get the input from.
  93411. * @param element Defines the element the controls should be listened from
  93412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93413. */
  93414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93415. /**
  93416. * Detach the current controls from the specified dom element.
  93417. * @param element Defines the element to stop listening the inputs from
  93418. */
  93419. detachControl(element: Nullable<HTMLElement>): void;
  93420. /**
  93421. * Gets the class name of the current intput.
  93422. * @returns the class name
  93423. */
  93424. getClassName(): string;
  93425. /**
  93426. * Get the friendly name associated with the input class.
  93427. * @returns the input friendly name
  93428. */
  93429. getSimpleName(): string;
  93430. }
  93431. }
  93432. declare module BABYLON {
  93433. /**
  93434. * Manage the pointers inputs to control an follow camera.
  93435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93436. */
  93437. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93438. /**
  93439. * Defines the camera the input is attached to.
  93440. */
  93441. camera: FollowCamera;
  93442. /**
  93443. * Gets the class name of the current input.
  93444. * @returns the class name
  93445. */
  93446. getClassName(): string;
  93447. /**
  93448. * Defines the pointer angular sensibility along the X axis or how fast is
  93449. * the camera rotating.
  93450. * A negative number will reverse the axis direction.
  93451. */
  93452. angularSensibilityX: number;
  93453. /**
  93454. * Defines the pointer angular sensibility along the Y axis or how fast is
  93455. * the camera rotating.
  93456. * A negative number will reverse the axis direction.
  93457. */
  93458. angularSensibilityY: number;
  93459. /**
  93460. * Defines the pointer pinch precision or how fast is the camera zooming.
  93461. * A negative number will reverse the axis direction.
  93462. */
  93463. pinchPrecision: number;
  93464. /**
  93465. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93466. * from 0.
  93467. * It defines the percentage of current camera.radius to use as delta when
  93468. * pinch zoom is used.
  93469. */
  93470. pinchDeltaPercentage: number;
  93471. /**
  93472. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93473. */
  93474. axisXControlRadius: boolean;
  93475. /**
  93476. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93477. */
  93478. axisXControlHeight: boolean;
  93479. /**
  93480. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93481. */
  93482. axisXControlRotation: boolean;
  93483. /**
  93484. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93485. */
  93486. axisYControlRadius: boolean;
  93487. /**
  93488. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93489. */
  93490. axisYControlHeight: boolean;
  93491. /**
  93492. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93493. */
  93494. axisYControlRotation: boolean;
  93495. /**
  93496. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93497. */
  93498. axisPinchControlRadius: boolean;
  93499. /**
  93500. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93501. */
  93502. axisPinchControlHeight: boolean;
  93503. /**
  93504. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93505. */
  93506. axisPinchControlRotation: boolean;
  93507. /**
  93508. * Log error messages if basic misconfiguration has occurred.
  93509. */
  93510. warningEnable: boolean;
  93511. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93512. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93513. private _warningCounter;
  93514. private _warning;
  93515. }
  93516. }
  93517. declare module BABYLON {
  93518. /**
  93519. * Default Inputs manager for the FollowCamera.
  93520. * It groups all the default supported inputs for ease of use.
  93521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93522. */
  93523. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93524. /**
  93525. * Instantiates a new FollowCameraInputsManager.
  93526. * @param camera Defines the camera the inputs belong to
  93527. */
  93528. constructor(camera: FollowCamera);
  93529. /**
  93530. * Add keyboard input support to the input manager.
  93531. * @returns the current input manager
  93532. */
  93533. addKeyboard(): FollowCameraInputsManager;
  93534. /**
  93535. * Add mouse wheel input support to the input manager.
  93536. * @returns the current input manager
  93537. */
  93538. addMouseWheel(): FollowCameraInputsManager;
  93539. /**
  93540. * Add pointers input support to the input manager.
  93541. * @returns the current input manager
  93542. */
  93543. addPointers(): FollowCameraInputsManager;
  93544. /**
  93545. * Add orientation input support to the input manager.
  93546. * @returns the current input manager
  93547. */
  93548. addVRDeviceOrientation(): FollowCameraInputsManager;
  93549. }
  93550. }
  93551. declare module BABYLON {
  93552. /**
  93553. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93554. * an arc rotate version arcFollowCamera are available.
  93555. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93556. */
  93557. export class FollowCamera extends TargetCamera {
  93558. /**
  93559. * Distance the follow camera should follow an object at
  93560. */
  93561. radius: number;
  93562. /**
  93563. * Minimum allowed distance of the camera to the axis of rotation
  93564. * (The camera can not get closer).
  93565. * This can help limiting how the Camera is able to move in the scene.
  93566. */
  93567. lowerRadiusLimit: Nullable<number>;
  93568. /**
  93569. * Maximum allowed distance of the camera to the axis of rotation
  93570. * (The camera can not get further).
  93571. * This can help limiting how the Camera is able to move in the scene.
  93572. */
  93573. upperRadiusLimit: Nullable<number>;
  93574. /**
  93575. * Define a rotation offset between the camera and the object it follows
  93576. */
  93577. rotationOffset: number;
  93578. /**
  93579. * Minimum allowed angle to camera position relative to target object.
  93580. * This can help limiting how the Camera is able to move in the scene.
  93581. */
  93582. lowerRotationOffsetLimit: Nullable<number>;
  93583. /**
  93584. * Maximum allowed angle to camera position relative to target object.
  93585. * This can help limiting how the Camera is able to move in the scene.
  93586. */
  93587. upperRotationOffsetLimit: Nullable<number>;
  93588. /**
  93589. * Define a height offset between the camera and the object it follows.
  93590. * It can help following an object from the top (like a car chaing a plane)
  93591. */
  93592. heightOffset: number;
  93593. /**
  93594. * Minimum allowed height of camera position relative to target object.
  93595. * This can help limiting how the Camera is able to move in the scene.
  93596. */
  93597. lowerHeightOffsetLimit: Nullable<number>;
  93598. /**
  93599. * Maximum allowed height of camera position relative to target object.
  93600. * This can help limiting how the Camera is able to move in the scene.
  93601. */
  93602. upperHeightOffsetLimit: Nullable<number>;
  93603. /**
  93604. * Define how fast the camera can accelerate to follow it s target.
  93605. */
  93606. cameraAcceleration: number;
  93607. /**
  93608. * Define the speed limit of the camera following an object.
  93609. */
  93610. maxCameraSpeed: number;
  93611. /**
  93612. * Define the target of the camera.
  93613. */
  93614. lockedTarget: Nullable<AbstractMesh>;
  93615. /**
  93616. * Defines the input associated with the camera.
  93617. */
  93618. inputs: FollowCameraInputsManager;
  93619. /**
  93620. * Instantiates the follow camera.
  93621. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93622. * @param name Define the name of the camera in the scene
  93623. * @param position Define the position of the camera
  93624. * @param scene Define the scene the camera belong to
  93625. * @param lockedTarget Define the target of the camera
  93626. */
  93627. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93628. private _follow;
  93629. /**
  93630. * Attached controls to the current camera.
  93631. * @param element Defines the element the controls should be listened from
  93632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93633. */
  93634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93635. /**
  93636. * Detach the current controls from the camera.
  93637. * The camera will stop reacting to inputs.
  93638. * @param element Defines the element to stop listening the inputs from
  93639. */
  93640. detachControl(element: HTMLElement): void;
  93641. /** @hidden */
  93642. _checkInputs(): void;
  93643. private _checkLimits;
  93644. /**
  93645. * Gets the camera class name.
  93646. * @returns the class name
  93647. */
  93648. getClassName(): string;
  93649. }
  93650. /**
  93651. * Arc Rotate version of the follow camera.
  93652. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93653. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93654. */
  93655. export class ArcFollowCamera extends TargetCamera {
  93656. /** The longitudinal angle of the camera */
  93657. alpha: number;
  93658. /** The latitudinal angle of the camera */
  93659. beta: number;
  93660. /** The radius of the camera from its target */
  93661. radius: number;
  93662. /** Define the camera target (the messh it should follow) */
  93663. target: Nullable<AbstractMesh>;
  93664. private _cartesianCoordinates;
  93665. /**
  93666. * Instantiates a new ArcFollowCamera
  93667. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93668. * @param name Define the name of the camera
  93669. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93670. * @param beta Define the rotation angle of the camera around the elevation axis
  93671. * @param radius Define the radius of the camera from its target point
  93672. * @param target Define the target of the camera
  93673. * @param scene Define the scene the camera belongs to
  93674. */
  93675. constructor(name: string,
  93676. /** The longitudinal angle of the camera */
  93677. alpha: number,
  93678. /** The latitudinal angle of the camera */
  93679. beta: number,
  93680. /** The radius of the camera from its target */
  93681. radius: number,
  93682. /** Define the camera target (the messh it should follow) */
  93683. target: Nullable<AbstractMesh>, scene: Scene);
  93684. private _follow;
  93685. /** @hidden */
  93686. _checkInputs(): void;
  93687. /**
  93688. * Returns the class name of the object.
  93689. * It is mostly used internally for serialization purposes.
  93690. */
  93691. getClassName(): string;
  93692. }
  93693. }
  93694. declare module BABYLON {
  93695. /**
  93696. * Manage the keyboard inputs to control the movement of a follow camera.
  93697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93698. */
  93699. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93700. /**
  93701. * Defines the camera the input is attached to.
  93702. */
  93703. camera: FollowCamera;
  93704. /**
  93705. * Defines the list of key codes associated with the up action (increase heightOffset)
  93706. */
  93707. keysHeightOffsetIncr: number[];
  93708. /**
  93709. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93710. */
  93711. keysHeightOffsetDecr: number[];
  93712. /**
  93713. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93714. */
  93715. keysHeightOffsetModifierAlt: boolean;
  93716. /**
  93717. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93718. */
  93719. keysHeightOffsetModifierCtrl: boolean;
  93720. /**
  93721. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93722. */
  93723. keysHeightOffsetModifierShift: boolean;
  93724. /**
  93725. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93726. */
  93727. keysRotationOffsetIncr: number[];
  93728. /**
  93729. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93730. */
  93731. keysRotationOffsetDecr: number[];
  93732. /**
  93733. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93734. */
  93735. keysRotationOffsetModifierAlt: boolean;
  93736. /**
  93737. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93738. */
  93739. keysRotationOffsetModifierCtrl: boolean;
  93740. /**
  93741. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93742. */
  93743. keysRotationOffsetModifierShift: boolean;
  93744. /**
  93745. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93746. */
  93747. keysRadiusIncr: number[];
  93748. /**
  93749. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93750. */
  93751. keysRadiusDecr: number[];
  93752. /**
  93753. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93754. */
  93755. keysRadiusModifierAlt: boolean;
  93756. /**
  93757. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93758. */
  93759. keysRadiusModifierCtrl: boolean;
  93760. /**
  93761. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93762. */
  93763. keysRadiusModifierShift: boolean;
  93764. /**
  93765. * Defines the rate of change of heightOffset.
  93766. */
  93767. heightSensibility: number;
  93768. /**
  93769. * Defines the rate of change of rotationOffset.
  93770. */
  93771. rotationSensibility: number;
  93772. /**
  93773. * Defines the rate of change of radius.
  93774. */
  93775. radiusSensibility: number;
  93776. private _keys;
  93777. private _ctrlPressed;
  93778. private _altPressed;
  93779. private _shiftPressed;
  93780. private _onCanvasBlurObserver;
  93781. private _onKeyboardObserver;
  93782. private _engine;
  93783. private _scene;
  93784. /**
  93785. * Attach the input controls to a specific dom element to get the input from.
  93786. * @param element Defines the element the controls should be listened from
  93787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93788. */
  93789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93790. /**
  93791. * Detach the current controls from the specified dom element.
  93792. * @param element Defines the element to stop listening the inputs from
  93793. */
  93794. detachControl(element: Nullable<HTMLElement>): void;
  93795. /**
  93796. * Update the current camera state depending on the inputs that have been used this frame.
  93797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93798. */
  93799. checkInputs(): void;
  93800. /**
  93801. * Gets the class name of the current input.
  93802. * @returns the class name
  93803. */
  93804. getClassName(): string;
  93805. /**
  93806. * Get the friendly name associated with the input class.
  93807. * @returns the input friendly name
  93808. */
  93809. getSimpleName(): string;
  93810. /**
  93811. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93812. * allow modification of the heightOffset value.
  93813. */
  93814. private _modifierHeightOffset;
  93815. /**
  93816. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93817. * allow modification of the rotationOffset value.
  93818. */
  93819. private _modifierRotationOffset;
  93820. /**
  93821. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93822. * allow modification of the radius value.
  93823. */
  93824. private _modifierRadius;
  93825. }
  93826. }
  93827. declare module BABYLON {
  93828. interface FreeCameraInputsManager {
  93829. /**
  93830. * Add orientation input support to the input manager.
  93831. * @returns the current input manager
  93832. */
  93833. addDeviceOrientation(): FreeCameraInputsManager;
  93834. }
  93835. /**
  93836. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93837. * Screen rotation is taken into account.
  93838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93839. */
  93840. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93841. private _camera;
  93842. private _screenOrientationAngle;
  93843. private _constantTranform;
  93844. private _screenQuaternion;
  93845. private _alpha;
  93846. private _beta;
  93847. private _gamma;
  93848. /**
  93849. * Instantiates a new input
  93850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93851. */
  93852. constructor();
  93853. /**
  93854. * Define the camera controlled by the input.
  93855. */
  93856. camera: FreeCamera;
  93857. /**
  93858. * Attach the input controls to a specific dom element to get the input from.
  93859. * @param element Defines the element the controls should be listened from
  93860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93861. */
  93862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93863. private _orientationChanged;
  93864. private _deviceOrientation;
  93865. /**
  93866. * Detach the current controls from the specified dom element.
  93867. * @param element Defines the element to stop listening the inputs from
  93868. */
  93869. detachControl(element: Nullable<HTMLElement>): void;
  93870. /**
  93871. * Update the current camera state depending on the inputs that have been used this frame.
  93872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93873. */
  93874. checkInputs(): void;
  93875. /**
  93876. * Gets the class name of the current intput.
  93877. * @returns the class name
  93878. */
  93879. getClassName(): string;
  93880. /**
  93881. * Get the friendly name associated with the input class.
  93882. * @returns the input friendly name
  93883. */
  93884. getSimpleName(): string;
  93885. }
  93886. }
  93887. declare module BABYLON {
  93888. /**
  93889. * Manage the gamepad inputs to control a free camera.
  93890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93891. */
  93892. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93893. /**
  93894. * Define the camera the input is attached to.
  93895. */
  93896. camera: FreeCamera;
  93897. /**
  93898. * Define the Gamepad controlling the input
  93899. */
  93900. gamepad: Nullable<Gamepad>;
  93901. /**
  93902. * Defines the gamepad rotation sensiblity.
  93903. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93904. */
  93905. gamepadAngularSensibility: number;
  93906. /**
  93907. * Defines the gamepad move sensiblity.
  93908. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93909. */
  93910. gamepadMoveSensibility: number;
  93911. private _onGamepadConnectedObserver;
  93912. private _onGamepadDisconnectedObserver;
  93913. private _cameraTransform;
  93914. private _deltaTransform;
  93915. private _vector3;
  93916. private _vector2;
  93917. /**
  93918. * Attach the input controls to a specific dom element to get the input from.
  93919. * @param element Defines the element the controls should be listened from
  93920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93921. */
  93922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93923. /**
  93924. * Detach the current controls from the specified dom element.
  93925. * @param element Defines the element to stop listening the inputs from
  93926. */
  93927. detachControl(element: Nullable<HTMLElement>): void;
  93928. /**
  93929. * Update the current camera state depending on the inputs that have been used this frame.
  93930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93931. */
  93932. checkInputs(): void;
  93933. /**
  93934. * Gets the class name of the current intput.
  93935. * @returns the class name
  93936. */
  93937. getClassName(): string;
  93938. /**
  93939. * Get the friendly name associated with the input class.
  93940. * @returns the input friendly name
  93941. */
  93942. getSimpleName(): string;
  93943. }
  93944. }
  93945. declare module BABYLON {
  93946. /**
  93947. * Defines the potential axis of a Joystick
  93948. */
  93949. export enum JoystickAxis {
  93950. /** X axis */
  93951. X = 0,
  93952. /** Y axis */
  93953. Y = 1,
  93954. /** Z axis */
  93955. Z = 2
  93956. }
  93957. /**
  93958. * Class used to define virtual joystick (used in touch mode)
  93959. */
  93960. export class VirtualJoystick {
  93961. /**
  93962. * Gets or sets a boolean indicating that left and right values must be inverted
  93963. */
  93964. reverseLeftRight: boolean;
  93965. /**
  93966. * Gets or sets a boolean indicating that up and down values must be inverted
  93967. */
  93968. reverseUpDown: boolean;
  93969. /**
  93970. * Gets the offset value for the position (ie. the change of the position value)
  93971. */
  93972. deltaPosition: Vector3;
  93973. /**
  93974. * Gets a boolean indicating if the virtual joystick was pressed
  93975. */
  93976. pressed: boolean;
  93977. /**
  93978. * Canvas the virtual joystick will render onto, default z-index of this is 5
  93979. */
  93980. static Canvas: Nullable<HTMLCanvasElement>;
  93981. private static _globalJoystickIndex;
  93982. private static vjCanvasContext;
  93983. private static vjCanvasWidth;
  93984. private static vjCanvasHeight;
  93985. private static halfWidth;
  93986. private _action;
  93987. private _axisTargetedByLeftAndRight;
  93988. private _axisTargetedByUpAndDown;
  93989. private _joystickSensibility;
  93990. private _inversedSensibility;
  93991. private _joystickPointerID;
  93992. private _joystickColor;
  93993. private _joystickPointerPos;
  93994. private _joystickPreviousPointerPos;
  93995. private _joystickPointerStartPos;
  93996. private _deltaJoystickVector;
  93997. private _leftJoystick;
  93998. private _touches;
  93999. private _onPointerDownHandlerRef;
  94000. private _onPointerMoveHandlerRef;
  94001. private _onPointerUpHandlerRef;
  94002. private _onResize;
  94003. /**
  94004. * Creates a new virtual joystick
  94005. * @param leftJoystick defines that the joystick is for left hand (false by default)
  94006. */
  94007. constructor(leftJoystick?: boolean);
  94008. /**
  94009. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  94010. * @param newJoystickSensibility defines the new sensibility
  94011. */
  94012. setJoystickSensibility(newJoystickSensibility: number): void;
  94013. private _onPointerDown;
  94014. private _onPointerMove;
  94015. private _onPointerUp;
  94016. /**
  94017. * Change the color of the virtual joystick
  94018. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  94019. */
  94020. setJoystickColor(newColor: string): void;
  94021. /**
  94022. * Defines a callback to call when the joystick is touched
  94023. * @param action defines the callback
  94024. */
  94025. setActionOnTouch(action: () => any): void;
  94026. /**
  94027. * Defines which axis you'd like to control for left & right
  94028. * @param axis defines the axis to use
  94029. */
  94030. setAxisForLeftRight(axis: JoystickAxis): void;
  94031. /**
  94032. * Defines which axis you'd like to control for up & down
  94033. * @param axis defines the axis to use
  94034. */
  94035. setAxisForUpDown(axis: JoystickAxis): void;
  94036. private _drawVirtualJoystick;
  94037. /**
  94038. * Release internal HTML canvas
  94039. */
  94040. releaseCanvas(): void;
  94041. }
  94042. }
  94043. declare module BABYLON {
  94044. interface FreeCameraInputsManager {
  94045. /**
  94046. * Add virtual joystick input support to the input manager.
  94047. * @returns the current input manager
  94048. */
  94049. addVirtualJoystick(): FreeCameraInputsManager;
  94050. }
  94051. /**
  94052. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  94053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94054. */
  94055. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  94056. /**
  94057. * Defines the camera the input is attached to.
  94058. */
  94059. camera: FreeCamera;
  94060. private _leftjoystick;
  94061. private _rightjoystick;
  94062. /**
  94063. * Gets the left stick of the virtual joystick.
  94064. * @returns The virtual Joystick
  94065. */
  94066. getLeftJoystick(): VirtualJoystick;
  94067. /**
  94068. * Gets the right stick of the virtual joystick.
  94069. * @returns The virtual Joystick
  94070. */
  94071. getRightJoystick(): VirtualJoystick;
  94072. /**
  94073. * Update the current camera state depending on the inputs that have been used this frame.
  94074. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94075. */
  94076. checkInputs(): void;
  94077. /**
  94078. * Attach the input controls to a specific dom element to get the input from.
  94079. * @param element Defines the element the controls should be listened from
  94080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94081. */
  94082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94083. /**
  94084. * Detach the current controls from the specified dom element.
  94085. * @param element Defines the element to stop listening the inputs from
  94086. */
  94087. detachControl(element: Nullable<HTMLElement>): void;
  94088. /**
  94089. * Gets the class name of the current intput.
  94090. * @returns the class name
  94091. */
  94092. getClassName(): string;
  94093. /**
  94094. * Get the friendly name associated with the input class.
  94095. * @returns the input friendly name
  94096. */
  94097. getSimpleName(): string;
  94098. }
  94099. }
  94100. declare module BABYLON {
  94101. /**
  94102. * This represents a FPS type of camera controlled by touch.
  94103. * This is like a universal camera minus the Gamepad controls.
  94104. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94105. */
  94106. export class TouchCamera extends FreeCamera {
  94107. /**
  94108. * Defines the touch sensibility for rotation.
  94109. * The higher the faster.
  94110. */
  94111. touchAngularSensibility: number;
  94112. /**
  94113. * Defines the touch sensibility for move.
  94114. * The higher the faster.
  94115. */
  94116. touchMoveSensibility: number;
  94117. /**
  94118. * Instantiates a new touch camera.
  94119. * This represents a FPS type of camera controlled by touch.
  94120. * This is like a universal camera minus the Gamepad controls.
  94121. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94122. * @param name Define the name of the camera in the scene
  94123. * @param position Define the start position of the camera in the scene
  94124. * @param scene Define the scene the camera belongs to
  94125. */
  94126. constructor(name: string, position: Vector3, scene: Scene);
  94127. /**
  94128. * Gets the current object class name.
  94129. * @return the class name
  94130. */
  94131. getClassName(): string;
  94132. /** @hidden */
  94133. _setupInputs(): void;
  94134. }
  94135. }
  94136. declare module BABYLON {
  94137. /**
  94138. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  94139. * being tilted forward or back and left or right.
  94140. */
  94141. export class DeviceOrientationCamera extends FreeCamera {
  94142. private _initialQuaternion;
  94143. private _quaternionCache;
  94144. /**
  94145. * Creates a new device orientation camera
  94146. * @param name The name of the camera
  94147. * @param position The start position camera
  94148. * @param scene The scene the camera belongs to
  94149. */
  94150. constructor(name: string, position: Vector3, scene: Scene);
  94151. /**
  94152. * Gets the current instance class name ("DeviceOrientationCamera").
  94153. * This helps avoiding instanceof at run time.
  94154. * @returns the class name
  94155. */
  94156. getClassName(): string;
  94157. /**
  94158. * @hidden
  94159. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  94160. */
  94161. _checkInputs(): void;
  94162. /**
  94163. * Reset the camera to its default orientation on the specified axis only.
  94164. * @param axis The axis to reset
  94165. */
  94166. resetToCurrentRotation(axis?: Axis): void;
  94167. }
  94168. }
  94169. declare module BABYLON {
  94170. /**
  94171. * 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,
  94172. * which still works and will still be found in many Playgrounds.
  94173. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94174. */
  94175. export class UniversalCamera extends TouchCamera {
  94176. /**
  94177. * Defines the gamepad rotation sensiblity.
  94178. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94179. */
  94180. gamepadAngularSensibility: number;
  94181. /**
  94182. * Defines the gamepad move sensiblity.
  94183. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94184. */
  94185. gamepadMoveSensibility: number;
  94186. /**
  94187. * 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,
  94188. * which still works and will still be found in many Playgrounds.
  94189. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94190. * @param name Define the name of the camera in the scene
  94191. * @param position Define the start position of the camera in the scene
  94192. * @param scene Define the scene the camera belongs to
  94193. */
  94194. constructor(name: string, position: Vector3, scene: Scene);
  94195. /**
  94196. * Gets the current object class name.
  94197. * @return the class name
  94198. */
  94199. getClassName(): string;
  94200. }
  94201. }
  94202. declare module BABYLON {
  94203. /**
  94204. * This represents a FPS type of camera. This is only here for back compat purpose.
  94205. * Please use the UniversalCamera instead as both are identical.
  94206. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94207. */
  94208. export class GamepadCamera extends UniversalCamera {
  94209. /**
  94210. * Instantiates a new Gamepad Camera
  94211. * This represents a FPS type of camera. This is only here for back compat purpose.
  94212. * Please use the UniversalCamera instead as both are identical.
  94213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94214. * @param name Define the name of the camera in the scene
  94215. * @param position Define the start position of the camera in the scene
  94216. * @param scene Define the scene the camera belongs to
  94217. */
  94218. constructor(name: string, position: Vector3, scene: Scene);
  94219. /**
  94220. * Gets the current object class name.
  94221. * @return the class name
  94222. */
  94223. getClassName(): string;
  94224. }
  94225. }
  94226. declare module BABYLON {
  94227. /** @hidden */
  94228. export var passPixelShader: {
  94229. name: string;
  94230. shader: string;
  94231. };
  94232. }
  94233. declare module BABYLON {
  94234. /** @hidden */
  94235. export var passCubePixelShader: {
  94236. name: string;
  94237. shader: string;
  94238. };
  94239. }
  94240. declare module BABYLON {
  94241. /**
  94242. * PassPostProcess which produces an output the same as it's input
  94243. */
  94244. export class PassPostProcess extends PostProcess {
  94245. /**
  94246. * Creates the PassPostProcess
  94247. * @param name The name of the effect.
  94248. * @param options The required width/height ratio to downsize to before computing the render pass.
  94249. * @param camera The camera to apply the render pass to.
  94250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94251. * @param engine The engine which the post process will be applied. (default: current engine)
  94252. * @param reusable If the post process can be reused on the same frame. (default: false)
  94253. * @param textureType The type of texture to be used when performing the post processing.
  94254. * @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)
  94255. */
  94256. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94257. }
  94258. /**
  94259. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94260. */
  94261. export class PassCubePostProcess extends PostProcess {
  94262. private _face;
  94263. /**
  94264. * Gets or sets the cube face to display.
  94265. * * 0 is +X
  94266. * * 1 is -X
  94267. * * 2 is +Y
  94268. * * 3 is -Y
  94269. * * 4 is +Z
  94270. * * 5 is -Z
  94271. */
  94272. face: number;
  94273. /**
  94274. * Creates the PassCubePostProcess
  94275. * @param name The name of the effect.
  94276. * @param options The required width/height ratio to downsize to before computing the render pass.
  94277. * @param camera The camera to apply the render pass to.
  94278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94279. * @param engine The engine which the post process will be applied. (default: current engine)
  94280. * @param reusable If the post process can be reused on the same frame. (default: false)
  94281. * @param textureType The type of texture to be used when performing the post processing.
  94282. * @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)
  94283. */
  94284. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94285. }
  94286. }
  94287. declare module BABYLON {
  94288. /** @hidden */
  94289. export var anaglyphPixelShader: {
  94290. name: string;
  94291. shader: string;
  94292. };
  94293. }
  94294. declare module BABYLON {
  94295. /**
  94296. * Postprocess used to generate anaglyphic rendering
  94297. */
  94298. export class AnaglyphPostProcess extends PostProcess {
  94299. private _passedProcess;
  94300. /**
  94301. * Creates a new AnaglyphPostProcess
  94302. * @param name defines postprocess name
  94303. * @param options defines creation options or target ratio scale
  94304. * @param rigCameras defines cameras using this postprocess
  94305. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94306. * @param engine defines hosting engine
  94307. * @param reusable defines if the postprocess will be reused multiple times per frame
  94308. */
  94309. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94310. }
  94311. }
  94312. declare module BABYLON {
  94313. /**
  94314. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94315. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94316. */
  94317. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94318. /**
  94319. * Creates a new AnaglyphArcRotateCamera
  94320. * @param name defines camera name
  94321. * @param alpha defines alpha angle (in radians)
  94322. * @param beta defines beta angle (in radians)
  94323. * @param radius defines radius
  94324. * @param target defines camera target
  94325. * @param interaxialDistance defines distance between each color axis
  94326. * @param scene defines the hosting scene
  94327. */
  94328. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94329. /**
  94330. * Gets camera class name
  94331. * @returns AnaglyphArcRotateCamera
  94332. */
  94333. getClassName(): string;
  94334. }
  94335. }
  94336. declare module BABYLON {
  94337. /**
  94338. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94339. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94340. */
  94341. export class AnaglyphFreeCamera extends FreeCamera {
  94342. /**
  94343. * Creates a new AnaglyphFreeCamera
  94344. * @param name defines camera name
  94345. * @param position defines initial position
  94346. * @param interaxialDistance defines distance between each color axis
  94347. * @param scene defines the hosting scene
  94348. */
  94349. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94350. /**
  94351. * Gets camera class name
  94352. * @returns AnaglyphFreeCamera
  94353. */
  94354. getClassName(): string;
  94355. }
  94356. }
  94357. declare module BABYLON {
  94358. /**
  94359. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94360. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94361. */
  94362. export class AnaglyphGamepadCamera extends GamepadCamera {
  94363. /**
  94364. * Creates a new AnaglyphGamepadCamera
  94365. * @param name defines camera name
  94366. * @param position defines initial position
  94367. * @param interaxialDistance defines distance between each color axis
  94368. * @param scene defines the hosting scene
  94369. */
  94370. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94371. /**
  94372. * Gets camera class name
  94373. * @returns AnaglyphGamepadCamera
  94374. */
  94375. getClassName(): string;
  94376. }
  94377. }
  94378. declare module BABYLON {
  94379. /**
  94380. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94381. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94382. */
  94383. export class AnaglyphUniversalCamera extends UniversalCamera {
  94384. /**
  94385. * Creates a new AnaglyphUniversalCamera
  94386. * @param name defines camera name
  94387. * @param position defines initial position
  94388. * @param interaxialDistance defines distance between each color axis
  94389. * @param scene defines the hosting scene
  94390. */
  94391. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94392. /**
  94393. * Gets camera class name
  94394. * @returns AnaglyphUniversalCamera
  94395. */
  94396. getClassName(): string;
  94397. }
  94398. }
  94399. declare module BABYLON {
  94400. /** @hidden */
  94401. export var stereoscopicInterlacePixelShader: {
  94402. name: string;
  94403. shader: string;
  94404. };
  94405. }
  94406. declare module BABYLON {
  94407. /**
  94408. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94409. */
  94410. export class StereoscopicInterlacePostProcess extends PostProcess {
  94411. private _stepSize;
  94412. private _passedProcess;
  94413. /**
  94414. * Initializes a StereoscopicInterlacePostProcess
  94415. * @param name The name of the effect.
  94416. * @param rigCameras The rig cameras to be appled to the post process
  94417. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94419. * @param engine The engine which the post process will be applied. (default: current engine)
  94420. * @param reusable If the post process can be reused on the same frame. (default: false)
  94421. */
  94422. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94423. }
  94424. }
  94425. declare module BABYLON {
  94426. /**
  94427. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94428. * @see http://doc.babylonjs.com/features/cameras
  94429. */
  94430. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94431. /**
  94432. * Creates a new StereoscopicArcRotateCamera
  94433. * @param name defines camera name
  94434. * @param alpha defines alpha angle (in radians)
  94435. * @param beta defines beta angle (in radians)
  94436. * @param radius defines radius
  94437. * @param target defines camera target
  94438. * @param interaxialDistance defines distance between each color axis
  94439. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94440. * @param scene defines the hosting scene
  94441. */
  94442. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94443. /**
  94444. * Gets camera class name
  94445. * @returns StereoscopicArcRotateCamera
  94446. */
  94447. getClassName(): string;
  94448. }
  94449. }
  94450. declare module BABYLON {
  94451. /**
  94452. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94453. * @see http://doc.babylonjs.com/features/cameras
  94454. */
  94455. export class StereoscopicFreeCamera extends FreeCamera {
  94456. /**
  94457. * Creates a new StereoscopicFreeCamera
  94458. * @param name defines camera name
  94459. * @param position defines initial position
  94460. * @param interaxialDistance defines distance between each color axis
  94461. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94462. * @param scene defines the hosting scene
  94463. */
  94464. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94465. /**
  94466. * Gets camera class name
  94467. * @returns StereoscopicFreeCamera
  94468. */
  94469. getClassName(): string;
  94470. }
  94471. }
  94472. declare module BABYLON {
  94473. /**
  94474. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94475. * @see http://doc.babylonjs.com/features/cameras
  94476. */
  94477. export class StereoscopicGamepadCamera extends GamepadCamera {
  94478. /**
  94479. * Creates a new StereoscopicGamepadCamera
  94480. * @param name defines camera name
  94481. * @param position defines initial position
  94482. * @param interaxialDistance defines distance between each color axis
  94483. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94484. * @param scene defines the hosting scene
  94485. */
  94486. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94487. /**
  94488. * Gets camera class name
  94489. * @returns StereoscopicGamepadCamera
  94490. */
  94491. getClassName(): string;
  94492. }
  94493. }
  94494. declare module BABYLON {
  94495. /**
  94496. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94497. * @see http://doc.babylonjs.com/features/cameras
  94498. */
  94499. export class StereoscopicUniversalCamera extends UniversalCamera {
  94500. /**
  94501. * Creates a new StereoscopicUniversalCamera
  94502. * @param name defines camera name
  94503. * @param position defines initial position
  94504. * @param interaxialDistance defines distance between each color axis
  94505. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94506. * @param scene defines the hosting scene
  94507. */
  94508. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94509. /**
  94510. * Gets camera class name
  94511. * @returns StereoscopicUniversalCamera
  94512. */
  94513. getClassName(): string;
  94514. }
  94515. }
  94516. declare module BABYLON {
  94517. /**
  94518. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94519. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94520. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94521. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94522. */
  94523. export class VirtualJoysticksCamera extends FreeCamera {
  94524. /**
  94525. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94526. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94527. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94528. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94529. * @param name Define the name of the camera in the scene
  94530. * @param position Define the start position of the camera in the scene
  94531. * @param scene Define the scene the camera belongs to
  94532. */
  94533. constructor(name: string, position: Vector3, scene: Scene);
  94534. /**
  94535. * Gets the current object class name.
  94536. * @return the class name
  94537. */
  94538. getClassName(): string;
  94539. }
  94540. }
  94541. declare module BABYLON {
  94542. /**
  94543. * This represents all the required metrics to create a VR camera.
  94544. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94545. */
  94546. export class VRCameraMetrics {
  94547. /**
  94548. * Define the horizontal resolution off the screen.
  94549. */
  94550. hResolution: number;
  94551. /**
  94552. * Define the vertical resolution off the screen.
  94553. */
  94554. vResolution: number;
  94555. /**
  94556. * Define the horizontal screen size.
  94557. */
  94558. hScreenSize: number;
  94559. /**
  94560. * Define the vertical screen size.
  94561. */
  94562. vScreenSize: number;
  94563. /**
  94564. * Define the vertical screen center position.
  94565. */
  94566. vScreenCenter: number;
  94567. /**
  94568. * Define the distance of the eyes to the screen.
  94569. */
  94570. eyeToScreenDistance: number;
  94571. /**
  94572. * Define the distance between both lenses
  94573. */
  94574. lensSeparationDistance: number;
  94575. /**
  94576. * Define the distance between both viewer's eyes.
  94577. */
  94578. interpupillaryDistance: number;
  94579. /**
  94580. * Define the distortion factor of the VR postprocess.
  94581. * Please, touch with care.
  94582. */
  94583. distortionK: number[];
  94584. /**
  94585. * Define the chromatic aberration correction factors for the VR post process.
  94586. */
  94587. chromaAbCorrection: number[];
  94588. /**
  94589. * Define the scale factor of the post process.
  94590. * The smaller the better but the slower.
  94591. */
  94592. postProcessScaleFactor: number;
  94593. /**
  94594. * Define an offset for the lens center.
  94595. */
  94596. lensCenterOffset: number;
  94597. /**
  94598. * Define if the current vr camera should compensate the distortion of the lense or not.
  94599. */
  94600. compensateDistortion: boolean;
  94601. /**
  94602. * Gets the rendering aspect ratio based on the provided resolutions.
  94603. */
  94604. readonly aspectRatio: number;
  94605. /**
  94606. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94607. */
  94608. readonly aspectRatioFov: number;
  94609. /**
  94610. * @hidden
  94611. */
  94612. readonly leftHMatrix: Matrix;
  94613. /**
  94614. * @hidden
  94615. */
  94616. readonly rightHMatrix: Matrix;
  94617. /**
  94618. * @hidden
  94619. */
  94620. readonly leftPreViewMatrix: Matrix;
  94621. /**
  94622. * @hidden
  94623. */
  94624. readonly rightPreViewMatrix: Matrix;
  94625. /**
  94626. * Get the default VRMetrics based on the most generic setup.
  94627. * @returns the default vr metrics
  94628. */
  94629. static GetDefault(): VRCameraMetrics;
  94630. }
  94631. }
  94632. declare module BABYLON {
  94633. /** @hidden */
  94634. export var vrDistortionCorrectionPixelShader: {
  94635. name: string;
  94636. shader: string;
  94637. };
  94638. }
  94639. declare module BABYLON {
  94640. /**
  94641. * VRDistortionCorrectionPostProcess used for mobile VR
  94642. */
  94643. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94644. private _isRightEye;
  94645. private _distortionFactors;
  94646. private _postProcessScaleFactor;
  94647. private _lensCenterOffset;
  94648. private _scaleIn;
  94649. private _scaleFactor;
  94650. private _lensCenter;
  94651. /**
  94652. * Initializes the VRDistortionCorrectionPostProcess
  94653. * @param name The name of the effect.
  94654. * @param camera The camera to apply the render pass to.
  94655. * @param isRightEye If this is for the right eye distortion
  94656. * @param vrMetrics All the required metrics for the VR camera
  94657. */
  94658. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94659. }
  94660. }
  94661. declare module BABYLON {
  94662. /**
  94663. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94664. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94665. */
  94666. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94667. /**
  94668. * Creates a new VRDeviceOrientationArcRotateCamera
  94669. * @param name defines camera name
  94670. * @param alpha defines the camera rotation along the logitudinal axis
  94671. * @param beta defines the camera rotation along the latitudinal axis
  94672. * @param radius defines the camera distance from its target
  94673. * @param target defines the camera target
  94674. * @param scene defines the scene the camera belongs to
  94675. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94676. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94677. */
  94678. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94679. /**
  94680. * Gets camera class name
  94681. * @returns VRDeviceOrientationArcRotateCamera
  94682. */
  94683. getClassName(): string;
  94684. }
  94685. }
  94686. declare module BABYLON {
  94687. /**
  94688. * Camera used to simulate VR rendering (based on FreeCamera)
  94689. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94690. */
  94691. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94692. /**
  94693. * Creates a new VRDeviceOrientationFreeCamera
  94694. * @param name defines camera name
  94695. * @param position defines the start position of the camera
  94696. * @param scene defines the scene the camera belongs to
  94697. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94698. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94699. */
  94700. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94701. /**
  94702. * Gets camera class name
  94703. * @returns VRDeviceOrientationFreeCamera
  94704. */
  94705. getClassName(): string;
  94706. }
  94707. }
  94708. declare module BABYLON {
  94709. /**
  94710. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94711. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94712. */
  94713. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94714. /**
  94715. * Creates a new VRDeviceOrientationGamepadCamera
  94716. * @param name defines camera name
  94717. * @param position defines the start position of the camera
  94718. * @param scene defines the scene the camera belongs to
  94719. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94720. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94721. */
  94722. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94723. /**
  94724. * Gets camera class name
  94725. * @returns VRDeviceOrientationGamepadCamera
  94726. */
  94727. getClassName(): string;
  94728. }
  94729. }
  94730. declare module BABYLON {
  94731. /**
  94732. * Defines supported buttons for XBox360 compatible gamepads
  94733. */
  94734. export enum Xbox360Button {
  94735. /** A */
  94736. A = 0,
  94737. /** B */
  94738. B = 1,
  94739. /** X */
  94740. X = 2,
  94741. /** Y */
  94742. Y = 3,
  94743. /** Start */
  94744. Start = 4,
  94745. /** Back */
  94746. Back = 5,
  94747. /** Left button */
  94748. LB = 6,
  94749. /** Right button */
  94750. RB = 7,
  94751. /** Left stick */
  94752. LeftStick = 8,
  94753. /** Right stick */
  94754. RightStick = 9
  94755. }
  94756. /** Defines values for XBox360 DPad */
  94757. export enum Xbox360Dpad {
  94758. /** Up */
  94759. Up = 0,
  94760. /** Down */
  94761. Down = 1,
  94762. /** Left */
  94763. Left = 2,
  94764. /** Right */
  94765. Right = 3
  94766. }
  94767. /**
  94768. * Defines a XBox360 gamepad
  94769. */
  94770. export class Xbox360Pad extends Gamepad {
  94771. private _leftTrigger;
  94772. private _rightTrigger;
  94773. private _onlefttriggerchanged;
  94774. private _onrighttriggerchanged;
  94775. private _onbuttondown;
  94776. private _onbuttonup;
  94777. private _ondpaddown;
  94778. private _ondpadup;
  94779. /** Observable raised when a button is pressed */
  94780. onButtonDownObservable: Observable<Xbox360Button>;
  94781. /** Observable raised when a button is released */
  94782. onButtonUpObservable: Observable<Xbox360Button>;
  94783. /** Observable raised when a pad is pressed */
  94784. onPadDownObservable: Observable<Xbox360Dpad>;
  94785. /** Observable raised when a pad is released */
  94786. onPadUpObservable: Observable<Xbox360Dpad>;
  94787. private _buttonA;
  94788. private _buttonB;
  94789. private _buttonX;
  94790. private _buttonY;
  94791. private _buttonBack;
  94792. private _buttonStart;
  94793. private _buttonLB;
  94794. private _buttonRB;
  94795. private _buttonLeftStick;
  94796. private _buttonRightStick;
  94797. private _dPadUp;
  94798. private _dPadDown;
  94799. private _dPadLeft;
  94800. private _dPadRight;
  94801. private _isXboxOnePad;
  94802. /**
  94803. * Creates a new XBox360 gamepad object
  94804. * @param id defines the id of this gamepad
  94805. * @param index defines its index
  94806. * @param gamepad defines the internal HTML gamepad object
  94807. * @param xboxOne defines if it is a XBox One gamepad
  94808. */
  94809. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94810. /**
  94811. * Defines the callback to call when left trigger is pressed
  94812. * @param callback defines the callback to use
  94813. */
  94814. onlefttriggerchanged(callback: (value: number) => void): void;
  94815. /**
  94816. * Defines the callback to call when right trigger is pressed
  94817. * @param callback defines the callback to use
  94818. */
  94819. onrighttriggerchanged(callback: (value: number) => void): void;
  94820. /**
  94821. * Gets the left trigger value
  94822. */
  94823. /**
  94824. * Sets the left trigger value
  94825. */
  94826. leftTrigger: number;
  94827. /**
  94828. * Gets the right trigger value
  94829. */
  94830. /**
  94831. * Sets the right trigger value
  94832. */
  94833. rightTrigger: number;
  94834. /**
  94835. * Defines the callback to call when a button is pressed
  94836. * @param callback defines the callback to use
  94837. */
  94838. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94839. /**
  94840. * Defines the callback to call when a button is released
  94841. * @param callback defines the callback to use
  94842. */
  94843. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94844. /**
  94845. * Defines the callback to call when a pad is pressed
  94846. * @param callback defines the callback to use
  94847. */
  94848. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94849. /**
  94850. * Defines the callback to call when a pad is released
  94851. * @param callback defines the callback to use
  94852. */
  94853. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94854. private _setButtonValue;
  94855. private _setDPadValue;
  94856. /**
  94857. * Gets the value of the `A` button
  94858. */
  94859. /**
  94860. * Sets the value of the `A` button
  94861. */
  94862. buttonA: number;
  94863. /**
  94864. * Gets the value of the `B` button
  94865. */
  94866. /**
  94867. * Sets the value of the `B` button
  94868. */
  94869. buttonB: number;
  94870. /**
  94871. * Gets the value of the `X` button
  94872. */
  94873. /**
  94874. * Sets the value of the `X` button
  94875. */
  94876. buttonX: number;
  94877. /**
  94878. * Gets the value of the `Y` button
  94879. */
  94880. /**
  94881. * Sets the value of the `Y` button
  94882. */
  94883. buttonY: number;
  94884. /**
  94885. * Gets the value of the `Start` button
  94886. */
  94887. /**
  94888. * Sets the value of the `Start` button
  94889. */
  94890. buttonStart: number;
  94891. /**
  94892. * Gets the value of the `Back` button
  94893. */
  94894. /**
  94895. * Sets the value of the `Back` button
  94896. */
  94897. buttonBack: number;
  94898. /**
  94899. * Gets the value of the `Left` button
  94900. */
  94901. /**
  94902. * Sets the value of the `Left` button
  94903. */
  94904. buttonLB: number;
  94905. /**
  94906. * Gets the value of the `Right` button
  94907. */
  94908. /**
  94909. * Sets the value of the `Right` button
  94910. */
  94911. buttonRB: number;
  94912. /**
  94913. * Gets the value of the Left joystick
  94914. */
  94915. /**
  94916. * Sets the value of the Left joystick
  94917. */
  94918. buttonLeftStick: number;
  94919. /**
  94920. * Gets the value of the Right joystick
  94921. */
  94922. /**
  94923. * Sets the value of the Right joystick
  94924. */
  94925. buttonRightStick: number;
  94926. /**
  94927. * Gets the value of D-pad up
  94928. */
  94929. /**
  94930. * Sets the value of D-pad up
  94931. */
  94932. dPadUp: number;
  94933. /**
  94934. * Gets the value of D-pad down
  94935. */
  94936. /**
  94937. * Sets the value of D-pad down
  94938. */
  94939. dPadDown: number;
  94940. /**
  94941. * Gets the value of D-pad left
  94942. */
  94943. /**
  94944. * Sets the value of D-pad left
  94945. */
  94946. dPadLeft: number;
  94947. /**
  94948. * Gets the value of D-pad right
  94949. */
  94950. /**
  94951. * Sets the value of D-pad right
  94952. */
  94953. dPadRight: number;
  94954. /**
  94955. * Force the gamepad to synchronize with device values
  94956. */
  94957. update(): void;
  94958. /**
  94959. * Disposes the gamepad
  94960. */
  94961. dispose(): void;
  94962. }
  94963. }
  94964. declare module BABYLON {
  94965. /**
  94966. * Base class of materials working in push mode in babylon JS
  94967. * @hidden
  94968. */
  94969. export class PushMaterial extends Material {
  94970. protected _activeEffect: Effect;
  94971. protected _normalMatrix: Matrix;
  94972. /**
  94973. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94974. * This means that the material can keep using a previous shader while a new one is being compiled.
  94975. * This is mostly used when shader parallel compilation is supported (true by default)
  94976. */
  94977. allowShaderHotSwapping: boolean;
  94978. constructor(name: string, scene: Scene);
  94979. getEffect(): Effect;
  94980. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94981. /**
  94982. * Binds the given world matrix to the active effect
  94983. *
  94984. * @param world the matrix to bind
  94985. */
  94986. bindOnlyWorldMatrix(world: Matrix): void;
  94987. /**
  94988. * Binds the given normal matrix to the active effect
  94989. *
  94990. * @param normalMatrix the matrix to bind
  94991. */
  94992. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94993. bind(world: Matrix, mesh?: Mesh): void;
  94994. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94995. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94996. }
  94997. }
  94998. declare module BABYLON {
  94999. /**
  95000. * This groups all the flags used to control the materials channel.
  95001. */
  95002. export class MaterialFlags {
  95003. private static _DiffuseTextureEnabled;
  95004. /**
  95005. * Are diffuse textures enabled in the application.
  95006. */
  95007. static DiffuseTextureEnabled: boolean;
  95008. private static _AmbientTextureEnabled;
  95009. /**
  95010. * Are ambient textures enabled in the application.
  95011. */
  95012. static AmbientTextureEnabled: boolean;
  95013. private static _OpacityTextureEnabled;
  95014. /**
  95015. * Are opacity textures enabled in the application.
  95016. */
  95017. static OpacityTextureEnabled: boolean;
  95018. private static _ReflectionTextureEnabled;
  95019. /**
  95020. * Are reflection textures enabled in the application.
  95021. */
  95022. static ReflectionTextureEnabled: boolean;
  95023. private static _EmissiveTextureEnabled;
  95024. /**
  95025. * Are emissive textures enabled in the application.
  95026. */
  95027. static EmissiveTextureEnabled: boolean;
  95028. private static _SpecularTextureEnabled;
  95029. /**
  95030. * Are specular textures enabled in the application.
  95031. */
  95032. static SpecularTextureEnabled: boolean;
  95033. private static _BumpTextureEnabled;
  95034. /**
  95035. * Are bump textures enabled in the application.
  95036. */
  95037. static BumpTextureEnabled: boolean;
  95038. private static _LightmapTextureEnabled;
  95039. /**
  95040. * Are lightmap textures enabled in the application.
  95041. */
  95042. static LightmapTextureEnabled: boolean;
  95043. private static _RefractionTextureEnabled;
  95044. /**
  95045. * Are refraction textures enabled in the application.
  95046. */
  95047. static RefractionTextureEnabled: boolean;
  95048. private static _ColorGradingTextureEnabled;
  95049. /**
  95050. * Are color grading textures enabled in the application.
  95051. */
  95052. static ColorGradingTextureEnabled: boolean;
  95053. private static _FresnelEnabled;
  95054. /**
  95055. * Are fresnels enabled in the application.
  95056. */
  95057. static FresnelEnabled: boolean;
  95058. private static _ClearCoatTextureEnabled;
  95059. /**
  95060. * Are clear coat textures enabled in the application.
  95061. */
  95062. static ClearCoatTextureEnabled: boolean;
  95063. private static _ClearCoatBumpTextureEnabled;
  95064. /**
  95065. * Are clear coat bump textures enabled in the application.
  95066. */
  95067. static ClearCoatBumpTextureEnabled: boolean;
  95068. private static _ClearCoatTintTextureEnabled;
  95069. /**
  95070. * Are clear coat tint textures enabled in the application.
  95071. */
  95072. static ClearCoatTintTextureEnabled: boolean;
  95073. private static _SheenTextureEnabled;
  95074. /**
  95075. * Are sheen textures enabled in the application.
  95076. */
  95077. static SheenTextureEnabled: boolean;
  95078. private static _AnisotropicTextureEnabled;
  95079. /**
  95080. * Are anisotropic textures enabled in the application.
  95081. */
  95082. static AnisotropicTextureEnabled: boolean;
  95083. }
  95084. }
  95085. declare module BABYLON {
  95086. /** @hidden */
  95087. export var defaultFragmentDeclaration: {
  95088. name: string;
  95089. shader: string;
  95090. };
  95091. }
  95092. declare module BABYLON {
  95093. /** @hidden */
  95094. export var defaultUboDeclaration: {
  95095. name: string;
  95096. shader: string;
  95097. };
  95098. }
  95099. declare module BABYLON {
  95100. /** @hidden */
  95101. export var lightFragmentDeclaration: {
  95102. name: string;
  95103. shader: string;
  95104. };
  95105. }
  95106. declare module BABYLON {
  95107. /** @hidden */
  95108. export var lightUboDeclaration: {
  95109. name: string;
  95110. shader: string;
  95111. };
  95112. }
  95113. declare module BABYLON {
  95114. /** @hidden */
  95115. export var lightsFragmentFunctions: {
  95116. name: string;
  95117. shader: string;
  95118. };
  95119. }
  95120. declare module BABYLON {
  95121. /** @hidden */
  95122. export var shadowsFragmentFunctions: {
  95123. name: string;
  95124. shader: string;
  95125. };
  95126. }
  95127. declare module BABYLON {
  95128. /** @hidden */
  95129. export var fresnelFunction: {
  95130. name: string;
  95131. shader: string;
  95132. };
  95133. }
  95134. declare module BABYLON {
  95135. /** @hidden */
  95136. export var reflectionFunction: {
  95137. name: string;
  95138. shader: string;
  95139. };
  95140. }
  95141. declare module BABYLON {
  95142. /** @hidden */
  95143. export var bumpFragmentFunctions: {
  95144. name: string;
  95145. shader: string;
  95146. };
  95147. }
  95148. declare module BABYLON {
  95149. /** @hidden */
  95150. export var logDepthDeclaration: {
  95151. name: string;
  95152. shader: string;
  95153. };
  95154. }
  95155. declare module BABYLON {
  95156. /** @hidden */
  95157. export var bumpFragment: {
  95158. name: string;
  95159. shader: string;
  95160. };
  95161. }
  95162. declare module BABYLON {
  95163. /** @hidden */
  95164. export var depthPrePass: {
  95165. name: string;
  95166. shader: string;
  95167. };
  95168. }
  95169. declare module BABYLON {
  95170. /** @hidden */
  95171. export var lightFragment: {
  95172. name: string;
  95173. shader: string;
  95174. };
  95175. }
  95176. declare module BABYLON {
  95177. /** @hidden */
  95178. export var logDepthFragment: {
  95179. name: string;
  95180. shader: string;
  95181. };
  95182. }
  95183. declare module BABYLON {
  95184. /** @hidden */
  95185. export var defaultPixelShader: {
  95186. name: string;
  95187. shader: string;
  95188. };
  95189. }
  95190. declare module BABYLON {
  95191. /** @hidden */
  95192. export var defaultVertexDeclaration: {
  95193. name: string;
  95194. shader: string;
  95195. };
  95196. }
  95197. declare module BABYLON {
  95198. /** @hidden */
  95199. export var bumpVertexDeclaration: {
  95200. name: string;
  95201. shader: string;
  95202. };
  95203. }
  95204. declare module BABYLON {
  95205. /** @hidden */
  95206. export var bumpVertex: {
  95207. name: string;
  95208. shader: string;
  95209. };
  95210. }
  95211. declare module BABYLON {
  95212. /** @hidden */
  95213. export var fogVertex: {
  95214. name: string;
  95215. shader: string;
  95216. };
  95217. }
  95218. declare module BABYLON {
  95219. /** @hidden */
  95220. export var shadowsVertex: {
  95221. name: string;
  95222. shader: string;
  95223. };
  95224. }
  95225. declare module BABYLON {
  95226. /** @hidden */
  95227. export var pointCloudVertex: {
  95228. name: string;
  95229. shader: string;
  95230. };
  95231. }
  95232. declare module BABYLON {
  95233. /** @hidden */
  95234. export var logDepthVertex: {
  95235. name: string;
  95236. shader: string;
  95237. };
  95238. }
  95239. declare module BABYLON {
  95240. /** @hidden */
  95241. export var defaultVertexShader: {
  95242. name: string;
  95243. shader: string;
  95244. };
  95245. }
  95246. declare module BABYLON {
  95247. /** @hidden */
  95248. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95249. MAINUV1: boolean;
  95250. MAINUV2: boolean;
  95251. DIFFUSE: boolean;
  95252. DIFFUSEDIRECTUV: number;
  95253. AMBIENT: boolean;
  95254. AMBIENTDIRECTUV: number;
  95255. OPACITY: boolean;
  95256. OPACITYDIRECTUV: number;
  95257. OPACITYRGB: boolean;
  95258. REFLECTION: boolean;
  95259. EMISSIVE: boolean;
  95260. EMISSIVEDIRECTUV: number;
  95261. SPECULAR: boolean;
  95262. SPECULARDIRECTUV: number;
  95263. BUMP: boolean;
  95264. BUMPDIRECTUV: number;
  95265. PARALLAX: boolean;
  95266. PARALLAXOCCLUSION: boolean;
  95267. SPECULAROVERALPHA: boolean;
  95268. CLIPPLANE: boolean;
  95269. CLIPPLANE2: boolean;
  95270. CLIPPLANE3: boolean;
  95271. CLIPPLANE4: boolean;
  95272. ALPHATEST: boolean;
  95273. DEPTHPREPASS: boolean;
  95274. ALPHAFROMDIFFUSE: boolean;
  95275. POINTSIZE: boolean;
  95276. FOG: boolean;
  95277. SPECULARTERM: boolean;
  95278. DIFFUSEFRESNEL: boolean;
  95279. OPACITYFRESNEL: boolean;
  95280. REFLECTIONFRESNEL: boolean;
  95281. REFRACTIONFRESNEL: boolean;
  95282. EMISSIVEFRESNEL: boolean;
  95283. FRESNEL: boolean;
  95284. NORMAL: boolean;
  95285. UV1: boolean;
  95286. UV2: boolean;
  95287. VERTEXCOLOR: boolean;
  95288. VERTEXALPHA: boolean;
  95289. NUM_BONE_INFLUENCERS: number;
  95290. BonesPerMesh: number;
  95291. BONETEXTURE: boolean;
  95292. INSTANCES: boolean;
  95293. GLOSSINESS: boolean;
  95294. ROUGHNESS: boolean;
  95295. EMISSIVEASILLUMINATION: boolean;
  95296. LINKEMISSIVEWITHDIFFUSE: boolean;
  95297. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95298. LIGHTMAP: boolean;
  95299. LIGHTMAPDIRECTUV: number;
  95300. OBJECTSPACE_NORMALMAP: boolean;
  95301. USELIGHTMAPASSHADOWMAP: boolean;
  95302. REFLECTIONMAP_3D: boolean;
  95303. REFLECTIONMAP_SPHERICAL: boolean;
  95304. REFLECTIONMAP_PLANAR: boolean;
  95305. REFLECTIONMAP_CUBIC: boolean;
  95306. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95307. REFLECTIONMAP_PROJECTION: boolean;
  95308. REFLECTIONMAP_SKYBOX: boolean;
  95309. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95310. REFLECTIONMAP_EXPLICIT: boolean;
  95311. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95312. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95313. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95314. INVERTCUBICMAP: boolean;
  95315. LOGARITHMICDEPTH: boolean;
  95316. REFRACTION: boolean;
  95317. REFRACTIONMAP_3D: boolean;
  95318. REFLECTIONOVERALPHA: boolean;
  95319. TWOSIDEDLIGHTING: boolean;
  95320. SHADOWFLOAT: boolean;
  95321. MORPHTARGETS: boolean;
  95322. MORPHTARGETS_NORMAL: boolean;
  95323. MORPHTARGETS_TANGENT: boolean;
  95324. NUM_MORPH_INFLUENCERS: number;
  95325. NONUNIFORMSCALING: boolean;
  95326. PREMULTIPLYALPHA: boolean;
  95327. IMAGEPROCESSING: boolean;
  95328. VIGNETTE: boolean;
  95329. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95330. VIGNETTEBLENDMODEOPAQUE: boolean;
  95331. TONEMAPPING: boolean;
  95332. TONEMAPPING_ACES: boolean;
  95333. CONTRAST: boolean;
  95334. COLORCURVES: boolean;
  95335. COLORGRADING: boolean;
  95336. COLORGRADING3D: boolean;
  95337. SAMPLER3DGREENDEPTH: boolean;
  95338. SAMPLER3DBGRMAP: boolean;
  95339. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95340. /**
  95341. * If the reflection texture on this material is in linear color space
  95342. * @hidden
  95343. */
  95344. IS_REFLECTION_LINEAR: boolean;
  95345. /**
  95346. * If the refraction texture on this material is in linear color space
  95347. * @hidden
  95348. */
  95349. IS_REFRACTION_LINEAR: boolean;
  95350. EXPOSURE: boolean;
  95351. constructor();
  95352. setReflectionMode(modeToEnable: string): void;
  95353. }
  95354. /**
  95355. * This is the default material used in Babylon. It is the best trade off between quality
  95356. * and performances.
  95357. * @see http://doc.babylonjs.com/babylon101/materials
  95358. */
  95359. export class StandardMaterial extends PushMaterial {
  95360. private _diffuseTexture;
  95361. /**
  95362. * The basic texture of the material as viewed under a light.
  95363. */
  95364. diffuseTexture: Nullable<BaseTexture>;
  95365. private _ambientTexture;
  95366. /**
  95367. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95368. */
  95369. ambientTexture: Nullable<BaseTexture>;
  95370. private _opacityTexture;
  95371. /**
  95372. * Define the transparency of the material from a texture.
  95373. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95374. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95375. */
  95376. opacityTexture: Nullable<BaseTexture>;
  95377. private _reflectionTexture;
  95378. /**
  95379. * Define the texture used to display the reflection.
  95380. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95381. */
  95382. reflectionTexture: Nullable<BaseTexture>;
  95383. private _emissiveTexture;
  95384. /**
  95385. * Define texture of the material as if self lit.
  95386. * This will be mixed in the final result even in the absence of light.
  95387. */
  95388. emissiveTexture: Nullable<BaseTexture>;
  95389. private _specularTexture;
  95390. /**
  95391. * Define how the color and intensity of the highlight given by the light in the material.
  95392. */
  95393. specularTexture: Nullable<BaseTexture>;
  95394. private _bumpTexture;
  95395. /**
  95396. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95397. * 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.
  95398. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95399. */
  95400. bumpTexture: Nullable<BaseTexture>;
  95401. private _lightmapTexture;
  95402. /**
  95403. * Complex lighting can be computationally expensive to compute at runtime.
  95404. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95405. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95406. */
  95407. lightmapTexture: Nullable<BaseTexture>;
  95408. private _refractionTexture;
  95409. /**
  95410. * Define the texture used to display the refraction.
  95411. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95412. */
  95413. refractionTexture: Nullable<BaseTexture>;
  95414. /**
  95415. * The color of the material lit by the environmental background lighting.
  95416. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95417. */
  95418. ambientColor: Color3;
  95419. /**
  95420. * The basic color of the material as viewed under a light.
  95421. */
  95422. diffuseColor: Color3;
  95423. /**
  95424. * Define how the color and intensity of the highlight given by the light in the material.
  95425. */
  95426. specularColor: Color3;
  95427. /**
  95428. * Define the color of the material as if self lit.
  95429. * This will be mixed in the final result even in the absence of light.
  95430. */
  95431. emissiveColor: Color3;
  95432. /**
  95433. * Defines how sharp are the highlights in the material.
  95434. * The bigger the value the sharper giving a more glossy feeling to the result.
  95435. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95436. */
  95437. specularPower: number;
  95438. private _useAlphaFromDiffuseTexture;
  95439. /**
  95440. * Does the transparency come from the diffuse texture alpha channel.
  95441. */
  95442. useAlphaFromDiffuseTexture: boolean;
  95443. private _useEmissiveAsIllumination;
  95444. /**
  95445. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95446. */
  95447. useEmissiveAsIllumination: boolean;
  95448. private _linkEmissiveWithDiffuse;
  95449. /**
  95450. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95451. * the emissive level when the final color is close to one.
  95452. */
  95453. linkEmissiveWithDiffuse: boolean;
  95454. private _useSpecularOverAlpha;
  95455. /**
  95456. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95457. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95458. */
  95459. useSpecularOverAlpha: boolean;
  95460. private _useReflectionOverAlpha;
  95461. /**
  95462. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95463. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95464. */
  95465. useReflectionOverAlpha: boolean;
  95466. private _disableLighting;
  95467. /**
  95468. * Does lights from the scene impacts this material.
  95469. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95470. */
  95471. disableLighting: boolean;
  95472. private _useObjectSpaceNormalMap;
  95473. /**
  95474. * Allows using an object space normal map (instead of tangent space).
  95475. */
  95476. useObjectSpaceNormalMap: boolean;
  95477. private _useParallax;
  95478. /**
  95479. * Is parallax enabled or not.
  95480. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95481. */
  95482. useParallax: boolean;
  95483. private _useParallaxOcclusion;
  95484. /**
  95485. * Is parallax occlusion enabled or not.
  95486. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95487. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95488. */
  95489. useParallaxOcclusion: boolean;
  95490. /**
  95491. * 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.
  95492. */
  95493. parallaxScaleBias: number;
  95494. private _roughness;
  95495. /**
  95496. * Helps to define how blurry the reflections should appears in the material.
  95497. */
  95498. roughness: number;
  95499. /**
  95500. * In case of refraction, define the value of the indice of refraction.
  95501. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95502. */
  95503. indexOfRefraction: number;
  95504. /**
  95505. * Invert the refraction texture alongside the y axis.
  95506. * It can be useful with procedural textures or probe for instance.
  95507. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95508. */
  95509. invertRefractionY: boolean;
  95510. /**
  95511. * Defines the alpha limits in alpha test mode.
  95512. */
  95513. alphaCutOff: number;
  95514. private _useLightmapAsShadowmap;
  95515. /**
  95516. * In case of light mapping, define whether the map contains light or shadow informations.
  95517. */
  95518. useLightmapAsShadowmap: boolean;
  95519. private _diffuseFresnelParameters;
  95520. /**
  95521. * Define the diffuse fresnel parameters of the material.
  95522. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95523. */
  95524. diffuseFresnelParameters: FresnelParameters;
  95525. private _opacityFresnelParameters;
  95526. /**
  95527. * Define the opacity fresnel parameters of the material.
  95528. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95529. */
  95530. opacityFresnelParameters: FresnelParameters;
  95531. private _reflectionFresnelParameters;
  95532. /**
  95533. * Define the reflection fresnel parameters of the material.
  95534. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95535. */
  95536. reflectionFresnelParameters: FresnelParameters;
  95537. private _refractionFresnelParameters;
  95538. /**
  95539. * Define the refraction fresnel parameters of the material.
  95540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95541. */
  95542. refractionFresnelParameters: FresnelParameters;
  95543. private _emissiveFresnelParameters;
  95544. /**
  95545. * Define the emissive fresnel parameters of the material.
  95546. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95547. */
  95548. emissiveFresnelParameters: FresnelParameters;
  95549. private _useReflectionFresnelFromSpecular;
  95550. /**
  95551. * If true automatically deducts the fresnels values from the material specularity.
  95552. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95553. */
  95554. useReflectionFresnelFromSpecular: boolean;
  95555. private _useGlossinessFromSpecularMapAlpha;
  95556. /**
  95557. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95558. */
  95559. useGlossinessFromSpecularMapAlpha: boolean;
  95560. private _maxSimultaneousLights;
  95561. /**
  95562. * Defines the maximum number of lights that can be used in the material
  95563. */
  95564. maxSimultaneousLights: number;
  95565. private _invertNormalMapX;
  95566. /**
  95567. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95568. */
  95569. invertNormalMapX: boolean;
  95570. private _invertNormalMapY;
  95571. /**
  95572. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95573. */
  95574. invertNormalMapY: boolean;
  95575. private _twoSidedLighting;
  95576. /**
  95577. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95578. */
  95579. twoSidedLighting: boolean;
  95580. /**
  95581. * Default configuration related to image processing available in the standard Material.
  95582. */
  95583. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95584. /**
  95585. * Gets the image processing configuration used either in this material.
  95586. */
  95587. /**
  95588. * Sets the Default image processing configuration used either in the this material.
  95589. *
  95590. * If sets to null, the scene one is in use.
  95591. */
  95592. imageProcessingConfiguration: ImageProcessingConfiguration;
  95593. /**
  95594. * Keep track of the image processing observer to allow dispose and replace.
  95595. */
  95596. private _imageProcessingObserver;
  95597. /**
  95598. * Attaches a new image processing configuration to the Standard Material.
  95599. * @param configuration
  95600. */
  95601. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95602. /**
  95603. * Gets wether the color curves effect is enabled.
  95604. */
  95605. /**
  95606. * Sets wether the color curves effect is enabled.
  95607. */
  95608. cameraColorCurvesEnabled: boolean;
  95609. /**
  95610. * Gets wether the color grading effect is enabled.
  95611. */
  95612. /**
  95613. * Gets wether the color grading effect is enabled.
  95614. */
  95615. cameraColorGradingEnabled: boolean;
  95616. /**
  95617. * Gets wether tonemapping is enabled or not.
  95618. */
  95619. /**
  95620. * Sets wether tonemapping is enabled or not
  95621. */
  95622. cameraToneMappingEnabled: boolean;
  95623. /**
  95624. * The camera exposure used on this material.
  95625. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95626. * This corresponds to a photographic exposure.
  95627. */
  95628. /**
  95629. * The camera exposure used on this material.
  95630. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95631. * This corresponds to a photographic exposure.
  95632. */
  95633. cameraExposure: number;
  95634. /**
  95635. * Gets The camera contrast used on this material.
  95636. */
  95637. /**
  95638. * Sets The camera contrast used on this material.
  95639. */
  95640. cameraContrast: number;
  95641. /**
  95642. * Gets the Color Grading 2D Lookup Texture.
  95643. */
  95644. /**
  95645. * Sets the Color Grading 2D Lookup Texture.
  95646. */
  95647. cameraColorGradingTexture: Nullable<BaseTexture>;
  95648. /**
  95649. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95650. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95651. * 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;
  95652. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95653. */
  95654. /**
  95655. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95656. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95657. * 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;
  95658. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95659. */
  95660. cameraColorCurves: Nullable<ColorCurves>;
  95661. /**
  95662. * Custom callback helping to override the default shader used in the material.
  95663. */
  95664. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95665. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95666. protected _worldViewProjectionMatrix: Matrix;
  95667. protected _globalAmbientColor: Color3;
  95668. protected _useLogarithmicDepth: boolean;
  95669. /**
  95670. * Instantiates a new standard material.
  95671. * This is the default material used in Babylon. It is the best trade off between quality
  95672. * and performances.
  95673. * @see http://doc.babylonjs.com/babylon101/materials
  95674. * @param name Define the name of the material in the scene
  95675. * @param scene Define the scene the material belong to
  95676. */
  95677. constructor(name: string, scene: Scene);
  95678. /**
  95679. * Gets a boolean indicating that current material needs to register RTT
  95680. */
  95681. readonly hasRenderTargetTextures: boolean;
  95682. /**
  95683. * Gets the current class name of the material e.g. "StandardMaterial"
  95684. * Mainly use in serialization.
  95685. * @returns the class name
  95686. */
  95687. getClassName(): string;
  95688. /**
  95689. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95690. * You can try switching to logarithmic depth.
  95691. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95692. */
  95693. useLogarithmicDepth: boolean;
  95694. /**
  95695. * Specifies if the material will require alpha blending
  95696. * @returns a boolean specifying if alpha blending is needed
  95697. */
  95698. needAlphaBlending(): boolean;
  95699. /**
  95700. * Specifies if this material should be rendered in alpha test mode
  95701. * @returns a boolean specifying if an alpha test is needed.
  95702. */
  95703. needAlphaTesting(): boolean;
  95704. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95705. /**
  95706. * Get the texture used for alpha test purpose.
  95707. * @returns the diffuse texture in case of the standard material.
  95708. */
  95709. getAlphaTestTexture(): Nullable<BaseTexture>;
  95710. /**
  95711. * Get if the submesh is ready to be used and all its information available.
  95712. * Child classes can use it to update shaders
  95713. * @param mesh defines the mesh to check
  95714. * @param subMesh defines which submesh to check
  95715. * @param useInstances specifies that instances should be used
  95716. * @returns a boolean indicating that the submesh is ready or not
  95717. */
  95718. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95719. /**
  95720. * Builds the material UBO layouts.
  95721. * Used internally during the effect preparation.
  95722. */
  95723. buildUniformLayout(): void;
  95724. /**
  95725. * Unbinds the material from the mesh
  95726. */
  95727. unbind(): void;
  95728. /**
  95729. * Binds the submesh to this material by preparing the effect and shader to draw
  95730. * @param world defines the world transformation matrix
  95731. * @param mesh defines the mesh containing the submesh
  95732. * @param subMesh defines the submesh to bind the material to
  95733. */
  95734. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95735. /**
  95736. * Get the list of animatables in the material.
  95737. * @returns the list of animatables object used in the material
  95738. */
  95739. getAnimatables(): IAnimatable[];
  95740. /**
  95741. * Gets the active textures from the material
  95742. * @returns an array of textures
  95743. */
  95744. getActiveTextures(): BaseTexture[];
  95745. /**
  95746. * Specifies if the material uses a texture
  95747. * @param texture defines the texture to check against the material
  95748. * @returns a boolean specifying if the material uses the texture
  95749. */
  95750. hasTexture(texture: BaseTexture): boolean;
  95751. /**
  95752. * Disposes the material
  95753. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95754. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95755. */
  95756. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95757. /**
  95758. * Makes a duplicate of the material, and gives it a new name
  95759. * @param name defines the new name for the duplicated material
  95760. * @returns the cloned material
  95761. */
  95762. clone(name: string): StandardMaterial;
  95763. /**
  95764. * Serializes this material in a JSON representation
  95765. * @returns the serialized material object
  95766. */
  95767. serialize(): any;
  95768. /**
  95769. * Creates a standard material from parsed material data
  95770. * @param source defines the JSON representation of the material
  95771. * @param scene defines the hosting scene
  95772. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95773. * @returns a new standard material
  95774. */
  95775. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95776. /**
  95777. * Are diffuse textures enabled in the application.
  95778. */
  95779. static DiffuseTextureEnabled: boolean;
  95780. /**
  95781. * Are ambient textures enabled in the application.
  95782. */
  95783. static AmbientTextureEnabled: boolean;
  95784. /**
  95785. * Are opacity textures enabled in the application.
  95786. */
  95787. static OpacityTextureEnabled: boolean;
  95788. /**
  95789. * Are reflection textures enabled in the application.
  95790. */
  95791. static ReflectionTextureEnabled: boolean;
  95792. /**
  95793. * Are emissive textures enabled in the application.
  95794. */
  95795. static EmissiveTextureEnabled: boolean;
  95796. /**
  95797. * Are specular textures enabled in the application.
  95798. */
  95799. static SpecularTextureEnabled: boolean;
  95800. /**
  95801. * Are bump textures enabled in the application.
  95802. */
  95803. static BumpTextureEnabled: boolean;
  95804. /**
  95805. * Are lightmap textures enabled in the application.
  95806. */
  95807. static LightmapTextureEnabled: boolean;
  95808. /**
  95809. * Are refraction textures enabled in the application.
  95810. */
  95811. static RefractionTextureEnabled: boolean;
  95812. /**
  95813. * Are color grading textures enabled in the application.
  95814. */
  95815. static ColorGradingTextureEnabled: boolean;
  95816. /**
  95817. * Are fresnels enabled in the application.
  95818. */
  95819. static FresnelEnabled: boolean;
  95820. }
  95821. }
  95822. declare module BABYLON {
  95823. /**
  95824. * A class extending Texture allowing drawing on a texture
  95825. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95826. */
  95827. export class DynamicTexture extends Texture {
  95828. private _generateMipMaps;
  95829. private _canvas;
  95830. private _context;
  95831. private _engine;
  95832. /**
  95833. * Creates a DynamicTexture
  95834. * @param name defines the name of the texture
  95835. * @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
  95836. * @param scene defines the scene where you want the texture
  95837. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95838. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95839. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95840. */
  95841. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95842. /**
  95843. * Get the current class name of the texture useful for serialization or dynamic coding.
  95844. * @returns "DynamicTexture"
  95845. */
  95846. getClassName(): string;
  95847. /**
  95848. * Gets the current state of canRescale
  95849. */
  95850. readonly canRescale: boolean;
  95851. private _recreate;
  95852. /**
  95853. * Scales the texture
  95854. * @param ratio the scale factor to apply to both width and height
  95855. */
  95856. scale(ratio: number): void;
  95857. /**
  95858. * Resizes the texture
  95859. * @param width the new width
  95860. * @param height the new height
  95861. */
  95862. scaleTo(width: number, height: number): void;
  95863. /**
  95864. * Gets the context of the canvas used by the texture
  95865. * @returns the canvas context of the dynamic texture
  95866. */
  95867. getContext(): CanvasRenderingContext2D;
  95868. /**
  95869. * Clears the texture
  95870. */
  95871. clear(): void;
  95872. /**
  95873. * Updates the texture
  95874. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95875. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95876. */
  95877. update(invertY?: boolean, premulAlpha?: boolean): void;
  95878. /**
  95879. * Draws text onto the texture
  95880. * @param text defines the text to be drawn
  95881. * @param x defines the placement of the text from the left
  95882. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95883. * @param font defines the font to be used with font-style, font-size, font-name
  95884. * @param color defines the color used for the text
  95885. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95886. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95887. * @param update defines whether texture is immediately update (default is true)
  95888. */
  95889. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95890. /**
  95891. * Clones the texture
  95892. * @returns the clone of the texture.
  95893. */
  95894. clone(): DynamicTexture;
  95895. /**
  95896. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95897. * @returns a serialized dynamic texture object
  95898. */
  95899. serialize(): any;
  95900. /** @hidden */
  95901. _rebuild(): void;
  95902. }
  95903. }
  95904. declare module BABYLON {
  95905. /** @hidden */
  95906. export var imageProcessingPixelShader: {
  95907. name: string;
  95908. shader: string;
  95909. };
  95910. }
  95911. declare module BABYLON {
  95912. /**
  95913. * ImageProcessingPostProcess
  95914. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95915. */
  95916. export class ImageProcessingPostProcess extends PostProcess {
  95917. /**
  95918. * Default configuration related to image processing available in the PBR Material.
  95919. */
  95920. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95921. /**
  95922. * Gets the image processing configuration used either in this material.
  95923. */
  95924. /**
  95925. * Sets the Default image processing configuration used either in the this material.
  95926. *
  95927. * If sets to null, the scene one is in use.
  95928. */
  95929. imageProcessingConfiguration: ImageProcessingConfiguration;
  95930. /**
  95931. * Keep track of the image processing observer to allow dispose and replace.
  95932. */
  95933. private _imageProcessingObserver;
  95934. /**
  95935. * Attaches a new image processing configuration to the PBR Material.
  95936. * @param configuration
  95937. */
  95938. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95939. /**
  95940. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95941. */
  95942. /**
  95943. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95944. */
  95945. colorCurves: Nullable<ColorCurves>;
  95946. /**
  95947. * Gets wether the color curves effect is enabled.
  95948. */
  95949. /**
  95950. * Sets wether the color curves effect is enabled.
  95951. */
  95952. colorCurvesEnabled: boolean;
  95953. /**
  95954. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95955. */
  95956. /**
  95957. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95958. */
  95959. colorGradingTexture: Nullable<BaseTexture>;
  95960. /**
  95961. * Gets wether the color grading effect is enabled.
  95962. */
  95963. /**
  95964. * Gets wether the color grading effect is enabled.
  95965. */
  95966. colorGradingEnabled: boolean;
  95967. /**
  95968. * Gets exposure used in the effect.
  95969. */
  95970. /**
  95971. * Sets exposure used in the effect.
  95972. */
  95973. exposure: number;
  95974. /**
  95975. * Gets wether tonemapping is enabled or not.
  95976. */
  95977. /**
  95978. * Sets wether tonemapping is enabled or not
  95979. */
  95980. toneMappingEnabled: boolean;
  95981. /**
  95982. * Gets the type of tone mapping effect.
  95983. */
  95984. /**
  95985. * Sets the type of tone mapping effect.
  95986. */
  95987. toneMappingType: number;
  95988. /**
  95989. * Gets contrast used in the effect.
  95990. */
  95991. /**
  95992. * Sets contrast used in the effect.
  95993. */
  95994. contrast: number;
  95995. /**
  95996. * Gets Vignette stretch size.
  95997. */
  95998. /**
  95999. * Sets Vignette stretch size.
  96000. */
  96001. vignetteStretch: number;
  96002. /**
  96003. * Gets Vignette centre X Offset.
  96004. */
  96005. /**
  96006. * Sets Vignette centre X Offset.
  96007. */
  96008. vignetteCentreX: number;
  96009. /**
  96010. * Gets Vignette centre Y Offset.
  96011. */
  96012. /**
  96013. * Sets Vignette centre Y Offset.
  96014. */
  96015. vignetteCentreY: number;
  96016. /**
  96017. * Gets Vignette weight or intensity of the vignette effect.
  96018. */
  96019. /**
  96020. * Sets Vignette weight or intensity of the vignette effect.
  96021. */
  96022. vignetteWeight: number;
  96023. /**
  96024. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96025. * if vignetteEnabled is set to true.
  96026. */
  96027. /**
  96028. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96029. * if vignetteEnabled is set to true.
  96030. */
  96031. vignetteColor: Color4;
  96032. /**
  96033. * Gets Camera field of view used by the Vignette effect.
  96034. */
  96035. /**
  96036. * Sets Camera field of view used by the Vignette effect.
  96037. */
  96038. vignetteCameraFov: number;
  96039. /**
  96040. * Gets the vignette blend mode allowing different kind of effect.
  96041. */
  96042. /**
  96043. * Sets the vignette blend mode allowing different kind of effect.
  96044. */
  96045. vignetteBlendMode: number;
  96046. /**
  96047. * Gets wether the vignette effect is enabled.
  96048. */
  96049. /**
  96050. * Sets wether the vignette effect is enabled.
  96051. */
  96052. vignetteEnabled: boolean;
  96053. private _fromLinearSpace;
  96054. /**
  96055. * Gets wether the input of the processing is in Gamma or Linear Space.
  96056. */
  96057. /**
  96058. * Sets wether the input of the processing is in Gamma or Linear Space.
  96059. */
  96060. fromLinearSpace: boolean;
  96061. /**
  96062. * Defines cache preventing GC.
  96063. */
  96064. private _defines;
  96065. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  96066. /**
  96067. * "ImageProcessingPostProcess"
  96068. * @returns "ImageProcessingPostProcess"
  96069. */
  96070. getClassName(): string;
  96071. protected _updateParameters(): void;
  96072. dispose(camera?: Camera): void;
  96073. }
  96074. }
  96075. declare module BABYLON {
  96076. /**
  96077. * Class containing static functions to help procedurally build meshes
  96078. */
  96079. export class GroundBuilder {
  96080. /**
  96081. * Creates a ground mesh
  96082. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  96083. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  96084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96085. * @param name defines the name of the mesh
  96086. * @param options defines the options used to create the mesh
  96087. * @param scene defines the hosting scene
  96088. * @returns the ground mesh
  96089. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  96090. */
  96091. static CreateGround(name: string, options: {
  96092. width?: number;
  96093. height?: number;
  96094. subdivisions?: number;
  96095. subdivisionsX?: number;
  96096. subdivisionsY?: number;
  96097. updatable?: boolean;
  96098. }, scene: any): Mesh;
  96099. /**
  96100. * Creates a tiled ground mesh
  96101. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  96102. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  96103. * * 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
  96104. * * 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
  96105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96106. * @param name defines the name of the mesh
  96107. * @param options defines the options used to create the mesh
  96108. * @param scene defines the hosting scene
  96109. * @returns the tiled ground mesh
  96110. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  96111. */
  96112. static CreateTiledGround(name: string, options: {
  96113. xmin: number;
  96114. zmin: number;
  96115. xmax: number;
  96116. zmax: number;
  96117. subdivisions?: {
  96118. w: number;
  96119. h: number;
  96120. };
  96121. precision?: {
  96122. w: number;
  96123. h: number;
  96124. };
  96125. updatable?: boolean;
  96126. }, scene: Scene): Mesh;
  96127. /**
  96128. * Creates a ground mesh from a height map
  96129. * * The parameter `url` sets the URL of the height map image resource.
  96130. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  96131. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  96132. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  96133. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  96134. * * 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.
  96135. * * 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).
  96136. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96138. * @param name defines the name of the mesh
  96139. * @param url defines the url to the height map
  96140. * @param options defines the options used to create the mesh
  96141. * @param scene defines the hosting scene
  96142. * @returns the ground mesh
  96143. * @see https://doc.babylonjs.com/babylon101/height_map
  96144. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  96145. */
  96146. static CreateGroundFromHeightMap(name: string, url: string, options: {
  96147. width?: number;
  96148. height?: number;
  96149. subdivisions?: number;
  96150. minHeight?: number;
  96151. maxHeight?: number;
  96152. colorFilter?: Color3;
  96153. alphaFilter?: number;
  96154. updatable?: boolean;
  96155. onReady?: (mesh: GroundMesh) => void;
  96156. }, scene: Scene): GroundMesh;
  96157. }
  96158. }
  96159. declare module BABYLON {
  96160. /**
  96161. * Class containing static functions to help procedurally build meshes
  96162. */
  96163. export class TorusBuilder {
  96164. /**
  96165. * Creates a torus mesh
  96166. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  96167. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  96168. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  96169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96172. * @param name defines the name of the mesh
  96173. * @param options defines the options used to create the mesh
  96174. * @param scene defines the hosting scene
  96175. * @returns the torus mesh
  96176. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  96177. */
  96178. static CreateTorus(name: string, options: {
  96179. diameter?: number;
  96180. thickness?: number;
  96181. tessellation?: number;
  96182. updatable?: boolean;
  96183. sideOrientation?: number;
  96184. frontUVs?: Vector4;
  96185. backUVs?: Vector4;
  96186. }, scene: any): Mesh;
  96187. }
  96188. }
  96189. declare module BABYLON {
  96190. /**
  96191. * Class containing static functions to help procedurally build meshes
  96192. */
  96193. export class CylinderBuilder {
  96194. /**
  96195. * Creates a cylinder or a cone mesh
  96196. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  96197. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  96198. * * 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.
  96199. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  96200. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  96201. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  96202. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  96203. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  96204. * * 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).
  96205. * * 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
  96206. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  96207. * * 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
  96208. * * 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.
  96209. * * If `enclose` is false, a ring surface is one element.
  96210. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  96211. * * 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
  96212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96215. * @param name defines the name of the mesh
  96216. * @param options defines the options used to create the mesh
  96217. * @param scene defines the hosting scene
  96218. * @returns the cylinder mesh
  96219. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  96220. */
  96221. static CreateCylinder(name: string, options: {
  96222. height?: number;
  96223. diameterTop?: number;
  96224. diameterBottom?: number;
  96225. diameter?: number;
  96226. tessellation?: number;
  96227. subdivisions?: number;
  96228. arc?: number;
  96229. faceColors?: Color4[];
  96230. faceUV?: Vector4[];
  96231. updatable?: boolean;
  96232. hasRings?: boolean;
  96233. enclose?: boolean;
  96234. sideOrientation?: number;
  96235. frontUVs?: Vector4;
  96236. backUVs?: Vector4;
  96237. }, scene: any): Mesh;
  96238. }
  96239. }
  96240. declare module BABYLON {
  96241. /**
  96242. * Manager for handling gamepads
  96243. */
  96244. export class GamepadManager {
  96245. private _scene?;
  96246. private _babylonGamepads;
  96247. private _oneGamepadConnected;
  96248. /** @hidden */
  96249. _isMonitoring: boolean;
  96250. private _gamepadEventSupported;
  96251. private _gamepadSupport;
  96252. /**
  96253. * observable to be triggered when the gamepad controller has been connected
  96254. */
  96255. onGamepadConnectedObservable: Observable<Gamepad>;
  96256. /**
  96257. * observable to be triggered when the gamepad controller has been disconnected
  96258. */
  96259. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96260. private _onGamepadConnectedEvent;
  96261. private _onGamepadDisconnectedEvent;
  96262. /**
  96263. * Initializes the gamepad manager
  96264. * @param _scene BabylonJS scene
  96265. */
  96266. constructor(_scene?: Scene | undefined);
  96267. /**
  96268. * The gamepads in the game pad manager
  96269. */
  96270. readonly gamepads: Gamepad[];
  96271. /**
  96272. * Get the gamepad controllers based on type
  96273. * @param type The type of gamepad controller
  96274. * @returns Nullable gamepad
  96275. */
  96276. getGamepadByType(type?: number): Nullable<Gamepad>;
  96277. /**
  96278. * Disposes the gamepad manager
  96279. */
  96280. dispose(): void;
  96281. private _addNewGamepad;
  96282. private _startMonitoringGamepads;
  96283. private _stopMonitoringGamepads;
  96284. /** @hidden */
  96285. _checkGamepadsStatus(): void;
  96286. private _updateGamepadObjects;
  96287. }
  96288. }
  96289. declare module BABYLON {
  96290. interface Scene {
  96291. /** @hidden */
  96292. _gamepadManager: Nullable<GamepadManager>;
  96293. /**
  96294. * Gets the gamepad manager associated with the scene
  96295. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96296. */
  96297. gamepadManager: GamepadManager;
  96298. }
  96299. /**
  96300. * Interface representing a free camera inputs manager
  96301. */
  96302. interface FreeCameraInputsManager {
  96303. /**
  96304. * Adds gamepad input support to the FreeCameraInputsManager.
  96305. * @returns the FreeCameraInputsManager
  96306. */
  96307. addGamepad(): FreeCameraInputsManager;
  96308. }
  96309. /**
  96310. * Interface representing an arc rotate camera inputs manager
  96311. */
  96312. interface ArcRotateCameraInputsManager {
  96313. /**
  96314. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96315. * @returns the camera inputs manager
  96316. */
  96317. addGamepad(): ArcRotateCameraInputsManager;
  96318. }
  96319. /**
  96320. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96321. */
  96322. export class GamepadSystemSceneComponent implements ISceneComponent {
  96323. /**
  96324. * The component name helpfull to identify the component in the list of scene components.
  96325. */
  96326. readonly name: string;
  96327. /**
  96328. * The scene the component belongs to.
  96329. */
  96330. scene: Scene;
  96331. /**
  96332. * Creates a new instance of the component for the given scene
  96333. * @param scene Defines the scene to register the component in
  96334. */
  96335. constructor(scene: Scene);
  96336. /**
  96337. * Registers the component in a given scene
  96338. */
  96339. register(): void;
  96340. /**
  96341. * Rebuilds the elements related to this component in case of
  96342. * context lost for instance.
  96343. */
  96344. rebuild(): void;
  96345. /**
  96346. * Disposes the component and the associated ressources
  96347. */
  96348. dispose(): void;
  96349. private _beforeCameraUpdate;
  96350. }
  96351. }
  96352. declare module BABYLON {
  96353. /**
  96354. * Options to modify the vr teleportation behavior.
  96355. */
  96356. export interface VRTeleportationOptions {
  96357. /**
  96358. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96359. */
  96360. floorMeshName?: string;
  96361. /**
  96362. * A list of meshes to be used as the teleportation floor. (default: empty)
  96363. */
  96364. floorMeshes?: Mesh[];
  96365. }
  96366. /**
  96367. * Options to modify the vr experience helper's behavior.
  96368. */
  96369. export interface VRExperienceHelperOptions extends WebVROptions {
  96370. /**
  96371. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96372. */
  96373. createDeviceOrientationCamera?: boolean;
  96374. /**
  96375. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96376. */
  96377. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96378. /**
  96379. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96380. */
  96381. laserToggle?: boolean;
  96382. /**
  96383. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96384. */
  96385. floorMeshes?: Mesh[];
  96386. /**
  96387. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96388. */
  96389. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96390. }
  96391. /**
  96392. * Event containing information after VR has been entered
  96393. */
  96394. export class OnAfterEnteringVRObservableEvent {
  96395. /**
  96396. * If entering vr was successful
  96397. */
  96398. success: boolean;
  96399. }
  96400. /**
  96401. * Helps to quickly add VR support to an existing scene.
  96402. * See http://doc.babylonjs.com/how_to/webvr_helper
  96403. */
  96404. export class VRExperienceHelper {
  96405. /** Options to modify the vr experience helper's behavior. */
  96406. webVROptions: VRExperienceHelperOptions;
  96407. private _scene;
  96408. private _position;
  96409. private _btnVR;
  96410. private _btnVRDisplayed;
  96411. private _webVRsupported;
  96412. private _webVRready;
  96413. private _webVRrequesting;
  96414. private _webVRpresenting;
  96415. private _hasEnteredVR;
  96416. private _fullscreenVRpresenting;
  96417. private _canvas;
  96418. private _webVRCamera;
  96419. private _vrDeviceOrientationCamera;
  96420. private _deviceOrientationCamera;
  96421. private _existingCamera;
  96422. private _onKeyDown;
  96423. private _onVrDisplayPresentChange;
  96424. private _onVRDisplayChanged;
  96425. private _onVRRequestPresentStart;
  96426. private _onVRRequestPresentComplete;
  96427. /**
  96428. * Observable raised right before entering VR.
  96429. */
  96430. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96431. /**
  96432. * Observable raised when entering VR has completed.
  96433. */
  96434. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96435. /**
  96436. * Observable raised when exiting VR.
  96437. */
  96438. onExitingVRObservable: Observable<VRExperienceHelper>;
  96439. /**
  96440. * Observable raised when controller mesh is loaded.
  96441. */
  96442. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96443. /** Return this.onEnteringVRObservable
  96444. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96445. */
  96446. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96447. /** Return this.onExitingVRObservable
  96448. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96449. */
  96450. readonly onExitingVR: Observable<VRExperienceHelper>;
  96451. /** Return this.onControllerMeshLoadedObservable
  96452. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96453. */
  96454. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96455. private _rayLength;
  96456. private _useCustomVRButton;
  96457. private _teleportationRequested;
  96458. private _teleportActive;
  96459. private _floorMeshName;
  96460. private _floorMeshesCollection;
  96461. private _rotationAllowed;
  96462. private _teleportBackwardsVector;
  96463. private _teleportationTarget;
  96464. private _isDefaultTeleportationTarget;
  96465. private _postProcessMove;
  96466. private _teleportationFillColor;
  96467. private _teleportationBorderColor;
  96468. private _rotationAngle;
  96469. private _haloCenter;
  96470. private _cameraGazer;
  96471. private _padSensibilityUp;
  96472. private _padSensibilityDown;
  96473. private _leftController;
  96474. private _rightController;
  96475. /**
  96476. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96477. */
  96478. onNewMeshSelected: Observable<AbstractMesh>;
  96479. /**
  96480. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96481. */
  96482. onNewMeshPicked: Observable<PickingInfo>;
  96483. private _circleEase;
  96484. /**
  96485. * Observable raised before camera teleportation
  96486. */
  96487. onBeforeCameraTeleport: Observable<Vector3>;
  96488. /**
  96489. * Observable raised after camera teleportation
  96490. */
  96491. onAfterCameraTeleport: Observable<Vector3>;
  96492. /**
  96493. * Observable raised when current selected mesh gets unselected
  96494. */
  96495. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96496. private _raySelectionPredicate;
  96497. /**
  96498. * To be optionaly changed by user to define custom ray selection
  96499. */
  96500. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96501. /**
  96502. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96503. */
  96504. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96505. /**
  96506. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96507. */
  96508. teleportationEnabled: boolean;
  96509. private _defaultHeight;
  96510. private _teleportationInitialized;
  96511. private _interactionsEnabled;
  96512. private _interactionsRequested;
  96513. private _displayGaze;
  96514. private _displayLaserPointer;
  96515. /**
  96516. * The mesh used to display where the user is going to teleport.
  96517. */
  96518. /**
  96519. * Sets the mesh to be used to display where the user is going to teleport.
  96520. */
  96521. teleportationTarget: Mesh;
  96522. /**
  96523. * 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
  96524. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96525. * See http://doc.babylonjs.com/resources/baking_transformations
  96526. */
  96527. gazeTrackerMesh: Mesh;
  96528. /**
  96529. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96530. */
  96531. updateGazeTrackerScale: boolean;
  96532. /**
  96533. * If the gaze trackers color should be updated when selecting meshes
  96534. */
  96535. updateGazeTrackerColor: boolean;
  96536. /**
  96537. * The gaze tracking mesh corresponding to the left controller
  96538. */
  96539. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96540. /**
  96541. * The gaze tracking mesh corresponding to the right controller
  96542. */
  96543. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96544. /**
  96545. * If the ray of the gaze should be displayed.
  96546. */
  96547. /**
  96548. * Sets if the ray of the gaze should be displayed.
  96549. */
  96550. displayGaze: boolean;
  96551. /**
  96552. * If the ray of the LaserPointer should be displayed.
  96553. */
  96554. /**
  96555. * Sets if the ray of the LaserPointer should be displayed.
  96556. */
  96557. displayLaserPointer: boolean;
  96558. /**
  96559. * The deviceOrientationCamera used as the camera when not in VR.
  96560. */
  96561. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96562. /**
  96563. * Based on the current WebVR support, returns the current VR camera used.
  96564. */
  96565. readonly currentVRCamera: Nullable<Camera>;
  96566. /**
  96567. * The webVRCamera which is used when in VR.
  96568. */
  96569. readonly webVRCamera: WebVRFreeCamera;
  96570. /**
  96571. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96572. */
  96573. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96574. private readonly _teleportationRequestInitiated;
  96575. /**
  96576. * Defines wether or not Pointer lock should be requested when switching to
  96577. * full screen.
  96578. */
  96579. requestPointerLockOnFullScreen: boolean;
  96580. /**
  96581. * Instantiates a VRExperienceHelper.
  96582. * Helps to quickly add VR support to an existing scene.
  96583. * @param scene The scene the VRExperienceHelper belongs to.
  96584. * @param webVROptions Options to modify the vr experience helper's behavior.
  96585. */
  96586. constructor(scene: Scene,
  96587. /** Options to modify the vr experience helper's behavior. */
  96588. webVROptions?: VRExperienceHelperOptions);
  96589. private _onDefaultMeshLoaded;
  96590. private _onResize;
  96591. private _onFullscreenChange;
  96592. /**
  96593. * Gets a value indicating if we are currently in VR mode.
  96594. */
  96595. readonly isInVRMode: boolean;
  96596. private onVrDisplayPresentChange;
  96597. private onVRDisplayChanged;
  96598. private moveButtonToBottomRight;
  96599. private displayVRButton;
  96600. private updateButtonVisibility;
  96601. private _cachedAngularSensibility;
  96602. /**
  96603. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96604. * Otherwise, will use the fullscreen API.
  96605. */
  96606. enterVR(): void;
  96607. /**
  96608. * Attempt to exit VR, or fullscreen.
  96609. */
  96610. exitVR(): void;
  96611. /**
  96612. * The position of the vr experience helper.
  96613. */
  96614. /**
  96615. * Sets the position of the vr experience helper.
  96616. */
  96617. position: Vector3;
  96618. /**
  96619. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96620. */
  96621. enableInteractions(): void;
  96622. private readonly _noControllerIsActive;
  96623. private beforeRender;
  96624. private _isTeleportationFloor;
  96625. /**
  96626. * Adds a floor mesh to be used for teleportation.
  96627. * @param floorMesh the mesh to be used for teleportation.
  96628. */
  96629. addFloorMesh(floorMesh: Mesh): void;
  96630. /**
  96631. * Removes a floor mesh from being used for teleportation.
  96632. * @param floorMesh the mesh to be removed.
  96633. */
  96634. removeFloorMesh(floorMesh: Mesh): void;
  96635. /**
  96636. * Enables interactions and teleportation using the VR controllers and gaze.
  96637. * @param vrTeleportationOptions options to modify teleportation behavior.
  96638. */
  96639. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96640. private _onNewGamepadConnected;
  96641. private _tryEnableInteractionOnController;
  96642. private _onNewGamepadDisconnected;
  96643. private _enableInteractionOnController;
  96644. private _checkTeleportWithRay;
  96645. private _checkRotate;
  96646. private _checkTeleportBackwards;
  96647. private _enableTeleportationOnController;
  96648. private _createTeleportationCircles;
  96649. private _displayTeleportationTarget;
  96650. private _hideTeleportationTarget;
  96651. private _rotateCamera;
  96652. private _moveTeleportationSelectorTo;
  96653. private _workingVector;
  96654. private _workingQuaternion;
  96655. private _workingMatrix;
  96656. /**
  96657. * Teleports the users feet to the desired location
  96658. * @param location The location where the user's feet should be placed
  96659. */
  96660. teleportCamera(location: Vector3): void;
  96661. private _convertNormalToDirectionOfRay;
  96662. private _castRayAndSelectObject;
  96663. private _notifySelectedMeshUnselected;
  96664. /**
  96665. * Sets the color of the laser ray from the vr controllers.
  96666. * @param color new color for the ray.
  96667. */
  96668. changeLaserColor(color: Color3): void;
  96669. /**
  96670. * Sets the color of the ray from the vr headsets gaze.
  96671. * @param color new color for the ray.
  96672. */
  96673. changeGazeColor(color: Color3): void;
  96674. /**
  96675. * Exits VR and disposes of the vr experience helper
  96676. */
  96677. dispose(): void;
  96678. /**
  96679. * Gets the name of the VRExperienceHelper class
  96680. * @returns "VRExperienceHelper"
  96681. */
  96682. getClassName(): string;
  96683. }
  96684. }
  96685. declare module BABYLON {
  96686. /**
  96687. * Manages an XRSession
  96688. * @see https://doc.babylonjs.com/how_to/webxr
  96689. */
  96690. export class WebXRSessionManager implements IDisposable {
  96691. private scene;
  96692. /**
  96693. * Fires every time a new xrFrame arrives which can be used to update the camera
  96694. */
  96695. onXRFrameObservable: Observable<any>;
  96696. /**
  96697. * Fires when the xr session is ended either by the device or manually done
  96698. */
  96699. onXRSessionEnded: Observable<any>;
  96700. /** @hidden */
  96701. _xrSession: XRSession;
  96702. /** @hidden */
  96703. _frameOfReference: XRFrameOfReference;
  96704. /** @hidden */
  96705. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96706. /** @hidden */
  96707. _currentXRFrame: Nullable<XRFrame>;
  96708. private _xrNavigator;
  96709. private _xrDevice;
  96710. private _tmpMatrix;
  96711. /**
  96712. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96713. * @param scene The scene which the session should be created for
  96714. */
  96715. constructor(scene: Scene);
  96716. /**
  96717. * Initializes the manager
  96718. * After initialization enterXR can be called to start an XR session
  96719. * @returns Promise which resolves after it is initialized
  96720. */
  96721. initializeAsync(): Promise<void>;
  96722. /**
  96723. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96724. * @param sessionCreationOptions xr options to create the session with
  96725. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96726. * @returns Promise which resolves after it enters XR
  96727. */
  96728. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96729. /**
  96730. * Stops the xrSession and restores the renderloop
  96731. * @returns Promise which resolves after it exits XR
  96732. */
  96733. exitXRAsync(): Promise<void>;
  96734. /**
  96735. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96736. * @param ray ray to cast into the environment
  96737. * @returns Promise which resolves with a collision point in the environment if it exists
  96738. */
  96739. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96740. /**
  96741. * Checks if a session would be supported for the creation options specified
  96742. * @param options creation options to check if they are supported
  96743. * @returns true if supported
  96744. */
  96745. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96746. /**
  96747. * @hidden
  96748. * Converts the render layer of xrSession to a render target
  96749. * @param session session to create render target for
  96750. * @param scene scene the new render target should be created for
  96751. */
  96752. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96753. /**
  96754. * Disposes of the session manager
  96755. */
  96756. dispose(): void;
  96757. }
  96758. }
  96759. declare module BABYLON {
  96760. /**
  96761. * WebXR Camera which holds the views for the xrSession
  96762. * @see https://doc.babylonjs.com/how_to/webxr
  96763. */
  96764. export class WebXRCamera extends FreeCamera {
  96765. private static _TmpMatrix;
  96766. /**
  96767. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96768. * @param name the name of the camera
  96769. * @param scene the scene to add the camera to
  96770. */
  96771. constructor(name: string, scene: Scene);
  96772. private _updateNumberOfRigCameras;
  96773. /** @hidden */
  96774. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96775. /**
  96776. * Updates the cameras position from the current pose information of the XR session
  96777. * @param xrSessionManager the session containing pose information
  96778. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96779. */
  96780. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96781. }
  96782. }
  96783. declare module BABYLON {
  96784. /**
  96785. * States of the webXR experience
  96786. */
  96787. export enum WebXRState {
  96788. /**
  96789. * Transitioning to being in XR mode
  96790. */
  96791. ENTERING_XR = 0,
  96792. /**
  96793. * Transitioning to non XR mode
  96794. */
  96795. EXITING_XR = 1,
  96796. /**
  96797. * In XR mode and presenting
  96798. */
  96799. IN_XR = 2,
  96800. /**
  96801. * Not entered XR mode
  96802. */
  96803. NOT_IN_XR = 3
  96804. }
  96805. /**
  96806. * Helper class used to enable XR
  96807. * @see https://doc.babylonjs.com/how_to/webxr
  96808. */
  96809. export class WebXRExperienceHelper implements IDisposable {
  96810. private scene;
  96811. /**
  96812. * 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
  96813. */
  96814. container: AbstractMesh;
  96815. /**
  96816. * Camera used to render xr content
  96817. */
  96818. camera: WebXRCamera;
  96819. /**
  96820. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96821. */
  96822. state: WebXRState;
  96823. private _setState;
  96824. private static _TmpVector;
  96825. /**
  96826. * Fires when the state of the experience helper has changed
  96827. */
  96828. onStateChangedObservable: Observable<WebXRState>;
  96829. /** @hidden */
  96830. _sessionManager: WebXRSessionManager;
  96831. private _nonVRCamera;
  96832. private _originalSceneAutoClear;
  96833. private _supported;
  96834. /**
  96835. * Creates the experience helper
  96836. * @param scene the scene to attach the experience helper to
  96837. * @returns a promise for the experience helper
  96838. */
  96839. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96840. /**
  96841. * Creates a WebXRExperienceHelper
  96842. * @param scene The scene the helper should be created in
  96843. */
  96844. private constructor();
  96845. /**
  96846. * Exits XR mode and returns the scene to its original state
  96847. * @returns promise that resolves after xr mode has exited
  96848. */
  96849. exitXRAsync(): Promise<void>;
  96850. /**
  96851. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96852. * @param sessionCreationOptions options for the XR session
  96853. * @param frameOfReference frame of reference of the XR session
  96854. * @returns promise that resolves after xr mode has entered
  96855. */
  96856. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96857. /**
  96858. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96859. * @param ray ray to cast into the environment
  96860. * @returns Promise which resolves with a collision point in the environment if it exists
  96861. */
  96862. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96863. /**
  96864. * Updates the global position of the camera by moving the camera's container
  96865. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96866. * @param position The desired global position of the camera
  96867. */
  96868. setPositionOfCameraUsingContainer(position: Vector3): void;
  96869. /**
  96870. * Rotates the xr camera by rotating the camera's container around the camera's position
  96871. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96872. * @param rotation the desired quaternion rotation to apply to the camera
  96873. */
  96874. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96875. /**
  96876. * Checks if the creation options are supported by the xr session
  96877. * @param options creation options
  96878. * @returns true if supported
  96879. */
  96880. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96881. /**
  96882. * Disposes of the experience helper
  96883. */
  96884. dispose(): void;
  96885. }
  96886. }
  96887. declare module BABYLON {
  96888. /**
  96889. * Button which can be used to enter a different mode of XR
  96890. */
  96891. export class WebXREnterExitUIButton {
  96892. /** button element */
  96893. element: HTMLElement;
  96894. /** XR initialization options for the button */
  96895. initializationOptions: XRSessionCreationOptions;
  96896. /**
  96897. * Creates a WebXREnterExitUIButton
  96898. * @param element button element
  96899. * @param initializationOptions XR initialization options for the button
  96900. */
  96901. constructor(
  96902. /** button element */
  96903. element: HTMLElement,
  96904. /** XR initialization options for the button */
  96905. initializationOptions: XRSessionCreationOptions);
  96906. /**
  96907. * Overwritable function which can be used to update the button's visuals when the state changes
  96908. * @param activeButton the current active button in the UI
  96909. */
  96910. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96911. }
  96912. /**
  96913. * Options to create the webXR UI
  96914. */
  96915. export class WebXREnterExitUIOptions {
  96916. /**
  96917. * Context to enter xr with
  96918. */
  96919. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96920. /**
  96921. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96922. */
  96923. customButtons?: Array<WebXREnterExitUIButton>;
  96924. }
  96925. /**
  96926. * UI to allow the user to enter/exit XR mode
  96927. */
  96928. export class WebXREnterExitUI implements IDisposable {
  96929. private scene;
  96930. private _overlay;
  96931. private _buttons;
  96932. private _activeButton;
  96933. /**
  96934. * Fired every time the active button is changed.
  96935. *
  96936. * When xr is entered via a button that launches xr that button will be the callback parameter
  96937. *
  96938. * When exiting xr the callback parameter will be null)
  96939. */
  96940. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96941. /**
  96942. * Creates UI to allow the user to enter/exit XR mode
  96943. * @param scene the scene to add the ui to
  96944. * @param helper the xr experience helper to enter/exit xr with
  96945. * @param options options to configure the UI
  96946. * @returns the created ui
  96947. */
  96948. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  96949. private constructor();
  96950. private _updateButtons;
  96951. /**
  96952. * Disposes of the object
  96953. */
  96954. dispose(): void;
  96955. }
  96956. }
  96957. declare module BABYLON {
  96958. /**
  96959. * Represents an XR input
  96960. */
  96961. export class WebXRController {
  96962. /**
  96963. * 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
  96964. */
  96965. grip?: AbstractMesh;
  96966. /**
  96967. * Pointer which can be used to select objects or attach a visible laser to
  96968. */
  96969. pointer: AbstractMesh;
  96970. /**
  96971. * Creates the controller
  96972. * @see https://doc.babylonjs.com/how_to/webxr
  96973. * @param scene the scene which the controller should be associated to
  96974. */
  96975. constructor(scene: Scene);
  96976. /**
  96977. * Disposes of the object
  96978. */
  96979. dispose(): void;
  96980. }
  96981. /**
  96982. * XR input used to track XR inputs such as controllers/rays
  96983. */
  96984. export class WebXRInput implements IDisposable {
  96985. private helper;
  96986. /**
  96987. * XR controllers being tracked
  96988. */
  96989. controllers: Array<WebXRController>;
  96990. private _tmpMatrix;
  96991. private _frameObserver;
  96992. /**
  96993. * Initializes the WebXRInput
  96994. * @param helper experience helper which the input should be created for
  96995. */
  96996. constructor(helper: WebXRExperienceHelper);
  96997. /**
  96998. * Disposes of the object
  96999. */
  97000. dispose(): void;
  97001. }
  97002. }
  97003. declare module BABYLON {
  97004. /**
  97005. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  97006. */
  97007. export class WebXRManagedOutputCanvas implements IDisposable {
  97008. private _canvas;
  97009. /**
  97010. * xrpresent context of the canvas which can be used to display/mirror xr content
  97011. */
  97012. canvasContext: Nullable<WebGLRenderingContext>;
  97013. /**
  97014. * Initializes the canvas to be added/removed upon entering/exiting xr
  97015. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  97016. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  97017. */
  97018. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  97019. /**
  97020. * Disposes of the object
  97021. */
  97022. dispose(): void;
  97023. private _setManagedOutputCanvas;
  97024. private _addCanvas;
  97025. private _removeCanvas;
  97026. }
  97027. }
  97028. declare module BABYLON {
  97029. /**
  97030. * Contains an array of blocks representing the octree
  97031. */
  97032. export interface IOctreeContainer<T> {
  97033. /**
  97034. * Blocks within the octree
  97035. */
  97036. blocks: Array<OctreeBlock<T>>;
  97037. }
  97038. /**
  97039. * Class used to store a cell in an octree
  97040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97041. */
  97042. export class OctreeBlock<T> {
  97043. /**
  97044. * Gets the content of the current block
  97045. */
  97046. entries: T[];
  97047. /**
  97048. * Gets the list of block children
  97049. */
  97050. blocks: Array<OctreeBlock<T>>;
  97051. private _depth;
  97052. private _maxDepth;
  97053. private _capacity;
  97054. private _minPoint;
  97055. private _maxPoint;
  97056. private _boundingVectors;
  97057. private _creationFunc;
  97058. /**
  97059. * Creates a new block
  97060. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  97061. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  97062. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97063. * @param depth defines the current depth of this block in the octree
  97064. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  97065. * @param creationFunc defines a callback to call when an element is added to the block
  97066. */
  97067. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  97068. /**
  97069. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97070. */
  97071. readonly capacity: number;
  97072. /**
  97073. * Gets the minimum vector (in world space) of the block's bounding box
  97074. */
  97075. readonly minPoint: Vector3;
  97076. /**
  97077. * Gets the maximum vector (in world space) of the block's bounding box
  97078. */
  97079. readonly maxPoint: Vector3;
  97080. /**
  97081. * Add a new element to this block
  97082. * @param entry defines the element to add
  97083. */
  97084. addEntry(entry: T): void;
  97085. /**
  97086. * Remove an element from this block
  97087. * @param entry defines the element to remove
  97088. */
  97089. removeEntry(entry: T): void;
  97090. /**
  97091. * Add an array of elements to this block
  97092. * @param entries defines the array of elements to add
  97093. */
  97094. addEntries(entries: T[]): void;
  97095. /**
  97096. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  97097. * @param frustumPlanes defines the frustum planes to test
  97098. * @param selection defines the array to store current content if selection is positive
  97099. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97100. */
  97101. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97102. /**
  97103. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  97104. * @param sphereCenter defines the bounding sphere center
  97105. * @param sphereRadius defines the bounding sphere radius
  97106. * @param selection defines the array to store current content if selection is positive
  97107. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97108. */
  97109. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97110. /**
  97111. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  97112. * @param ray defines the ray to test with
  97113. * @param selection defines the array to store current content if selection is positive
  97114. */
  97115. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  97116. /**
  97117. * Subdivide the content into child blocks (this block will then be empty)
  97118. */
  97119. createInnerBlocks(): void;
  97120. /**
  97121. * @hidden
  97122. */
  97123. 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;
  97124. }
  97125. }
  97126. declare module BABYLON {
  97127. /**
  97128. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  97129. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97130. */
  97131. export class Octree<T> {
  97132. /** 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.) */
  97133. maxDepth: number;
  97134. /**
  97135. * Blocks within the octree containing objects
  97136. */
  97137. blocks: Array<OctreeBlock<T>>;
  97138. /**
  97139. * Content stored in the octree
  97140. */
  97141. dynamicContent: T[];
  97142. private _maxBlockCapacity;
  97143. private _selectionContent;
  97144. private _creationFunc;
  97145. /**
  97146. * Creates a octree
  97147. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97148. * @param creationFunc function to be used to instatiate the octree
  97149. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  97150. * @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.)
  97151. */
  97152. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  97153. /** 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.) */
  97154. maxDepth?: number);
  97155. /**
  97156. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  97157. * @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);
  97158. * @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);
  97159. * @param entries meshes to be added to the octree blocks
  97160. */
  97161. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  97162. /**
  97163. * Adds a mesh to the octree
  97164. * @param entry Mesh to add to the octree
  97165. */
  97166. addMesh(entry: T): void;
  97167. /**
  97168. * Remove an element from the octree
  97169. * @param entry defines the element to remove
  97170. */
  97171. removeMesh(entry: T): void;
  97172. /**
  97173. * Selects an array of meshes within the frustum
  97174. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  97175. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  97176. * @returns array of meshes within the frustum
  97177. */
  97178. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  97179. /**
  97180. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  97181. * @param sphereCenter defines the bounding sphere center
  97182. * @param sphereRadius defines the bounding sphere radius
  97183. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97184. * @returns an array of objects that intersect the sphere
  97185. */
  97186. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  97187. /**
  97188. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  97189. * @param ray defines the ray to test with
  97190. * @returns array of intersected objects
  97191. */
  97192. intersectsRay(ray: Ray): SmartArray<T>;
  97193. /**
  97194. * Adds a mesh into the octree block if it intersects the block
  97195. */
  97196. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  97197. /**
  97198. * Adds a submesh into the octree block if it intersects the block
  97199. */
  97200. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  97201. }
  97202. }
  97203. declare module BABYLON {
  97204. interface Scene {
  97205. /**
  97206. * @hidden
  97207. * Backing Filed
  97208. */
  97209. _selectionOctree: Octree<AbstractMesh>;
  97210. /**
  97211. * Gets the octree used to boost mesh selection (picking)
  97212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97213. */
  97214. selectionOctree: Octree<AbstractMesh>;
  97215. /**
  97216. * Creates or updates the octree used to boost selection (picking)
  97217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97218. * @param maxCapacity defines the maximum capacity per leaf
  97219. * @param maxDepth defines the maximum depth of the octree
  97220. * @returns an octree of AbstractMesh
  97221. */
  97222. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  97223. }
  97224. interface AbstractMesh {
  97225. /**
  97226. * @hidden
  97227. * Backing Field
  97228. */
  97229. _submeshesOctree: Octree<SubMesh>;
  97230. /**
  97231. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97232. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97233. * @param maxCapacity defines the maximum size of each block (64 by default)
  97234. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97235. * @returns the new octree
  97236. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97238. */
  97239. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97240. }
  97241. /**
  97242. * Defines the octree scene component responsible to manage any octrees
  97243. * in a given scene.
  97244. */
  97245. export class OctreeSceneComponent {
  97246. /**
  97247. * The component name helpfull to identify the component in the list of scene components.
  97248. */
  97249. readonly name: string;
  97250. /**
  97251. * The scene the component belongs to.
  97252. */
  97253. scene: Scene;
  97254. /**
  97255. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97256. */
  97257. readonly checksIsEnabled: boolean;
  97258. /**
  97259. * Creates a new instance of the component for the given scene
  97260. * @param scene Defines the scene to register the component in
  97261. */
  97262. constructor(scene: Scene);
  97263. /**
  97264. * Registers the component in a given scene
  97265. */
  97266. register(): void;
  97267. /**
  97268. * Return the list of active meshes
  97269. * @returns the list of active meshes
  97270. */
  97271. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97272. /**
  97273. * Return the list of active sub meshes
  97274. * @param mesh The mesh to get the candidates sub meshes from
  97275. * @returns the list of active sub meshes
  97276. */
  97277. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97278. private _tempRay;
  97279. /**
  97280. * Return the list of sub meshes intersecting with a given local ray
  97281. * @param mesh defines the mesh to find the submesh for
  97282. * @param localRay defines the ray in local space
  97283. * @returns the list of intersecting sub meshes
  97284. */
  97285. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97286. /**
  97287. * Return the list of sub meshes colliding with a collider
  97288. * @param mesh defines the mesh to find the submesh for
  97289. * @param collider defines the collider to evaluate the collision against
  97290. * @returns the list of colliding sub meshes
  97291. */
  97292. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97293. /**
  97294. * Rebuilds the elements related to this component in case of
  97295. * context lost for instance.
  97296. */
  97297. rebuild(): void;
  97298. /**
  97299. * Disposes the component and the associated ressources.
  97300. */
  97301. dispose(): void;
  97302. }
  97303. }
  97304. declare module BABYLON {
  97305. /**
  97306. * Class containing static functions to help procedurally build meshes
  97307. */
  97308. export class LinesBuilder {
  97309. /**
  97310. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97311. * * 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
  97312. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97313. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97314. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97315. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97316. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97317. * * 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
  97318. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97321. * @param name defines the name of the new line system
  97322. * @param options defines the options used to create the line system
  97323. * @param scene defines the hosting scene
  97324. * @returns a new line system mesh
  97325. */
  97326. static CreateLineSystem(name: string, options: {
  97327. lines: Vector3[][];
  97328. updatable?: boolean;
  97329. instance?: Nullable<LinesMesh>;
  97330. colors?: Nullable<Color4[][]>;
  97331. useVertexAlpha?: boolean;
  97332. }, scene: Nullable<Scene>): LinesMesh;
  97333. /**
  97334. * Creates a line mesh
  97335. * 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
  97336. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97337. * * The parameter `points` is an array successive Vector3
  97338. * * 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
  97339. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97340. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97341. * * When updating an instance, remember that only point positions can change, not the number of points
  97342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97344. * @param name defines the name of the new line system
  97345. * @param options defines the options used to create the line system
  97346. * @param scene defines the hosting scene
  97347. * @returns a new line mesh
  97348. */
  97349. static CreateLines(name: string, options: {
  97350. points: Vector3[];
  97351. updatable?: boolean;
  97352. instance?: Nullable<LinesMesh>;
  97353. colors?: Color4[];
  97354. useVertexAlpha?: boolean;
  97355. }, scene?: Nullable<Scene>): LinesMesh;
  97356. /**
  97357. * Creates a dashed line mesh
  97358. * * 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
  97359. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97360. * * The parameter `points` is an array successive Vector3
  97361. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97362. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97363. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97364. * * 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
  97365. * * When updating an instance, remember that only point positions can change, not the number of points
  97366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97367. * @param name defines the name of the mesh
  97368. * @param options defines the options used to create the mesh
  97369. * @param scene defines the hosting scene
  97370. * @returns the dashed line mesh
  97371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97372. */
  97373. static CreateDashedLines(name: string, options: {
  97374. points: Vector3[];
  97375. dashSize?: number;
  97376. gapSize?: number;
  97377. dashNb?: number;
  97378. updatable?: boolean;
  97379. instance?: LinesMesh;
  97380. }, scene?: Nullable<Scene>): LinesMesh;
  97381. }
  97382. }
  97383. declare module BABYLON {
  97384. /**
  97385. * Renders a layer on top of an existing scene
  97386. */
  97387. export class UtilityLayerRenderer implements IDisposable {
  97388. /** the original scene that will be rendered on top of */
  97389. originalScene: Scene;
  97390. private _pointerCaptures;
  97391. private _lastPointerEvents;
  97392. private static _DefaultUtilityLayer;
  97393. private static _DefaultKeepDepthUtilityLayer;
  97394. /**
  97395. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97396. */
  97397. pickUtilitySceneFirst: boolean;
  97398. /**
  97399. * 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)
  97400. */
  97401. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97402. /**
  97403. * 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)
  97404. */
  97405. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97406. /**
  97407. * The scene that is rendered on top of the original scene
  97408. */
  97409. utilityLayerScene: Scene;
  97410. /**
  97411. * If the utility layer should automatically be rendered on top of existing scene
  97412. */
  97413. shouldRender: boolean;
  97414. /**
  97415. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97416. */
  97417. onlyCheckPointerDownEvents: boolean;
  97418. /**
  97419. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97420. */
  97421. processAllEvents: boolean;
  97422. /**
  97423. * Observable raised when the pointer move from the utility layer scene to the main scene
  97424. */
  97425. onPointerOutObservable: Observable<number>;
  97426. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97427. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97428. private _afterRenderObserver;
  97429. private _sceneDisposeObserver;
  97430. private _originalPointerObserver;
  97431. /**
  97432. * Instantiates a UtilityLayerRenderer
  97433. * @param originalScene the original scene that will be rendered on top of
  97434. * @param handleEvents boolean indicating if the utility layer should handle events
  97435. */
  97436. constructor(
  97437. /** the original scene that will be rendered on top of */
  97438. originalScene: Scene, handleEvents?: boolean);
  97439. private _notifyObservers;
  97440. /**
  97441. * Renders the utility layers scene on top of the original scene
  97442. */
  97443. render(): void;
  97444. /**
  97445. * Disposes of the renderer
  97446. */
  97447. dispose(): void;
  97448. private _updateCamera;
  97449. }
  97450. }
  97451. declare module BABYLON {
  97452. /**
  97453. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97454. */
  97455. export class Gizmo implements IDisposable {
  97456. /** The utility layer the gizmo will be added to */
  97457. gizmoLayer: UtilityLayerRenderer;
  97458. /**
  97459. * The root mesh of the gizmo
  97460. */
  97461. _rootMesh: Mesh;
  97462. private _attachedMesh;
  97463. /**
  97464. * Ratio for the scale of the gizmo (Default: 1)
  97465. */
  97466. scaleRatio: number;
  97467. private _tmpMatrix;
  97468. /**
  97469. * If a custom mesh has been set (Default: false)
  97470. */
  97471. protected _customMeshSet: boolean;
  97472. /**
  97473. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97474. * * When set, interactions will be enabled
  97475. */
  97476. attachedMesh: Nullable<AbstractMesh>;
  97477. /**
  97478. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97479. * @param mesh The mesh to replace the default mesh of the gizmo
  97480. */
  97481. setCustomMesh(mesh: Mesh): void;
  97482. /**
  97483. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97484. */
  97485. updateGizmoRotationToMatchAttachedMesh: boolean;
  97486. /**
  97487. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97488. */
  97489. updateGizmoPositionToMatchAttachedMesh: boolean;
  97490. /**
  97491. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97492. */
  97493. protected _updateScale: boolean;
  97494. protected _interactionsEnabled: boolean;
  97495. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97496. private _beforeRenderObserver;
  97497. /**
  97498. * Creates a gizmo
  97499. * @param gizmoLayer The utility layer the gizmo will be added to
  97500. */
  97501. constructor(
  97502. /** The utility layer the gizmo will be added to */
  97503. gizmoLayer?: UtilityLayerRenderer);
  97504. private _tempVector;
  97505. /**
  97506. * @hidden
  97507. * Updates the gizmo to match the attached mesh's position/rotation
  97508. */
  97509. protected _update(): void;
  97510. /**
  97511. * Disposes of the gizmo
  97512. */
  97513. dispose(): void;
  97514. }
  97515. }
  97516. declare module BABYLON {
  97517. /**
  97518. * Single axis drag gizmo
  97519. */
  97520. export class AxisDragGizmo extends Gizmo {
  97521. /**
  97522. * Drag behavior responsible for the gizmos dragging interactions
  97523. */
  97524. dragBehavior: PointerDragBehavior;
  97525. private _pointerObserver;
  97526. /**
  97527. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97528. */
  97529. snapDistance: number;
  97530. /**
  97531. * Event that fires each time the gizmo snaps to a new location.
  97532. * * snapDistance is the the change in distance
  97533. */
  97534. onSnapObservable: Observable<{
  97535. snapDistance: number;
  97536. }>;
  97537. /** @hidden */
  97538. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97539. /** @hidden */
  97540. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97541. /**
  97542. * Creates an AxisDragGizmo
  97543. * @param gizmoLayer The utility layer the gizmo will be added to
  97544. * @param dragAxis The axis which the gizmo will be able to drag on
  97545. * @param color The color of the gizmo
  97546. */
  97547. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97548. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97549. /**
  97550. * Disposes of the gizmo
  97551. */
  97552. dispose(): void;
  97553. }
  97554. }
  97555. declare module BABYLON.Debug {
  97556. /**
  97557. * The Axes viewer will show 3 axes in a specific point in space
  97558. */
  97559. export class AxesViewer {
  97560. private _xAxis;
  97561. private _yAxis;
  97562. private _zAxis;
  97563. private _scaleLinesFactor;
  97564. private _instanced;
  97565. /**
  97566. * Gets the hosting scene
  97567. */
  97568. scene: Scene;
  97569. /**
  97570. * Gets or sets a number used to scale line length
  97571. */
  97572. scaleLines: number;
  97573. /** Gets the node hierarchy used to render x-axis */
  97574. readonly xAxis: TransformNode;
  97575. /** Gets the node hierarchy used to render y-axis */
  97576. readonly yAxis: TransformNode;
  97577. /** Gets the node hierarchy used to render z-axis */
  97578. readonly zAxis: TransformNode;
  97579. /**
  97580. * Creates a new AxesViewer
  97581. * @param scene defines the hosting scene
  97582. * @param scaleLines defines a number used to scale line length (1 by default)
  97583. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97584. * @param xAxis defines the node hierarchy used to render the x-axis
  97585. * @param yAxis defines the node hierarchy used to render the y-axis
  97586. * @param zAxis defines the node hierarchy used to render the z-axis
  97587. */
  97588. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97589. /**
  97590. * Force the viewer to update
  97591. * @param position defines the position of the viewer
  97592. * @param xaxis defines the x axis of the viewer
  97593. * @param yaxis defines the y axis of the viewer
  97594. * @param zaxis defines the z axis of the viewer
  97595. */
  97596. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97597. /**
  97598. * Creates an instance of this axes viewer.
  97599. * @returns a new axes viewer with instanced meshes
  97600. */
  97601. createInstance(): AxesViewer;
  97602. /** Releases resources */
  97603. dispose(): void;
  97604. private static _SetRenderingGroupId;
  97605. }
  97606. }
  97607. declare module BABYLON.Debug {
  97608. /**
  97609. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97610. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97611. */
  97612. export class BoneAxesViewer extends AxesViewer {
  97613. /**
  97614. * Gets or sets the target mesh where to display the axes viewer
  97615. */
  97616. mesh: Nullable<Mesh>;
  97617. /**
  97618. * Gets or sets the target bone where to display the axes viewer
  97619. */
  97620. bone: Nullable<Bone>;
  97621. /** Gets current position */
  97622. pos: Vector3;
  97623. /** Gets direction of X axis */
  97624. xaxis: Vector3;
  97625. /** Gets direction of Y axis */
  97626. yaxis: Vector3;
  97627. /** Gets direction of Z axis */
  97628. zaxis: Vector3;
  97629. /**
  97630. * Creates a new BoneAxesViewer
  97631. * @param scene defines the hosting scene
  97632. * @param bone defines the target bone
  97633. * @param mesh defines the target mesh
  97634. * @param scaleLines defines a scaling factor for line length (1 by default)
  97635. */
  97636. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97637. /**
  97638. * Force the viewer to update
  97639. */
  97640. update(): void;
  97641. /** Releases resources */
  97642. dispose(): void;
  97643. }
  97644. }
  97645. declare module BABYLON {
  97646. /**
  97647. * Interface used to define scene explorer extensibility option
  97648. */
  97649. export interface IExplorerExtensibilityOption {
  97650. /**
  97651. * Define the option label
  97652. */
  97653. label: string;
  97654. /**
  97655. * Defines the action to execute on click
  97656. */
  97657. action: (entity: any) => void;
  97658. }
  97659. /**
  97660. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97661. */
  97662. export interface IExplorerExtensibilityGroup {
  97663. /**
  97664. * Defines a predicate to test if a given type mut be extended
  97665. */
  97666. predicate: (entity: any) => boolean;
  97667. /**
  97668. * Gets the list of options added to a type
  97669. */
  97670. entries: IExplorerExtensibilityOption[];
  97671. }
  97672. /**
  97673. * Interface used to define the options to use to create the Inspector
  97674. */
  97675. export interface IInspectorOptions {
  97676. /**
  97677. * Display in overlay mode (default: false)
  97678. */
  97679. overlay?: boolean;
  97680. /**
  97681. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97682. */
  97683. globalRoot?: HTMLElement;
  97684. /**
  97685. * Display the Scene explorer
  97686. */
  97687. showExplorer?: boolean;
  97688. /**
  97689. * Display the property inspector
  97690. */
  97691. showInspector?: boolean;
  97692. /**
  97693. * Display in embed mode (both panes on the right)
  97694. */
  97695. embedMode?: boolean;
  97696. /**
  97697. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97698. */
  97699. handleResize?: boolean;
  97700. /**
  97701. * Allow the panes to popup (default: true)
  97702. */
  97703. enablePopup?: boolean;
  97704. /**
  97705. * Allow the panes to be closed by users (default: true)
  97706. */
  97707. enableClose?: boolean;
  97708. /**
  97709. * Optional list of extensibility entries
  97710. */
  97711. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97712. /**
  97713. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97714. */
  97715. inspectorURL?: string;
  97716. }
  97717. interface Scene {
  97718. /**
  97719. * @hidden
  97720. * Backing field
  97721. */
  97722. _debugLayer: DebugLayer;
  97723. /**
  97724. * Gets the debug layer (aka Inspector) associated with the scene
  97725. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97726. */
  97727. debugLayer: DebugLayer;
  97728. }
  97729. /**
  97730. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97731. * what is happening in your scene
  97732. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97733. */
  97734. export class DebugLayer {
  97735. /**
  97736. * Define the url to get the inspector script from.
  97737. * By default it uses the babylonjs CDN.
  97738. * @ignoreNaming
  97739. */
  97740. static InspectorURL: string;
  97741. private _scene;
  97742. private BJSINSPECTOR;
  97743. /**
  97744. * Observable triggered when a property is changed through the inspector.
  97745. */
  97746. onPropertyChangedObservable: Observable<{
  97747. object: any;
  97748. property: string;
  97749. value: any;
  97750. initialValue: any;
  97751. }>;
  97752. /**
  97753. * Instantiates a new debug layer.
  97754. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97755. * what is happening in your scene
  97756. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97757. * @param scene Defines the scene to inspect
  97758. */
  97759. constructor(scene: Scene);
  97760. /** Creates the inspector window. */
  97761. private _createInspector;
  97762. /**
  97763. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97764. * @param entity defines the entity to select
  97765. * @param lineContainerTitle defines the specific block to highlight
  97766. */
  97767. select(entity: any, lineContainerTitle?: string): void;
  97768. /** Get the inspector from bundle or global */
  97769. private _getGlobalInspector;
  97770. /**
  97771. * Get if the inspector is visible or not.
  97772. * @returns true if visible otherwise, false
  97773. */
  97774. isVisible(): boolean;
  97775. /**
  97776. * Hide the inspector and close its window.
  97777. */
  97778. hide(): void;
  97779. /**
  97780. * Launch the debugLayer.
  97781. * @param config Define the configuration of the inspector
  97782. * @return a promise fulfilled when the debug layer is visible
  97783. */
  97784. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97785. }
  97786. }
  97787. declare module BABYLON {
  97788. /**
  97789. * Class containing static functions to help procedurally build meshes
  97790. */
  97791. export class BoxBuilder {
  97792. /**
  97793. * Creates a box mesh
  97794. * * The parameter `size` sets the size (float) of each box side (default 1)
  97795. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97796. * * 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)
  97797. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97799. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97801. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97802. * @param name defines the name of the mesh
  97803. * @param options defines the options used to create the mesh
  97804. * @param scene defines the hosting scene
  97805. * @returns the box mesh
  97806. */
  97807. static CreateBox(name: string, options: {
  97808. size?: number;
  97809. width?: number;
  97810. height?: number;
  97811. depth?: number;
  97812. faceUV?: Vector4[];
  97813. faceColors?: Color4[];
  97814. sideOrientation?: number;
  97815. frontUVs?: Vector4;
  97816. backUVs?: Vector4;
  97817. updatable?: boolean;
  97818. }, scene?: Nullable<Scene>): Mesh;
  97819. }
  97820. }
  97821. declare module BABYLON {
  97822. /**
  97823. * Class containing static functions to help procedurally build meshes
  97824. */
  97825. export class SphereBuilder {
  97826. /**
  97827. * Creates a sphere mesh
  97828. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97829. * * 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`)
  97830. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97831. * * 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
  97832. * * 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)
  97833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97836. * @param name defines the name of the mesh
  97837. * @param options defines the options used to create the mesh
  97838. * @param scene defines the hosting scene
  97839. * @returns the sphere mesh
  97840. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97841. */
  97842. static CreateSphere(name: string, options: {
  97843. segments?: number;
  97844. diameter?: number;
  97845. diameterX?: number;
  97846. diameterY?: number;
  97847. diameterZ?: number;
  97848. arc?: number;
  97849. slice?: number;
  97850. sideOrientation?: number;
  97851. frontUVs?: Vector4;
  97852. backUVs?: Vector4;
  97853. updatable?: boolean;
  97854. }, scene: any): Mesh;
  97855. }
  97856. }
  97857. declare module BABYLON.Debug {
  97858. /**
  97859. * Used to show the physics impostor around the specific mesh
  97860. */
  97861. export class PhysicsViewer {
  97862. /** @hidden */
  97863. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97864. /** @hidden */
  97865. protected _meshes: Array<Nullable<AbstractMesh>>;
  97866. /** @hidden */
  97867. protected _scene: Nullable<Scene>;
  97868. /** @hidden */
  97869. protected _numMeshes: number;
  97870. /** @hidden */
  97871. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97872. private _renderFunction;
  97873. private _utilityLayer;
  97874. private _debugBoxMesh;
  97875. private _debugSphereMesh;
  97876. private _debugMaterial;
  97877. /**
  97878. * Creates a new PhysicsViewer
  97879. * @param scene defines the hosting scene
  97880. */
  97881. constructor(scene: Scene);
  97882. /** @hidden */
  97883. protected _updateDebugMeshes(): void;
  97884. /**
  97885. * Renders a specified physic impostor
  97886. * @param impostor defines the impostor to render
  97887. * @returns the new debug mesh used to render the impostor
  97888. */
  97889. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97890. /**
  97891. * Hides a specified physic impostor
  97892. * @param impostor defines the impostor to hide
  97893. */
  97894. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97895. private _getDebugMaterial;
  97896. private _getDebugBoxMesh;
  97897. private _getDebugSphereMesh;
  97898. private _getDebugMesh;
  97899. /** Releases all resources */
  97900. dispose(): void;
  97901. }
  97902. }
  97903. declare module BABYLON {
  97904. /**
  97905. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97906. * in order to better appreciate the issue one might have.
  97907. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97908. */
  97909. export class RayHelper {
  97910. /**
  97911. * Defines the ray we are currently tryin to visualize.
  97912. */
  97913. ray: Nullable<Ray>;
  97914. private _renderPoints;
  97915. private _renderLine;
  97916. private _renderFunction;
  97917. private _scene;
  97918. private _updateToMeshFunction;
  97919. private _attachedToMesh;
  97920. private _meshSpaceDirection;
  97921. private _meshSpaceOrigin;
  97922. /**
  97923. * Helper function to create a colored helper in a scene in one line.
  97924. * @param ray Defines the ray we are currently tryin to visualize
  97925. * @param scene Defines the scene the ray is used in
  97926. * @param color Defines the color we want to see the ray in
  97927. * @returns The newly created ray helper.
  97928. */
  97929. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97930. /**
  97931. * Instantiate a new ray helper.
  97932. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97933. * in order to better appreciate the issue one might have.
  97934. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97935. * @param ray Defines the ray we are currently tryin to visualize
  97936. */
  97937. constructor(ray: Ray);
  97938. /**
  97939. * Shows the ray we are willing to debug.
  97940. * @param scene Defines the scene the ray needs to be rendered in
  97941. * @param color Defines the color the ray needs to be rendered in
  97942. */
  97943. show(scene: Scene, color?: Color3): void;
  97944. /**
  97945. * Hides the ray we are debugging.
  97946. */
  97947. hide(): void;
  97948. private _render;
  97949. /**
  97950. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  97951. * @param mesh Defines the mesh we want the helper attached to
  97952. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  97953. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  97954. * @param length Defines the length of the ray
  97955. */
  97956. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  97957. /**
  97958. * Detach the ray helper from the mesh it has previously been attached to.
  97959. */
  97960. detachFromMesh(): void;
  97961. private _updateToMesh;
  97962. /**
  97963. * Dispose the helper and release its associated resources.
  97964. */
  97965. dispose(): void;
  97966. }
  97967. }
  97968. declare module BABYLON.Debug {
  97969. /**
  97970. * Class used to render a debug view of a given skeleton
  97971. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  97972. */
  97973. export class SkeletonViewer {
  97974. /** defines the skeleton to render */
  97975. skeleton: Skeleton;
  97976. /** defines the mesh attached to the skeleton */
  97977. mesh: AbstractMesh;
  97978. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97979. autoUpdateBonesMatrices: boolean;
  97980. /** defines the rendering group id to use with the viewer */
  97981. renderingGroupId: number;
  97982. /** Gets or sets the color used to render the skeleton */
  97983. color: Color3;
  97984. private _scene;
  97985. private _debugLines;
  97986. private _debugMesh;
  97987. private _isEnabled;
  97988. private _renderFunction;
  97989. private _utilityLayer;
  97990. /**
  97991. * Returns the mesh used to render the bones
  97992. */
  97993. readonly debugMesh: Nullable<LinesMesh>;
  97994. /**
  97995. * Creates a new SkeletonViewer
  97996. * @param skeleton defines the skeleton to render
  97997. * @param mesh defines the mesh attached to the skeleton
  97998. * @param scene defines the hosting scene
  97999. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  98000. * @param renderingGroupId defines the rendering group id to use with the viewer
  98001. */
  98002. constructor(
  98003. /** defines the skeleton to render */
  98004. skeleton: Skeleton,
  98005. /** defines the mesh attached to the skeleton */
  98006. mesh: AbstractMesh, scene: Scene,
  98007. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98008. autoUpdateBonesMatrices?: boolean,
  98009. /** defines the rendering group id to use with the viewer */
  98010. renderingGroupId?: number);
  98011. /** Gets or sets a boolean indicating if the viewer is enabled */
  98012. isEnabled: boolean;
  98013. private _getBonePosition;
  98014. private _getLinesForBonesWithLength;
  98015. private _getLinesForBonesNoLength;
  98016. /** Update the viewer to sync with current skeleton state */
  98017. update(): void;
  98018. /** Release associated resources */
  98019. dispose(): void;
  98020. }
  98021. }
  98022. declare module BABYLON {
  98023. /**
  98024. * Options to create the null engine
  98025. */
  98026. export class NullEngineOptions {
  98027. /**
  98028. * Render width (Default: 512)
  98029. */
  98030. renderWidth: number;
  98031. /**
  98032. * Render height (Default: 256)
  98033. */
  98034. renderHeight: number;
  98035. /**
  98036. * Texture size (Default: 512)
  98037. */
  98038. textureSize: number;
  98039. /**
  98040. * If delta time between frames should be constant
  98041. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98042. */
  98043. deterministicLockstep: boolean;
  98044. /**
  98045. * Maximum about of steps between frames (Default: 4)
  98046. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98047. */
  98048. lockstepMaxSteps: number;
  98049. }
  98050. /**
  98051. * The null engine class provides support for headless version of babylon.js.
  98052. * This can be used in server side scenario or for testing purposes
  98053. */
  98054. export class NullEngine extends Engine {
  98055. private _options;
  98056. /**
  98057. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98058. */
  98059. isDeterministicLockStep(): boolean;
  98060. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  98061. getLockstepMaxSteps(): number;
  98062. /**
  98063. * Sets hardware scaling, used to save performance if needed
  98064. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98065. */
  98066. getHardwareScalingLevel(): number;
  98067. constructor(options?: NullEngineOptions);
  98068. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98069. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  98070. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98071. getRenderWidth(useScreen?: boolean): number;
  98072. getRenderHeight(useScreen?: boolean): number;
  98073. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  98074. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  98075. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  98076. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  98077. bindSamplers(effect: Effect): void;
  98078. enableEffect(effect: Effect): void;
  98079. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98080. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  98081. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  98082. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  98083. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  98084. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  98085. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  98086. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  98087. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  98088. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  98089. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  98090. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  98091. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  98092. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  98093. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  98094. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98095. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98096. setFloat(uniform: WebGLUniformLocation, value: number): void;
  98097. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  98098. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  98099. setBool(uniform: WebGLUniformLocation, bool: number): void;
  98100. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  98101. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  98102. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  98103. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98104. bindBuffers(vertexBuffers: {
  98105. [key: string]: VertexBuffer;
  98106. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  98107. wipeCaches(bruteForce?: boolean): void;
  98108. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98109. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98110. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98111. /** @hidden */
  98112. _createTexture(): WebGLTexture;
  98113. /** @hidden */
  98114. _releaseTexture(texture: InternalTexture): void;
  98115. 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;
  98116. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98117. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98118. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  98119. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98120. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98121. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  98122. areAllEffectsReady(): boolean;
  98123. /**
  98124. * @hidden
  98125. * Get the current error code of the webGL context
  98126. * @returns the error code
  98127. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98128. */
  98129. getError(): number;
  98130. /** @hidden */
  98131. _getUnpackAlignement(): number;
  98132. /** @hidden */
  98133. _unpackFlipY(value: boolean): void;
  98134. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  98135. /**
  98136. * Updates a dynamic vertex buffer.
  98137. * @param vertexBuffer the vertex buffer to update
  98138. * @param data the data used to update the vertex buffer
  98139. * @param byteOffset the byte offset of the data (optional)
  98140. * @param byteLength the byte length of the data (optional)
  98141. */
  98142. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  98143. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  98144. /** @hidden */
  98145. _bindTexture(channel: number, texture: InternalTexture): void;
  98146. /** @hidden */
  98147. _releaseBuffer(buffer: WebGLBuffer): boolean;
  98148. releaseEffects(): void;
  98149. displayLoadingUI(): void;
  98150. hideLoadingUI(): void;
  98151. /** @hidden */
  98152. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98153. /** @hidden */
  98154. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98155. /** @hidden */
  98156. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98157. /** @hidden */
  98158. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  98159. }
  98160. }
  98161. declare module BABYLON {
  98162. /** @hidden */
  98163. export class _OcclusionDataStorage {
  98164. /** @hidden */
  98165. occlusionInternalRetryCounter: number;
  98166. /** @hidden */
  98167. isOcclusionQueryInProgress: boolean;
  98168. /** @hidden */
  98169. isOccluded: boolean;
  98170. /** @hidden */
  98171. occlusionRetryCount: number;
  98172. /** @hidden */
  98173. occlusionType: number;
  98174. /** @hidden */
  98175. occlusionQueryAlgorithmType: number;
  98176. }
  98177. interface Engine {
  98178. /**
  98179. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  98180. * @return the new query
  98181. */
  98182. createQuery(): WebGLQuery;
  98183. /**
  98184. * Delete and release a webGL query
  98185. * @param query defines the query to delete
  98186. * @return the current engine
  98187. */
  98188. deleteQuery(query: WebGLQuery): Engine;
  98189. /**
  98190. * Check if a given query has resolved and got its value
  98191. * @param query defines the query to check
  98192. * @returns true if the query got its value
  98193. */
  98194. isQueryResultAvailable(query: WebGLQuery): boolean;
  98195. /**
  98196. * Gets the value of a given query
  98197. * @param query defines the query to check
  98198. * @returns the value of the query
  98199. */
  98200. getQueryResult(query: WebGLQuery): number;
  98201. /**
  98202. * Initiates an occlusion query
  98203. * @param algorithmType defines the algorithm to use
  98204. * @param query defines the query to use
  98205. * @returns the current engine
  98206. * @see http://doc.babylonjs.com/features/occlusionquery
  98207. */
  98208. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  98209. /**
  98210. * Ends an occlusion query
  98211. * @see http://doc.babylonjs.com/features/occlusionquery
  98212. * @param algorithmType defines the algorithm to use
  98213. * @returns the current engine
  98214. */
  98215. endOcclusionQuery(algorithmType: number): Engine;
  98216. /**
  98217. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  98218. * Please note that only one query can be issued at a time
  98219. * @returns a time token used to track the time span
  98220. */
  98221. startTimeQuery(): Nullable<_TimeToken>;
  98222. /**
  98223. * Ends a time query
  98224. * @param token defines the token used to measure the time span
  98225. * @returns the time spent (in ns)
  98226. */
  98227. endTimeQuery(token: _TimeToken): int;
  98228. /** @hidden */
  98229. _currentNonTimestampToken: Nullable<_TimeToken>;
  98230. /** @hidden */
  98231. _createTimeQuery(): WebGLQuery;
  98232. /** @hidden */
  98233. _deleteTimeQuery(query: WebGLQuery): void;
  98234. /** @hidden */
  98235. _getGlAlgorithmType(algorithmType: number): number;
  98236. /** @hidden */
  98237. _getTimeQueryResult(query: WebGLQuery): any;
  98238. /** @hidden */
  98239. _getTimeQueryAvailability(query: WebGLQuery): any;
  98240. }
  98241. interface AbstractMesh {
  98242. /**
  98243. * Backing filed
  98244. * @hidden
  98245. */
  98246. __occlusionDataStorage: _OcclusionDataStorage;
  98247. /**
  98248. * Access property
  98249. * @hidden
  98250. */
  98251. _occlusionDataStorage: _OcclusionDataStorage;
  98252. /**
  98253. * 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.
  98254. * The default value is -1 which means don't break the query and wait till the result
  98255. * @see http://doc.babylonjs.com/features/occlusionquery
  98256. */
  98257. occlusionRetryCount: number;
  98258. /**
  98259. * 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:
  98260. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98261. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98262. * * 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.
  98263. * @see http://doc.babylonjs.com/features/occlusionquery
  98264. */
  98265. occlusionType: number;
  98266. /**
  98267. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98268. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98269. * * 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.
  98270. * @see http://doc.babylonjs.com/features/occlusionquery
  98271. */
  98272. occlusionQueryAlgorithmType: number;
  98273. /**
  98274. * 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
  98275. * @see http://doc.babylonjs.com/features/occlusionquery
  98276. */
  98277. isOccluded: boolean;
  98278. /**
  98279. * Flag to check the progress status of the query
  98280. * @see http://doc.babylonjs.com/features/occlusionquery
  98281. */
  98282. isOcclusionQueryInProgress: boolean;
  98283. }
  98284. }
  98285. declare module BABYLON {
  98286. /** @hidden */
  98287. export var _forceTransformFeedbackToBundle: boolean;
  98288. interface Engine {
  98289. /**
  98290. * Creates a webGL transform feedback object
  98291. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98292. * @returns the webGL transform feedback object
  98293. */
  98294. createTransformFeedback(): WebGLTransformFeedback;
  98295. /**
  98296. * Delete a webGL transform feedback object
  98297. * @param value defines the webGL transform feedback object to delete
  98298. */
  98299. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98300. /**
  98301. * Bind a webGL transform feedback object to the webgl context
  98302. * @param value defines the webGL transform feedback object to bind
  98303. */
  98304. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98305. /**
  98306. * Begins a transform feedback operation
  98307. * @param usePoints defines if points or triangles must be used
  98308. */
  98309. beginTransformFeedback(usePoints: boolean): void;
  98310. /**
  98311. * Ends a transform feedback operation
  98312. */
  98313. endTransformFeedback(): void;
  98314. /**
  98315. * Specify the varyings to use with transform feedback
  98316. * @param program defines the associated webGL program
  98317. * @param value defines the list of strings representing the varying names
  98318. */
  98319. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98320. /**
  98321. * Bind a webGL buffer for a transform feedback operation
  98322. * @param value defines the webGL buffer to bind
  98323. */
  98324. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98325. }
  98326. }
  98327. declare module BABYLON {
  98328. /**
  98329. * Gather the list of clipboard event types as constants.
  98330. */
  98331. export class ClipboardEventTypes {
  98332. /**
  98333. * The clipboard event is fired when a copy command is active (pressed).
  98334. */
  98335. static readonly COPY: number;
  98336. /**
  98337. * The clipboard event is fired when a cut command is active (pressed).
  98338. */
  98339. static readonly CUT: number;
  98340. /**
  98341. * The clipboard event is fired when a paste command is active (pressed).
  98342. */
  98343. static readonly PASTE: number;
  98344. }
  98345. /**
  98346. * This class is used to store clipboard related info for the onClipboardObservable event.
  98347. */
  98348. export class ClipboardInfo {
  98349. /**
  98350. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98351. */
  98352. type: number;
  98353. /**
  98354. * Defines the related dom event
  98355. */
  98356. event: ClipboardEvent;
  98357. /**
  98358. *Creates an instance of ClipboardInfo.
  98359. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98360. * @param event Defines the related dom event
  98361. */
  98362. constructor(
  98363. /**
  98364. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98365. */
  98366. type: number,
  98367. /**
  98368. * Defines the related dom event
  98369. */
  98370. event: ClipboardEvent);
  98371. /**
  98372. * Get the clipboard event's type from the keycode.
  98373. * @param keyCode Defines the keyCode for the current keyboard event.
  98374. * @return {number}
  98375. */
  98376. static GetTypeFromCharacter(keyCode: number): number;
  98377. }
  98378. }
  98379. declare module BABYLON {
  98380. /**
  98381. * Class used to represent data loading progression
  98382. */
  98383. export class SceneLoaderProgressEvent {
  98384. /** defines if data length to load can be evaluated */
  98385. readonly lengthComputable: boolean;
  98386. /** defines the loaded data length */
  98387. readonly loaded: number;
  98388. /** defines the data length to load */
  98389. readonly total: number;
  98390. /**
  98391. * Create a new progress event
  98392. * @param lengthComputable defines if data length to load can be evaluated
  98393. * @param loaded defines the loaded data length
  98394. * @param total defines the data length to load
  98395. */
  98396. constructor(
  98397. /** defines if data length to load can be evaluated */
  98398. lengthComputable: boolean,
  98399. /** defines the loaded data length */
  98400. loaded: number,
  98401. /** defines the data length to load */
  98402. total: number);
  98403. /**
  98404. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98405. * @param event defines the source event
  98406. * @returns a new SceneLoaderProgressEvent
  98407. */
  98408. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98409. }
  98410. /**
  98411. * Interface used by SceneLoader plugins to define supported file extensions
  98412. */
  98413. export interface ISceneLoaderPluginExtensions {
  98414. /**
  98415. * Defines the list of supported extensions
  98416. */
  98417. [extension: string]: {
  98418. isBinary: boolean;
  98419. };
  98420. }
  98421. /**
  98422. * Interface used by SceneLoader plugin factory
  98423. */
  98424. export interface ISceneLoaderPluginFactory {
  98425. /**
  98426. * Defines the name of the factory
  98427. */
  98428. name: string;
  98429. /**
  98430. * Function called to create a new plugin
  98431. * @return the new plugin
  98432. */
  98433. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98434. /**
  98435. * Boolean indicating if the plugin can direct load specific data
  98436. */
  98437. canDirectLoad?: (data: string) => boolean;
  98438. }
  98439. /**
  98440. * Interface used to define a SceneLoader plugin
  98441. */
  98442. export interface ISceneLoaderPlugin {
  98443. /**
  98444. * The friendly name of this plugin.
  98445. */
  98446. name: string;
  98447. /**
  98448. * The file extensions supported by this plugin.
  98449. */
  98450. extensions: string | ISceneLoaderPluginExtensions;
  98451. /**
  98452. * Import meshes into a scene.
  98453. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98454. * @param scene The scene to import into
  98455. * @param data The data to import
  98456. * @param rootUrl The root url for scene and resources
  98457. * @param meshes The meshes array to import into
  98458. * @param particleSystems The particle systems array to import into
  98459. * @param skeletons The skeletons array to import into
  98460. * @param onError The callback when import fails
  98461. * @returns True if successful or false otherwise
  98462. */
  98463. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98464. /**
  98465. * Load into a scene.
  98466. * @param scene The scene to load into
  98467. * @param data The data to import
  98468. * @param rootUrl The root url for scene and resources
  98469. * @param onError The callback when import fails
  98470. * @returns true if successful or false otherwise
  98471. */
  98472. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98473. /**
  98474. * The callback that returns true if the data can be directly loaded.
  98475. */
  98476. canDirectLoad?: (data: string) => boolean;
  98477. /**
  98478. * The callback that allows custom handling of the root url based on the response url.
  98479. */
  98480. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98481. /**
  98482. * Load into an asset container.
  98483. * @param scene The scene to load into
  98484. * @param data The data to import
  98485. * @param rootUrl The root url for scene and resources
  98486. * @param onError The callback when import fails
  98487. * @returns The loaded asset container
  98488. */
  98489. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98490. }
  98491. /**
  98492. * Interface used to define an async SceneLoader plugin
  98493. */
  98494. export interface ISceneLoaderPluginAsync {
  98495. /**
  98496. * The friendly name of this plugin.
  98497. */
  98498. name: string;
  98499. /**
  98500. * The file extensions supported by this plugin.
  98501. */
  98502. extensions: string | ISceneLoaderPluginExtensions;
  98503. /**
  98504. * Import meshes into a scene.
  98505. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98506. * @param scene The scene to import into
  98507. * @param data The data to import
  98508. * @param rootUrl The root url for scene and resources
  98509. * @param onProgress The callback when the load progresses
  98510. * @param fileName Defines the name of the file to load
  98511. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98512. */
  98513. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98514. meshes: AbstractMesh[];
  98515. particleSystems: IParticleSystem[];
  98516. skeletons: Skeleton[];
  98517. animationGroups: AnimationGroup[];
  98518. }>;
  98519. /**
  98520. * Load into a scene.
  98521. * @param scene The scene to load into
  98522. * @param data The data to import
  98523. * @param rootUrl The root url for scene and resources
  98524. * @param onProgress The callback when the load progresses
  98525. * @param fileName Defines the name of the file to load
  98526. * @returns Nothing
  98527. */
  98528. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98529. /**
  98530. * The callback that returns true if the data can be directly loaded.
  98531. */
  98532. canDirectLoad?: (data: string) => boolean;
  98533. /**
  98534. * The callback that allows custom handling of the root url based on the response url.
  98535. */
  98536. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98537. /**
  98538. * Load into an asset container.
  98539. * @param scene The scene to load into
  98540. * @param data The data to import
  98541. * @param rootUrl The root url for scene and resources
  98542. * @param onProgress The callback when the load progresses
  98543. * @param fileName Defines the name of the file to load
  98544. * @returns The loaded asset container
  98545. */
  98546. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98547. }
  98548. /**
  98549. * Class used to load scene from various file formats using registered plugins
  98550. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98551. */
  98552. export class SceneLoader {
  98553. /**
  98554. * No logging while loading
  98555. */
  98556. static readonly NO_LOGGING: number;
  98557. /**
  98558. * Minimal logging while loading
  98559. */
  98560. static readonly MINIMAL_LOGGING: number;
  98561. /**
  98562. * Summary logging while loading
  98563. */
  98564. static readonly SUMMARY_LOGGING: number;
  98565. /**
  98566. * Detailled logging while loading
  98567. */
  98568. static readonly DETAILED_LOGGING: number;
  98569. /**
  98570. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98571. */
  98572. static ForceFullSceneLoadingForIncremental: boolean;
  98573. /**
  98574. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98575. */
  98576. static ShowLoadingScreen: boolean;
  98577. /**
  98578. * Defines the current logging level (while loading the scene)
  98579. * @ignorenaming
  98580. */
  98581. static loggingLevel: number;
  98582. /**
  98583. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98584. */
  98585. static CleanBoneMatrixWeights: boolean;
  98586. /**
  98587. * Event raised when a plugin is used to load a scene
  98588. */
  98589. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98590. private static _registeredPlugins;
  98591. private static _getDefaultPlugin;
  98592. private static _getPluginForExtension;
  98593. private static _getPluginForDirectLoad;
  98594. private static _getPluginForFilename;
  98595. private static _getDirectLoad;
  98596. private static _loadData;
  98597. private static _getFileInfo;
  98598. /**
  98599. * Gets a plugin that can load the given extension
  98600. * @param extension defines the extension to load
  98601. * @returns a plugin or null if none works
  98602. */
  98603. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98604. /**
  98605. * Gets a boolean indicating that the given extension can be loaded
  98606. * @param extension defines the extension to load
  98607. * @returns true if the extension is supported
  98608. */
  98609. static IsPluginForExtensionAvailable(extension: string): boolean;
  98610. /**
  98611. * Adds a new plugin to the list of registered plugins
  98612. * @param plugin defines the plugin to add
  98613. */
  98614. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98615. /**
  98616. * Import meshes into a scene
  98617. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98618. * @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)
  98619. * @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)
  98620. * @param scene the instance of BABYLON.Scene to append to
  98621. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98622. * @param onProgress a callback with a progress event for each file being loaded
  98623. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98624. * @param pluginExtension the extension used to determine the plugin
  98625. * @returns The loaded plugin
  98626. */
  98627. 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>;
  98628. /**
  98629. * Import meshes into a scene
  98630. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98631. * @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)
  98632. * @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)
  98633. * @param scene the instance of BABYLON.Scene to append to
  98634. * @param onProgress a callback with a progress event for each file being loaded
  98635. * @param pluginExtension the extension used to determine the plugin
  98636. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98637. */
  98638. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98639. meshes: AbstractMesh[];
  98640. particleSystems: IParticleSystem[];
  98641. skeletons: Skeleton[];
  98642. animationGroups: AnimationGroup[];
  98643. }>;
  98644. /**
  98645. * Load a scene
  98646. * @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)
  98647. * @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)
  98648. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98649. * @param onSuccess a callback with the scene when import succeeds
  98650. * @param onProgress a callback with a progress event for each file being loaded
  98651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98652. * @param pluginExtension the extension used to determine the plugin
  98653. * @returns The loaded plugin
  98654. */
  98655. 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>;
  98656. /**
  98657. * Load 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 engine is the instance of BABYLON.Engine to use to create the scene
  98661. * @param onProgress a callback with a progress event for each file being loaded
  98662. * @param pluginExtension the extension used to determine the plugin
  98663. * @returns The loaded scene
  98664. */
  98665. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98666. /**
  98667. * Append a scene
  98668. * @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)
  98669. * @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)
  98670. * @param scene is the instance of BABYLON.Scene to append to
  98671. * @param onSuccess a callback with the scene when import succeeds
  98672. * @param onProgress a callback with a progress event for each file being loaded
  98673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98674. * @param pluginExtension the extension used to determine the plugin
  98675. * @returns The loaded plugin
  98676. */
  98677. 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>;
  98678. /**
  98679. * Append a scene
  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
  98683. * @param onProgress a callback with a progress event for each file being loaded
  98684. * @param pluginExtension the extension used to determine the plugin
  98685. * @returns The given scene
  98686. */
  98687. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98688. /**
  98689. * Load a scene into an asset container
  98690. * @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)
  98691. * @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)
  98692. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98693. * @param onSuccess a callback with the scene when import succeeds
  98694. * @param onProgress a callback with a progress event for each file being loaded
  98695. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98696. * @param pluginExtension the extension used to determine the plugin
  98697. * @returns The loaded plugin
  98698. */
  98699. 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>;
  98700. /**
  98701. * Load a scene into an asset container
  98702. * @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)
  98703. * @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)
  98704. * @param scene is the instance of Scene to append to
  98705. * @param onProgress a callback with a progress event for each file being loaded
  98706. * @param pluginExtension the extension used to determine the plugin
  98707. * @returns The loaded asset container
  98708. */
  98709. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98710. }
  98711. }
  98712. declare module BABYLON {
  98713. /**
  98714. * Google Daydream controller
  98715. */
  98716. export class DaydreamController extends WebVRController {
  98717. /**
  98718. * Base Url for the controller model.
  98719. */
  98720. static MODEL_BASE_URL: string;
  98721. /**
  98722. * File name for the controller model.
  98723. */
  98724. static MODEL_FILENAME: string;
  98725. /**
  98726. * Gamepad Id prefix used to identify Daydream Controller.
  98727. */
  98728. static readonly GAMEPAD_ID_PREFIX: string;
  98729. /**
  98730. * Creates a new DaydreamController from a gamepad
  98731. * @param vrGamepad the gamepad that the controller should be created from
  98732. */
  98733. constructor(vrGamepad: any);
  98734. /**
  98735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98736. * @param scene scene in which to add meshes
  98737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98738. */
  98739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98740. /**
  98741. * Called once for each button that changed state since the last frame
  98742. * @param buttonIdx Which button index changed
  98743. * @param state New state of the button
  98744. * @param changes Which properties on the state changed since last frame
  98745. */
  98746. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98747. }
  98748. }
  98749. declare module BABYLON {
  98750. /**
  98751. * Gear VR Controller
  98752. */
  98753. export class GearVRController extends WebVRController {
  98754. /**
  98755. * Base Url for the controller model.
  98756. */
  98757. static MODEL_BASE_URL: string;
  98758. /**
  98759. * File name for the controller model.
  98760. */
  98761. static MODEL_FILENAME: string;
  98762. /**
  98763. * Gamepad Id prefix used to identify this controller.
  98764. */
  98765. static readonly GAMEPAD_ID_PREFIX: string;
  98766. private readonly _buttonIndexToObservableNameMap;
  98767. /**
  98768. * Creates a new GearVRController from a gamepad
  98769. * @param vrGamepad the gamepad that the controller should be created from
  98770. */
  98771. constructor(vrGamepad: any);
  98772. /**
  98773. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98774. * @param scene scene in which to add meshes
  98775. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98776. */
  98777. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98778. /**
  98779. * Called once for each button that changed state since the last frame
  98780. * @param buttonIdx Which button index changed
  98781. * @param state New state of the button
  98782. * @param changes Which properties on the state changed since last frame
  98783. */
  98784. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98785. }
  98786. }
  98787. declare module BABYLON {
  98788. /**
  98789. * Generic Controller
  98790. */
  98791. export class GenericController extends WebVRController {
  98792. /**
  98793. * Base Url for the controller model.
  98794. */
  98795. static readonly MODEL_BASE_URL: string;
  98796. /**
  98797. * File name for the controller model.
  98798. */
  98799. static readonly MODEL_FILENAME: string;
  98800. /**
  98801. * Creates a new GenericController from a gamepad
  98802. * @param vrGamepad the gamepad that the controller should be created from
  98803. */
  98804. constructor(vrGamepad: any);
  98805. /**
  98806. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98807. * @param scene scene in which to add meshes
  98808. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98809. */
  98810. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98811. /**
  98812. * Called once for each button that changed state since the last frame
  98813. * @param buttonIdx Which button index changed
  98814. * @param state New state of the button
  98815. * @param changes Which properties on the state changed since last frame
  98816. */
  98817. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98818. }
  98819. }
  98820. declare module BABYLON {
  98821. /**
  98822. * Oculus Touch Controller
  98823. */
  98824. export class OculusTouchController extends WebVRController {
  98825. /**
  98826. * Base Url for the controller model.
  98827. */
  98828. static MODEL_BASE_URL: string;
  98829. /**
  98830. * File name for the left controller model.
  98831. */
  98832. static MODEL_LEFT_FILENAME: string;
  98833. /**
  98834. * File name for the right controller model.
  98835. */
  98836. static MODEL_RIGHT_FILENAME: string;
  98837. /**
  98838. * Fired when the secondary trigger on this controller is modified
  98839. */
  98840. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98841. /**
  98842. * Fired when the thumb rest on this controller is modified
  98843. */
  98844. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98845. /**
  98846. * Creates a new OculusTouchController from a gamepad
  98847. * @param vrGamepad the gamepad that the controller should be created from
  98848. */
  98849. constructor(vrGamepad: any);
  98850. /**
  98851. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98852. * @param scene scene in which to add meshes
  98853. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98854. */
  98855. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98856. /**
  98857. * Fired when the A button on this controller is modified
  98858. */
  98859. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98860. /**
  98861. * Fired when the B button on this controller is modified
  98862. */
  98863. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98864. /**
  98865. * Fired when the X button on this controller is modified
  98866. */
  98867. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98868. /**
  98869. * Fired when the Y button on this controller is modified
  98870. */
  98871. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98872. /**
  98873. * Called once for each button that changed state since the last frame
  98874. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98875. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98876. * 2) secondary trigger (same)
  98877. * 3) A (right) X (left), touch, pressed = value
  98878. * 4) B / Y
  98879. * 5) thumb rest
  98880. * @param buttonIdx Which button index changed
  98881. * @param state New state of the button
  98882. * @param changes Which properties on the state changed since last frame
  98883. */
  98884. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98885. }
  98886. }
  98887. declare module BABYLON {
  98888. /**
  98889. * Vive Controller
  98890. */
  98891. export class ViveController extends WebVRController {
  98892. /**
  98893. * Base Url for the controller model.
  98894. */
  98895. static MODEL_BASE_URL: string;
  98896. /**
  98897. * File name for the controller model.
  98898. */
  98899. static MODEL_FILENAME: string;
  98900. /**
  98901. * Creates a new ViveController from a gamepad
  98902. * @param vrGamepad the gamepad that the controller should be created from
  98903. */
  98904. constructor(vrGamepad: any);
  98905. /**
  98906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98907. * @param scene scene in which to add meshes
  98908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98909. */
  98910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98911. /**
  98912. * Fired when the left button on this controller is modified
  98913. */
  98914. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98915. /**
  98916. * Fired when the right button on this controller is modified
  98917. */
  98918. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98919. /**
  98920. * Fired when the menu button on this controller is modified
  98921. */
  98922. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98923. /**
  98924. * Called once for each button that changed state since the last frame
  98925. * Vive mapping:
  98926. * 0: touchpad
  98927. * 1: trigger
  98928. * 2: left AND right buttons
  98929. * 3: menu button
  98930. * @param buttonIdx Which button index changed
  98931. * @param state New state of the button
  98932. * @param changes Which properties on the state changed since last frame
  98933. */
  98934. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98935. }
  98936. }
  98937. declare module BABYLON {
  98938. /**
  98939. * Defines the WindowsMotionController object that the state of the windows motion controller
  98940. */
  98941. export class WindowsMotionController extends WebVRController {
  98942. /**
  98943. * The base url used to load the left and right controller models
  98944. */
  98945. static MODEL_BASE_URL: string;
  98946. /**
  98947. * The name of the left controller model file
  98948. */
  98949. static MODEL_LEFT_FILENAME: string;
  98950. /**
  98951. * The name of the right controller model file
  98952. */
  98953. static MODEL_RIGHT_FILENAME: string;
  98954. /**
  98955. * The controller name prefix for this controller type
  98956. */
  98957. static readonly GAMEPAD_ID_PREFIX: string;
  98958. /**
  98959. * The controller id pattern for this controller type
  98960. */
  98961. private static readonly GAMEPAD_ID_PATTERN;
  98962. private _loadedMeshInfo;
  98963. private readonly _mapping;
  98964. /**
  98965. * Fired when the trackpad on this controller is clicked
  98966. */
  98967. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  98968. /**
  98969. * Fired when the trackpad on this controller is modified
  98970. */
  98971. onTrackpadValuesChangedObservable: Observable<StickValues>;
  98972. /**
  98973. * The current x and y values of this controller's trackpad
  98974. */
  98975. trackpad: StickValues;
  98976. /**
  98977. * Creates a new WindowsMotionController from a gamepad
  98978. * @param vrGamepad the gamepad that the controller should be created from
  98979. */
  98980. constructor(vrGamepad: any);
  98981. /**
  98982. * Fired when the trigger on this controller is modified
  98983. */
  98984. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98985. /**
  98986. * Fired when the menu button on this controller is modified
  98987. */
  98988. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98989. /**
  98990. * Fired when the grip button on this controller is modified
  98991. */
  98992. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98993. /**
  98994. * Fired when the thumbstick button on this controller is modified
  98995. */
  98996. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98997. /**
  98998. * Fired when the touchpad button on this controller is modified
  98999. */
  99000. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99001. /**
  99002. * Fired when the touchpad values on this controller are modified
  99003. */
  99004. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  99005. private _updateTrackpad;
  99006. /**
  99007. * Called once per frame by the engine.
  99008. */
  99009. update(): void;
  99010. /**
  99011. * Called once for each button that changed state since the last frame
  99012. * @param buttonIdx Which button index changed
  99013. * @param state New state of the button
  99014. * @param changes Which properties on the state changed since last frame
  99015. */
  99016. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99017. /**
  99018. * Moves the buttons on the controller mesh based on their current state
  99019. * @param buttonName the name of the button to move
  99020. * @param buttonValue the value of the button which determines the buttons new position
  99021. */
  99022. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  99023. /**
  99024. * Moves the axis on the controller mesh based on its current state
  99025. * @param axis the index of the axis
  99026. * @param axisValue the value of the axis which determines the meshes new position
  99027. * @hidden
  99028. */
  99029. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  99030. /**
  99031. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99032. * @param scene scene in which to add meshes
  99033. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99034. */
  99035. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  99036. /**
  99037. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  99038. * can be transformed by button presses and axes values, based on this._mapping.
  99039. *
  99040. * @param scene scene in which the meshes exist
  99041. * @param meshes list of meshes that make up the controller model to process
  99042. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  99043. */
  99044. private processModel;
  99045. private createMeshInfo;
  99046. /**
  99047. * Gets the ray of the controller in the direction the controller is pointing
  99048. * @param length the length the resulting ray should be
  99049. * @returns a ray in the direction the controller is pointing
  99050. */
  99051. getForwardRay(length?: number): Ray;
  99052. /**
  99053. * Disposes of the controller
  99054. */
  99055. dispose(): void;
  99056. }
  99057. }
  99058. declare module BABYLON {
  99059. /**
  99060. * Single axis scale gizmo
  99061. */
  99062. export class AxisScaleGizmo extends Gizmo {
  99063. private _coloredMaterial;
  99064. /**
  99065. * Drag behavior responsible for the gizmos dragging interactions
  99066. */
  99067. dragBehavior: PointerDragBehavior;
  99068. private _pointerObserver;
  99069. /**
  99070. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99071. */
  99072. snapDistance: number;
  99073. /**
  99074. * Event that fires each time the gizmo snaps to a new location.
  99075. * * snapDistance is the the change in distance
  99076. */
  99077. onSnapObservable: Observable<{
  99078. snapDistance: number;
  99079. }>;
  99080. /**
  99081. * If the scaling operation should be done on all axis (default: false)
  99082. */
  99083. uniformScaling: boolean;
  99084. /**
  99085. * Creates an AxisScaleGizmo
  99086. * @param gizmoLayer The utility layer the gizmo will be added to
  99087. * @param dragAxis The axis which the gizmo will be able to scale on
  99088. * @param color The color of the gizmo
  99089. */
  99090. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99091. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99092. /**
  99093. * Disposes of the gizmo
  99094. */
  99095. dispose(): void;
  99096. /**
  99097. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99098. * @param mesh The mesh to replace the default mesh of the gizmo
  99099. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  99100. */
  99101. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  99102. }
  99103. }
  99104. declare module BABYLON {
  99105. /**
  99106. * Bounding box gizmo
  99107. */
  99108. export class BoundingBoxGizmo extends Gizmo {
  99109. private _lineBoundingBox;
  99110. private _rotateSpheresParent;
  99111. private _scaleBoxesParent;
  99112. private _boundingDimensions;
  99113. private _renderObserver;
  99114. private _pointerObserver;
  99115. private _scaleDragSpeed;
  99116. private _tmpQuaternion;
  99117. private _tmpVector;
  99118. private _tmpRotationMatrix;
  99119. /**
  99120. * 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)
  99121. */
  99122. ignoreChildren: boolean;
  99123. /**
  99124. * 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)
  99125. */
  99126. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  99127. /**
  99128. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  99129. */
  99130. rotationSphereSize: number;
  99131. /**
  99132. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  99133. */
  99134. scaleBoxSize: number;
  99135. /**
  99136. * 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)
  99137. */
  99138. fixedDragMeshScreenSize: boolean;
  99139. /**
  99140. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  99141. */
  99142. fixedDragMeshScreenSizeDistanceFactor: number;
  99143. /**
  99144. * Fired when a rotation sphere or scale box is dragged
  99145. */
  99146. onDragStartObservable: Observable<{}>;
  99147. /**
  99148. * Fired when a scale box is dragged
  99149. */
  99150. onScaleBoxDragObservable: Observable<{}>;
  99151. /**
  99152. * Fired when a scale box drag is ended
  99153. */
  99154. onScaleBoxDragEndObservable: Observable<{}>;
  99155. /**
  99156. * Fired when a rotation sphere is dragged
  99157. */
  99158. onRotationSphereDragObservable: Observable<{}>;
  99159. /**
  99160. * Fired when a rotation sphere drag is ended
  99161. */
  99162. onRotationSphereDragEndObservable: Observable<{}>;
  99163. /**
  99164. * 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)
  99165. */
  99166. scalePivot: Nullable<Vector3>;
  99167. private _anchorMesh;
  99168. private _existingMeshScale;
  99169. private _dragMesh;
  99170. private pointerDragBehavior;
  99171. private coloredMaterial;
  99172. private hoverColoredMaterial;
  99173. /**
  99174. * Sets the color of the bounding box gizmo
  99175. * @param color the color to set
  99176. */
  99177. setColor(color: Color3): void;
  99178. /**
  99179. * Creates an BoundingBoxGizmo
  99180. * @param gizmoLayer The utility layer the gizmo will be added to
  99181. * @param color The color of the gizmo
  99182. */
  99183. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99184. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99185. private _selectNode;
  99186. /**
  99187. * Updates the bounding box information for the Gizmo
  99188. */
  99189. updateBoundingBox(): void;
  99190. private _updateRotationSpheres;
  99191. private _updateScaleBoxes;
  99192. /**
  99193. * Enables rotation on the specified axis and disables rotation on the others
  99194. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  99195. */
  99196. setEnabledRotationAxis(axis: string): void;
  99197. /**
  99198. * Enables/disables scaling
  99199. * @param enable if scaling should be enabled
  99200. */
  99201. setEnabledScaling(enable: boolean): void;
  99202. private _updateDummy;
  99203. /**
  99204. * Enables a pointer drag behavior on the bounding box of the gizmo
  99205. */
  99206. enableDragBehavior(): void;
  99207. /**
  99208. * Disposes of the gizmo
  99209. */
  99210. dispose(): void;
  99211. /**
  99212. * 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)
  99213. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  99214. * @returns the bounding box mesh with the passed in mesh as a child
  99215. */
  99216. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  99217. /**
  99218. * CustomMeshes are not supported by this gizmo
  99219. * @param mesh The mesh to replace the default mesh of the gizmo
  99220. */
  99221. setCustomMesh(mesh: Mesh): void;
  99222. }
  99223. }
  99224. declare module BABYLON {
  99225. /**
  99226. * Single plane rotation gizmo
  99227. */
  99228. export class PlaneRotationGizmo extends Gizmo {
  99229. /**
  99230. * Drag behavior responsible for the gizmos dragging interactions
  99231. */
  99232. dragBehavior: PointerDragBehavior;
  99233. private _pointerObserver;
  99234. /**
  99235. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99236. */
  99237. snapDistance: number;
  99238. /**
  99239. * Event that fires each time the gizmo snaps to a new location.
  99240. * * snapDistance is the the change in distance
  99241. */
  99242. onSnapObservable: Observable<{
  99243. snapDistance: number;
  99244. }>;
  99245. /**
  99246. * Creates a PlaneRotationGizmo
  99247. * @param gizmoLayer The utility layer the gizmo will be added to
  99248. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99249. * @param color The color of the gizmo
  99250. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99251. */
  99252. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99254. /**
  99255. * Disposes of the gizmo
  99256. */
  99257. dispose(): void;
  99258. }
  99259. }
  99260. declare module BABYLON {
  99261. /**
  99262. * Gizmo that enables rotating a mesh along 3 axis
  99263. */
  99264. export class RotationGizmo extends Gizmo {
  99265. /**
  99266. * Internal gizmo used for interactions on the x axis
  99267. */
  99268. xGizmo: PlaneRotationGizmo;
  99269. /**
  99270. * Internal gizmo used for interactions on the y axis
  99271. */
  99272. yGizmo: PlaneRotationGizmo;
  99273. /**
  99274. * Internal gizmo used for interactions on the z axis
  99275. */
  99276. zGizmo: PlaneRotationGizmo;
  99277. /** Fires an event when any of it's sub gizmos are dragged */
  99278. onDragStartObservable: Observable<{}>;
  99279. /** Fires an event when any of it's sub gizmos are released from dragging */
  99280. onDragEndObservable: Observable<{}>;
  99281. attachedMesh: Nullable<AbstractMesh>;
  99282. /**
  99283. * Creates a RotationGizmo
  99284. * @param gizmoLayer The utility layer the gizmo will be added to
  99285. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99286. */
  99287. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99288. updateGizmoRotationToMatchAttachedMesh: boolean;
  99289. /**
  99290. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99291. */
  99292. snapDistance: number;
  99293. /**
  99294. * Ratio for the scale of the gizmo (Default: 1)
  99295. */
  99296. scaleRatio: number;
  99297. /**
  99298. * Disposes of the gizmo
  99299. */
  99300. dispose(): void;
  99301. /**
  99302. * CustomMeshes are not supported by this gizmo
  99303. * @param mesh The mesh to replace the default mesh of the gizmo
  99304. */
  99305. setCustomMesh(mesh: Mesh): void;
  99306. }
  99307. }
  99308. declare module BABYLON {
  99309. /**
  99310. * Gizmo that enables dragging a mesh along 3 axis
  99311. */
  99312. export class PositionGizmo extends Gizmo {
  99313. /**
  99314. * Internal gizmo used for interactions on the x axis
  99315. */
  99316. xGizmo: AxisDragGizmo;
  99317. /**
  99318. * Internal gizmo used for interactions on the y axis
  99319. */
  99320. yGizmo: AxisDragGizmo;
  99321. /**
  99322. * Internal gizmo used for interactions on the z axis
  99323. */
  99324. zGizmo: AxisDragGizmo;
  99325. /** Fires an event when any of it's sub gizmos are dragged */
  99326. onDragStartObservable: Observable<{}>;
  99327. /** Fires an event when any of it's sub gizmos are released from dragging */
  99328. onDragEndObservable: Observable<{}>;
  99329. attachedMesh: Nullable<AbstractMesh>;
  99330. /**
  99331. * Creates a PositionGizmo
  99332. * @param gizmoLayer The utility layer the gizmo will be added to
  99333. */
  99334. constructor(gizmoLayer?: UtilityLayerRenderer);
  99335. updateGizmoRotationToMatchAttachedMesh: boolean;
  99336. /**
  99337. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99338. */
  99339. snapDistance: number;
  99340. /**
  99341. * Ratio for the scale of the gizmo (Default: 1)
  99342. */
  99343. scaleRatio: number;
  99344. /**
  99345. * Disposes of the gizmo
  99346. */
  99347. dispose(): void;
  99348. /**
  99349. * CustomMeshes are not supported by this gizmo
  99350. * @param mesh The mesh to replace the default mesh of the gizmo
  99351. */
  99352. setCustomMesh(mesh: Mesh): void;
  99353. }
  99354. }
  99355. declare module BABYLON {
  99356. /**
  99357. * Class containing static functions to help procedurally build meshes
  99358. */
  99359. export class PolyhedronBuilder {
  99360. /**
  99361. * Creates a polyhedron mesh
  99362. * * 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
  99363. * * The parameter `size` (positive float, default 1) sets the polygon size
  99364. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99365. * * 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`
  99366. * * 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
  99367. * * 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)`)
  99368. * * 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
  99369. * * 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
  99370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99373. * @param name defines the name of the mesh
  99374. * @param options defines the options used to create the mesh
  99375. * @param scene defines the hosting scene
  99376. * @returns the polyhedron mesh
  99377. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99378. */
  99379. static CreatePolyhedron(name: string, options: {
  99380. type?: number;
  99381. size?: number;
  99382. sizeX?: number;
  99383. sizeY?: number;
  99384. sizeZ?: number;
  99385. custom?: any;
  99386. faceUV?: Vector4[];
  99387. faceColors?: Color4[];
  99388. flat?: boolean;
  99389. updatable?: boolean;
  99390. sideOrientation?: number;
  99391. frontUVs?: Vector4;
  99392. backUVs?: Vector4;
  99393. }, scene: Scene): Mesh;
  99394. }
  99395. }
  99396. declare module BABYLON {
  99397. /**
  99398. * Gizmo that enables scaling a mesh along 3 axis
  99399. */
  99400. export class ScaleGizmo extends Gizmo {
  99401. /**
  99402. * Internal gizmo used for interactions on the x axis
  99403. */
  99404. xGizmo: AxisScaleGizmo;
  99405. /**
  99406. * Internal gizmo used for interactions on the y axis
  99407. */
  99408. yGizmo: AxisScaleGizmo;
  99409. /**
  99410. * Internal gizmo used for interactions on the z axis
  99411. */
  99412. zGizmo: AxisScaleGizmo;
  99413. /**
  99414. * Internal gizmo used to scale all axis equally
  99415. */
  99416. uniformScaleGizmo: AxisScaleGizmo;
  99417. /** Fires an event when any of it's sub gizmos are dragged */
  99418. onDragStartObservable: Observable<{}>;
  99419. /** Fires an event when any of it's sub gizmos are released from dragging */
  99420. onDragEndObservable: Observable<{}>;
  99421. attachedMesh: Nullable<AbstractMesh>;
  99422. /**
  99423. * Creates a ScaleGizmo
  99424. * @param gizmoLayer The utility layer the gizmo will be added to
  99425. */
  99426. constructor(gizmoLayer?: UtilityLayerRenderer);
  99427. updateGizmoRotationToMatchAttachedMesh: boolean;
  99428. /**
  99429. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99430. */
  99431. snapDistance: number;
  99432. /**
  99433. * Ratio for the scale of the gizmo (Default: 1)
  99434. */
  99435. scaleRatio: number;
  99436. /**
  99437. * Disposes of the gizmo
  99438. */
  99439. dispose(): void;
  99440. }
  99441. }
  99442. declare module BABYLON {
  99443. /**
  99444. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99445. */
  99446. export class GizmoManager implements IDisposable {
  99447. private scene;
  99448. /**
  99449. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99450. */
  99451. gizmos: {
  99452. positionGizmo: Nullable<PositionGizmo>;
  99453. rotationGizmo: Nullable<RotationGizmo>;
  99454. scaleGizmo: Nullable<ScaleGizmo>;
  99455. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99456. };
  99457. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99458. clearGizmoOnEmptyPointerEvent: boolean;
  99459. /** Fires an event when the manager is attached to a mesh */
  99460. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99461. private _gizmosEnabled;
  99462. private _pointerObserver;
  99463. private _attachedMesh;
  99464. private _boundingBoxColor;
  99465. private _defaultUtilityLayer;
  99466. private _defaultKeepDepthUtilityLayer;
  99467. /**
  99468. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99469. */
  99470. boundingBoxDragBehavior: SixDofDragBehavior;
  99471. /**
  99472. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99473. */
  99474. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99475. /**
  99476. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99477. */
  99478. usePointerToAttachGizmos: boolean;
  99479. /**
  99480. * Instatiates a gizmo manager
  99481. * @param scene the scene to overlay the gizmos on top of
  99482. */
  99483. constructor(scene: Scene);
  99484. /**
  99485. * Attaches a set of gizmos to the specified mesh
  99486. * @param mesh The mesh the gizmo's should be attached to
  99487. */
  99488. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99489. /**
  99490. * If the position gizmo is enabled
  99491. */
  99492. positionGizmoEnabled: boolean;
  99493. /**
  99494. * If the rotation gizmo is enabled
  99495. */
  99496. rotationGizmoEnabled: boolean;
  99497. /**
  99498. * If the scale gizmo is enabled
  99499. */
  99500. scaleGizmoEnabled: boolean;
  99501. /**
  99502. * If the boundingBox gizmo is enabled
  99503. */
  99504. boundingBoxGizmoEnabled: boolean;
  99505. /**
  99506. * Disposes of the gizmo manager
  99507. */
  99508. dispose(): void;
  99509. }
  99510. }
  99511. declare module BABYLON {
  99512. /**
  99513. * Gizmo that enables viewing a light
  99514. */
  99515. export class LightGizmo extends Gizmo {
  99516. private _box;
  99517. /**
  99518. * Creates a LightGizmo
  99519. * @param gizmoLayer The utility layer the gizmo will be added to
  99520. */
  99521. constructor(gizmoLayer?: UtilityLayerRenderer);
  99522. private _light;
  99523. /**
  99524. * The light that the gizmo is attached to
  99525. */
  99526. light: Nullable<Light>;
  99527. /**
  99528. * @hidden
  99529. * Updates the gizmo to match the attached mesh's position/rotation
  99530. */
  99531. protected _update(): void;
  99532. }
  99533. }
  99534. declare module BABYLON {
  99535. /** @hidden */
  99536. export var backgroundFragmentDeclaration: {
  99537. name: string;
  99538. shader: string;
  99539. };
  99540. }
  99541. declare module BABYLON {
  99542. /** @hidden */
  99543. export var backgroundUboDeclaration: {
  99544. name: string;
  99545. shader: string;
  99546. };
  99547. }
  99548. declare module BABYLON {
  99549. /** @hidden */
  99550. export var backgroundPixelShader: {
  99551. name: string;
  99552. shader: string;
  99553. };
  99554. }
  99555. declare module BABYLON {
  99556. /** @hidden */
  99557. export var backgroundVertexDeclaration: {
  99558. name: string;
  99559. shader: string;
  99560. };
  99561. }
  99562. declare module BABYLON {
  99563. /** @hidden */
  99564. export var backgroundVertexShader: {
  99565. name: string;
  99566. shader: string;
  99567. };
  99568. }
  99569. declare module BABYLON {
  99570. /**
  99571. * Background material used to create an efficient environement around your scene.
  99572. */
  99573. export class BackgroundMaterial extends PushMaterial {
  99574. /**
  99575. * Standard reflectance value at parallel view angle.
  99576. */
  99577. static StandardReflectance0: number;
  99578. /**
  99579. * Standard reflectance value at grazing angle.
  99580. */
  99581. static StandardReflectance90: number;
  99582. protected _primaryColor: Color3;
  99583. /**
  99584. * Key light Color (multiply against the environement texture)
  99585. */
  99586. primaryColor: Color3;
  99587. protected __perceptualColor: Nullable<Color3>;
  99588. /**
  99589. * Experimental Internal Use Only.
  99590. *
  99591. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99592. * This acts as a helper to set the primary color to a more "human friendly" value.
  99593. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99594. * output color as close as possible from the chosen value.
  99595. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99596. * part of lighting setup.)
  99597. */
  99598. _perceptualColor: Nullable<Color3>;
  99599. protected _primaryColorShadowLevel: float;
  99600. /**
  99601. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99602. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99603. */
  99604. primaryColorShadowLevel: float;
  99605. protected _primaryColorHighlightLevel: float;
  99606. /**
  99607. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99608. * The primary color is used at the level chosen to define what the white area would look.
  99609. */
  99610. primaryColorHighlightLevel: float;
  99611. protected _reflectionTexture: Nullable<BaseTexture>;
  99612. /**
  99613. * Reflection Texture used in the material.
  99614. * Should be author in a specific way for the best result (refer to the documentation).
  99615. */
  99616. reflectionTexture: Nullable<BaseTexture>;
  99617. protected _reflectionBlur: float;
  99618. /**
  99619. * Reflection Texture level of blur.
  99620. *
  99621. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99622. * texture twice.
  99623. */
  99624. reflectionBlur: float;
  99625. protected _diffuseTexture: Nullable<BaseTexture>;
  99626. /**
  99627. * Diffuse Texture used in the material.
  99628. * Should be author in a specific way for the best result (refer to the documentation).
  99629. */
  99630. diffuseTexture: Nullable<BaseTexture>;
  99631. protected _shadowLights: Nullable<IShadowLight[]>;
  99632. /**
  99633. * Specify the list of lights casting shadow on the material.
  99634. * All scene shadow lights will be included if null.
  99635. */
  99636. shadowLights: Nullable<IShadowLight[]>;
  99637. protected _shadowLevel: float;
  99638. /**
  99639. * Helps adjusting the shadow to a softer level if required.
  99640. * 0 means black shadows and 1 means no shadows.
  99641. */
  99642. shadowLevel: float;
  99643. protected _sceneCenter: Vector3;
  99644. /**
  99645. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99646. * It is usually zero but might be interesting to modify according to your setup.
  99647. */
  99648. sceneCenter: Vector3;
  99649. protected _opacityFresnel: boolean;
  99650. /**
  99651. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99652. * This helps ensuring a nice transition when the camera goes under the ground.
  99653. */
  99654. opacityFresnel: boolean;
  99655. protected _reflectionFresnel: boolean;
  99656. /**
  99657. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99658. * This helps adding a mirror texture on the ground.
  99659. */
  99660. reflectionFresnel: boolean;
  99661. protected _reflectionFalloffDistance: number;
  99662. /**
  99663. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99664. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99665. */
  99666. reflectionFalloffDistance: number;
  99667. protected _reflectionAmount: number;
  99668. /**
  99669. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99670. */
  99671. reflectionAmount: number;
  99672. protected _reflectionReflectance0: number;
  99673. /**
  99674. * This specifies the weight of the reflection at grazing angle.
  99675. */
  99676. reflectionReflectance0: number;
  99677. protected _reflectionReflectance90: number;
  99678. /**
  99679. * This specifies the weight of the reflection at a perpendicular point of view.
  99680. */
  99681. reflectionReflectance90: number;
  99682. /**
  99683. * Sets the reflection reflectance fresnel values according to the default standard
  99684. * empirically know to work well :-)
  99685. */
  99686. reflectionStandardFresnelWeight: number;
  99687. protected _useRGBColor: boolean;
  99688. /**
  99689. * Helps to directly use the maps channels instead of their level.
  99690. */
  99691. useRGBColor: boolean;
  99692. protected _enableNoise: boolean;
  99693. /**
  99694. * This helps reducing the banding effect that could occur on the background.
  99695. */
  99696. enableNoise: boolean;
  99697. /**
  99698. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99699. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99700. * Recommended to be keep at 1.0 except for special cases.
  99701. */
  99702. fovMultiplier: number;
  99703. private _fovMultiplier;
  99704. /**
  99705. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99706. */
  99707. useEquirectangularFOV: boolean;
  99708. private _maxSimultaneousLights;
  99709. /**
  99710. * Number of Simultaneous lights allowed on the material.
  99711. */
  99712. maxSimultaneousLights: int;
  99713. /**
  99714. * Default configuration related to image processing available in the Background Material.
  99715. */
  99716. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99717. /**
  99718. * Keep track of the image processing observer to allow dispose and replace.
  99719. */
  99720. private _imageProcessingObserver;
  99721. /**
  99722. * Attaches a new image processing configuration to the PBR Material.
  99723. * @param configuration (if null the scene configuration will be use)
  99724. */
  99725. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99726. /**
  99727. * Gets the image processing configuration used either in this material.
  99728. */
  99729. /**
  99730. * Sets the Default image processing configuration used either in the this material.
  99731. *
  99732. * If sets to null, the scene one is in use.
  99733. */
  99734. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99735. /**
  99736. * Gets wether the color curves effect is enabled.
  99737. */
  99738. /**
  99739. * Sets wether the color curves effect is enabled.
  99740. */
  99741. cameraColorCurvesEnabled: boolean;
  99742. /**
  99743. * Gets wether the color grading effect is enabled.
  99744. */
  99745. /**
  99746. * Gets wether the color grading effect is enabled.
  99747. */
  99748. cameraColorGradingEnabled: boolean;
  99749. /**
  99750. * Gets wether tonemapping is enabled or not.
  99751. */
  99752. /**
  99753. * Sets wether tonemapping is enabled or not
  99754. */
  99755. cameraToneMappingEnabled: boolean;
  99756. /**
  99757. * The camera exposure used on this material.
  99758. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99759. * This corresponds to a photographic exposure.
  99760. */
  99761. /**
  99762. * The camera exposure used on this material.
  99763. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99764. * This corresponds to a photographic exposure.
  99765. */
  99766. cameraExposure: float;
  99767. /**
  99768. * Gets The camera contrast used on this material.
  99769. */
  99770. /**
  99771. * Sets The camera contrast used on this material.
  99772. */
  99773. cameraContrast: float;
  99774. /**
  99775. * Gets the Color Grading 2D Lookup Texture.
  99776. */
  99777. /**
  99778. * Sets the Color Grading 2D Lookup Texture.
  99779. */
  99780. cameraColorGradingTexture: Nullable<BaseTexture>;
  99781. /**
  99782. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99783. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99784. * 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;
  99785. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99786. */
  99787. /**
  99788. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99789. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99790. * 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;
  99791. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99792. */
  99793. cameraColorCurves: Nullable<ColorCurves>;
  99794. /**
  99795. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99796. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99797. */
  99798. switchToBGR: boolean;
  99799. private _renderTargets;
  99800. private _reflectionControls;
  99801. private _white;
  99802. private _primaryShadowColor;
  99803. private _primaryHighlightColor;
  99804. /**
  99805. * Instantiates a Background Material in the given scene
  99806. * @param name The friendly name of the material
  99807. * @param scene The scene to add the material to
  99808. */
  99809. constructor(name: string, scene: Scene);
  99810. /**
  99811. * Gets a boolean indicating that current material needs to register RTT
  99812. */
  99813. readonly hasRenderTargetTextures: boolean;
  99814. /**
  99815. * The entire material has been created in order to prevent overdraw.
  99816. * @returns false
  99817. */
  99818. needAlphaTesting(): boolean;
  99819. /**
  99820. * The entire material has been created in order to prevent overdraw.
  99821. * @returns true if blending is enable
  99822. */
  99823. needAlphaBlending(): boolean;
  99824. /**
  99825. * Checks wether the material is ready to be rendered for a given mesh.
  99826. * @param mesh The mesh to render
  99827. * @param subMesh The submesh to check against
  99828. * @param useInstances Specify wether or not the material is used with instances
  99829. * @returns true if all the dependencies are ready (Textures, Effects...)
  99830. */
  99831. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99832. /**
  99833. * Compute the primary color according to the chosen perceptual color.
  99834. */
  99835. private _computePrimaryColorFromPerceptualColor;
  99836. /**
  99837. * Compute the highlights and shadow colors according to their chosen levels.
  99838. */
  99839. private _computePrimaryColors;
  99840. /**
  99841. * Build the uniform buffer used in the material.
  99842. */
  99843. buildUniformLayout(): void;
  99844. /**
  99845. * Unbind the material.
  99846. */
  99847. unbind(): void;
  99848. /**
  99849. * Bind only the world matrix to the material.
  99850. * @param world The world matrix to bind.
  99851. */
  99852. bindOnlyWorldMatrix(world: Matrix): void;
  99853. /**
  99854. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99855. * @param world The world matrix to bind.
  99856. * @param subMesh The submesh to bind for.
  99857. */
  99858. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99859. /**
  99860. * Dispose the material.
  99861. * @param forceDisposeEffect Force disposal of the associated effect.
  99862. * @param forceDisposeTextures Force disposal of the associated textures.
  99863. */
  99864. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99865. /**
  99866. * Clones the material.
  99867. * @param name The cloned name.
  99868. * @returns The cloned material.
  99869. */
  99870. clone(name: string): BackgroundMaterial;
  99871. /**
  99872. * Serializes the current material to its JSON representation.
  99873. * @returns The JSON representation.
  99874. */
  99875. serialize(): any;
  99876. /**
  99877. * Gets the class name of the material
  99878. * @returns "BackgroundMaterial"
  99879. */
  99880. getClassName(): string;
  99881. /**
  99882. * Parse a JSON input to create back a background material.
  99883. * @param source The JSON data to parse
  99884. * @param scene The scene to create the parsed material in
  99885. * @param rootUrl The root url of the assets the material depends upon
  99886. * @returns the instantiated BackgroundMaterial.
  99887. */
  99888. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99889. }
  99890. }
  99891. declare module BABYLON {
  99892. /**
  99893. * Represents the different options available during the creation of
  99894. * a Environment helper.
  99895. *
  99896. * This can control the default ground, skybox and image processing setup of your scene.
  99897. */
  99898. export interface IEnvironmentHelperOptions {
  99899. /**
  99900. * Specifies wether or not to create a ground.
  99901. * True by default.
  99902. */
  99903. createGround: boolean;
  99904. /**
  99905. * Specifies the ground size.
  99906. * 15 by default.
  99907. */
  99908. groundSize: number;
  99909. /**
  99910. * The texture used on the ground for the main color.
  99911. * Comes from the BabylonJS CDN by default.
  99912. *
  99913. * Remarks: Can be either a texture or a url.
  99914. */
  99915. groundTexture: string | BaseTexture;
  99916. /**
  99917. * The color mixed in the ground texture by default.
  99918. * BabylonJS clearColor by default.
  99919. */
  99920. groundColor: Color3;
  99921. /**
  99922. * Specifies the ground opacity.
  99923. * 1 by default.
  99924. */
  99925. groundOpacity: number;
  99926. /**
  99927. * Enables the ground to receive shadows.
  99928. * True by default.
  99929. */
  99930. enableGroundShadow: boolean;
  99931. /**
  99932. * Helps preventing the shadow to be fully black on the ground.
  99933. * 0.5 by default.
  99934. */
  99935. groundShadowLevel: number;
  99936. /**
  99937. * Creates a mirror texture attach to the ground.
  99938. * false by default.
  99939. */
  99940. enableGroundMirror: boolean;
  99941. /**
  99942. * Specifies the ground mirror size ratio.
  99943. * 0.3 by default as the default kernel is 64.
  99944. */
  99945. groundMirrorSizeRatio: number;
  99946. /**
  99947. * Specifies the ground mirror blur kernel size.
  99948. * 64 by default.
  99949. */
  99950. groundMirrorBlurKernel: number;
  99951. /**
  99952. * Specifies the ground mirror visibility amount.
  99953. * 1 by default
  99954. */
  99955. groundMirrorAmount: number;
  99956. /**
  99957. * Specifies the ground mirror reflectance weight.
  99958. * This uses the standard weight of the background material to setup the fresnel effect
  99959. * of the mirror.
  99960. * 1 by default.
  99961. */
  99962. groundMirrorFresnelWeight: number;
  99963. /**
  99964. * Specifies the ground mirror Falloff distance.
  99965. * This can helps reducing the size of the reflection.
  99966. * 0 by Default.
  99967. */
  99968. groundMirrorFallOffDistance: number;
  99969. /**
  99970. * Specifies the ground mirror texture type.
  99971. * Unsigned Int by Default.
  99972. */
  99973. groundMirrorTextureType: number;
  99974. /**
  99975. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  99976. * the shown objects.
  99977. */
  99978. groundYBias: number;
  99979. /**
  99980. * Specifies wether or not to create a skybox.
  99981. * True by default.
  99982. */
  99983. createSkybox: boolean;
  99984. /**
  99985. * Specifies the skybox size.
  99986. * 20 by default.
  99987. */
  99988. skyboxSize: number;
  99989. /**
  99990. * The texture used on the skybox for the main color.
  99991. * Comes from the BabylonJS CDN by default.
  99992. *
  99993. * Remarks: Can be either a texture or a url.
  99994. */
  99995. skyboxTexture: string | BaseTexture;
  99996. /**
  99997. * The color mixed in the skybox texture by default.
  99998. * BabylonJS clearColor by default.
  99999. */
  100000. skyboxColor: Color3;
  100001. /**
  100002. * The background rotation around the Y axis of the scene.
  100003. * This helps aligning the key lights of your scene with the background.
  100004. * 0 by default.
  100005. */
  100006. backgroundYRotation: number;
  100007. /**
  100008. * Compute automatically the size of the elements to best fit with the scene.
  100009. */
  100010. sizeAuto: boolean;
  100011. /**
  100012. * Default position of the rootMesh if autoSize is not true.
  100013. */
  100014. rootPosition: Vector3;
  100015. /**
  100016. * Sets up the image processing in the scene.
  100017. * true by default.
  100018. */
  100019. setupImageProcessing: boolean;
  100020. /**
  100021. * The texture used as your environment texture in the scene.
  100022. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  100023. *
  100024. * Remarks: Can be either a texture or a url.
  100025. */
  100026. environmentTexture: string | BaseTexture;
  100027. /**
  100028. * The value of the exposure to apply to the scene.
  100029. * 0.6 by default if setupImageProcessing is true.
  100030. */
  100031. cameraExposure: number;
  100032. /**
  100033. * The value of the contrast to apply to the scene.
  100034. * 1.6 by default if setupImageProcessing is true.
  100035. */
  100036. cameraContrast: number;
  100037. /**
  100038. * Specifies wether or not tonemapping should be enabled in the scene.
  100039. * true by default if setupImageProcessing is true.
  100040. */
  100041. toneMappingEnabled: boolean;
  100042. }
  100043. /**
  100044. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  100045. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  100046. * It also helps with the default setup of your imageProcessing configuration.
  100047. */
  100048. export class EnvironmentHelper {
  100049. /**
  100050. * Default ground texture URL.
  100051. */
  100052. private static _groundTextureCDNUrl;
  100053. /**
  100054. * Default skybox texture URL.
  100055. */
  100056. private static _skyboxTextureCDNUrl;
  100057. /**
  100058. * Default environment texture URL.
  100059. */
  100060. private static _environmentTextureCDNUrl;
  100061. /**
  100062. * Creates the default options for the helper.
  100063. */
  100064. private static _getDefaultOptions;
  100065. private _rootMesh;
  100066. /**
  100067. * Gets the root mesh created by the helper.
  100068. */
  100069. readonly rootMesh: Mesh;
  100070. private _skybox;
  100071. /**
  100072. * Gets the skybox created by the helper.
  100073. */
  100074. readonly skybox: Nullable<Mesh>;
  100075. private _skyboxTexture;
  100076. /**
  100077. * Gets the skybox texture created by the helper.
  100078. */
  100079. readonly skyboxTexture: Nullable<BaseTexture>;
  100080. private _skyboxMaterial;
  100081. /**
  100082. * Gets the skybox material created by the helper.
  100083. */
  100084. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  100085. private _ground;
  100086. /**
  100087. * Gets the ground mesh created by the helper.
  100088. */
  100089. readonly ground: Nullable<Mesh>;
  100090. private _groundTexture;
  100091. /**
  100092. * Gets the ground texture created by the helper.
  100093. */
  100094. readonly groundTexture: Nullable<BaseTexture>;
  100095. private _groundMirror;
  100096. /**
  100097. * Gets the ground mirror created by the helper.
  100098. */
  100099. readonly groundMirror: Nullable<MirrorTexture>;
  100100. /**
  100101. * Gets the ground mirror render list to helps pushing the meshes
  100102. * you wish in the ground reflection.
  100103. */
  100104. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  100105. private _groundMaterial;
  100106. /**
  100107. * Gets the ground material created by the helper.
  100108. */
  100109. readonly groundMaterial: Nullable<BackgroundMaterial>;
  100110. /**
  100111. * Stores the creation options.
  100112. */
  100113. private readonly _scene;
  100114. private _options;
  100115. /**
  100116. * This observable will be notified with any error during the creation of the environment,
  100117. * mainly texture creation errors.
  100118. */
  100119. onErrorObservable: Observable<{
  100120. message?: string;
  100121. exception?: any;
  100122. }>;
  100123. /**
  100124. * constructor
  100125. * @param options Defines the options we want to customize the helper
  100126. * @param scene The scene to add the material to
  100127. */
  100128. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  100129. /**
  100130. * Updates the background according to the new options
  100131. * @param options
  100132. */
  100133. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  100134. /**
  100135. * Sets the primary color of all the available elements.
  100136. * @param color the main color to affect to the ground and the background
  100137. */
  100138. setMainColor(color: Color3): void;
  100139. /**
  100140. * Setup the image processing according to the specified options.
  100141. */
  100142. private _setupImageProcessing;
  100143. /**
  100144. * Setup the environment texture according to the specified options.
  100145. */
  100146. private _setupEnvironmentTexture;
  100147. /**
  100148. * Setup the background according to the specified options.
  100149. */
  100150. private _setupBackground;
  100151. /**
  100152. * Get the scene sizes according to the setup.
  100153. */
  100154. private _getSceneSize;
  100155. /**
  100156. * Setup the ground according to the specified options.
  100157. */
  100158. private _setupGround;
  100159. /**
  100160. * Setup the ground material according to the specified options.
  100161. */
  100162. private _setupGroundMaterial;
  100163. /**
  100164. * Setup the ground diffuse texture according to the specified options.
  100165. */
  100166. private _setupGroundDiffuseTexture;
  100167. /**
  100168. * Setup the ground mirror texture according to the specified options.
  100169. */
  100170. private _setupGroundMirrorTexture;
  100171. /**
  100172. * Setup the ground to receive the mirror texture.
  100173. */
  100174. private _setupMirrorInGroundMaterial;
  100175. /**
  100176. * Setup the skybox according to the specified options.
  100177. */
  100178. private _setupSkybox;
  100179. /**
  100180. * Setup the skybox material according to the specified options.
  100181. */
  100182. private _setupSkyboxMaterial;
  100183. /**
  100184. * Setup the skybox reflection texture according to the specified options.
  100185. */
  100186. private _setupSkyboxReflectionTexture;
  100187. private _errorHandler;
  100188. /**
  100189. * Dispose all the elements created by the Helper.
  100190. */
  100191. dispose(): void;
  100192. }
  100193. }
  100194. declare module BABYLON {
  100195. /**
  100196. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  100197. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  100198. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  100199. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100200. */
  100201. export class PhotoDome extends TransformNode {
  100202. private _useDirectMapping;
  100203. /**
  100204. * The texture being displayed on the sphere
  100205. */
  100206. protected _photoTexture: Texture;
  100207. /**
  100208. * Gets or sets the texture being displayed on the sphere
  100209. */
  100210. photoTexture: Texture;
  100211. /**
  100212. * Observable raised when an error occured while loading the 360 image
  100213. */
  100214. onLoadErrorObservable: Observable<string>;
  100215. /**
  100216. * The skybox material
  100217. */
  100218. protected _material: BackgroundMaterial;
  100219. /**
  100220. * The surface used for the skybox
  100221. */
  100222. protected _mesh: Mesh;
  100223. /**
  100224. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100225. * Also see the options.resolution property.
  100226. */
  100227. fovMultiplier: number;
  100228. /**
  100229. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  100230. * @param name Element's name, child elements will append suffixes for their own names.
  100231. * @param urlsOfPhoto defines the url of the photo to display
  100232. * @param options defines an object containing optional or exposed sub element properties
  100233. * @param onError defines a callback called when an error occured while loading the texture
  100234. */
  100235. constructor(name: string, urlOfPhoto: string, options: {
  100236. resolution?: number;
  100237. size?: number;
  100238. useDirectMapping?: boolean;
  100239. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100240. /**
  100241. * Releases resources associated with this node.
  100242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100244. */
  100245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100246. }
  100247. }
  100248. declare module BABYLON {
  100249. /**
  100250. * Class used to host texture specific utilities
  100251. */
  100252. export class TextureTools {
  100253. /**
  100254. * Uses the GPU to create a copy texture rescaled at a given size
  100255. * @param texture Texture to copy from
  100256. * @param width defines the desired width
  100257. * @param height defines the desired height
  100258. * @param useBilinearMode defines if bilinear mode has to be used
  100259. * @return the generated texture
  100260. */
  100261. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100262. /**
  100263. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100264. * @param scene defines the hosting scene
  100265. * @returns the environment BRDF texture
  100266. */
  100267. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100268. private static _environmentBRDFBase64Texture;
  100269. }
  100270. }
  100271. declare module BABYLON {
  100272. /**
  100273. * @hidden
  100274. */
  100275. export interface IMaterialClearCoatDefines {
  100276. CLEARCOAT: boolean;
  100277. CLEARCOAT_DEFAULTIOR: boolean;
  100278. CLEARCOAT_TEXTURE: boolean;
  100279. CLEARCOAT_TEXTUREDIRECTUV: number;
  100280. CLEARCOAT_BUMP: boolean;
  100281. CLEARCOAT_BUMPDIRECTUV: number;
  100282. CLEARCOAT_TINT: boolean;
  100283. CLEARCOAT_TINT_TEXTURE: boolean;
  100284. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100285. /** @hidden */
  100286. _areTexturesDirty: boolean;
  100287. }
  100288. /**
  100289. * Define the code related to the clear coat parameters of the pbr material.
  100290. */
  100291. export class PBRClearCoatConfiguration {
  100292. /**
  100293. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100294. * The default fits with a polyurethane material.
  100295. */
  100296. private static readonly _DefaultIndiceOfRefraction;
  100297. private _isEnabled;
  100298. /**
  100299. * Defines if the clear coat is enabled in the material.
  100300. */
  100301. isEnabled: boolean;
  100302. /**
  100303. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100304. */
  100305. intensity: number;
  100306. /**
  100307. * Defines the clear coat layer roughness.
  100308. */
  100309. roughness: number;
  100310. private _indiceOfRefraction;
  100311. /**
  100312. * Defines the indice of refraction of the clear coat.
  100313. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100314. * The default fits with a polyurethane material.
  100315. * Changing the default value is more performance intensive.
  100316. */
  100317. indiceOfRefraction: number;
  100318. private _texture;
  100319. /**
  100320. * Stores the clear coat values in a texture.
  100321. */
  100322. texture: Nullable<BaseTexture>;
  100323. private _bumpTexture;
  100324. /**
  100325. * Define the clear coat specific bump texture.
  100326. */
  100327. bumpTexture: Nullable<BaseTexture>;
  100328. private _isTintEnabled;
  100329. /**
  100330. * Defines if the clear coat tint is enabled in the material.
  100331. */
  100332. isTintEnabled: boolean;
  100333. /**
  100334. * Defines if the clear coat tint is enabled in the material.
  100335. * This is only use if tint is enabled
  100336. */
  100337. tintColor: Color3;
  100338. /**
  100339. * Defines if the distance at which the tint color should be found in the
  100340. * clear coat media.
  100341. * This is only use if tint is enabled
  100342. */
  100343. tintColorAtDistance: number;
  100344. /**
  100345. * Defines the clear coat layer thickness.
  100346. * This is only use if tint is enabled
  100347. */
  100348. tintThickness: number;
  100349. private _tintTexture;
  100350. /**
  100351. * Stores the clear tint values in a texture.
  100352. * rgb is tint
  100353. * a is a thickness factor
  100354. */
  100355. tintTexture: Nullable<BaseTexture>;
  100356. /** @hidden */
  100357. private _internalMarkAllSubMeshesAsTexturesDirty;
  100358. /** @hidden */
  100359. _markAllSubMeshesAsTexturesDirty(): void;
  100360. /**
  100361. * Instantiate a new istance of clear coat configuration.
  100362. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100363. */
  100364. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100365. /**
  100366. * Specifies that the submesh is ready to be used.
  100367. * @param defines the list of "defines" to update.
  100368. * @param scene defines the scene the material belongs to.
  100369. * @param engine defines the engine the material belongs to.
  100370. * @param disableBumpMap defines wether the material disables bump or not.
  100371. * @returns - boolean indicating that the submesh is ready or not.
  100372. */
  100373. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100374. /**
  100375. * Checks to see if a texture is used in the material.
  100376. * @param defines the list of "defines" to update.
  100377. * @param scene defines the scene to the material belongs to.
  100378. */
  100379. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100380. /**
  100381. * Binds the material data.
  100382. * @param uniformBuffer defines the Uniform buffer to fill in.
  100383. * @param scene defines the scene the material belongs to.
  100384. * @param engine defines the engine the material belongs to.
  100385. * @param disableBumpMap defines wether the material disables bump or not.
  100386. * @param isFrozen defines wether the material is frozen or not.
  100387. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100388. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100389. */
  100390. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100391. /**
  100392. * Checks to see if a texture is used in the material.
  100393. * @param texture - Base texture to use.
  100394. * @returns - Boolean specifying if a texture is used in the material.
  100395. */
  100396. hasTexture(texture: BaseTexture): boolean;
  100397. /**
  100398. * Returns an array of the actively used textures.
  100399. * @param activeTextures Array of BaseTextures
  100400. */
  100401. getActiveTextures(activeTextures: BaseTexture[]): void;
  100402. /**
  100403. * Returns the animatable textures.
  100404. * @param animatables Array of animatable textures.
  100405. */
  100406. getAnimatables(animatables: IAnimatable[]): void;
  100407. /**
  100408. * Disposes the resources of the material.
  100409. * @param forceDisposeTextures - Forces the disposal of all textures.
  100410. */
  100411. dispose(forceDisposeTextures?: boolean): void;
  100412. /**
  100413. * Get the current class name of the texture useful for serialization or dynamic coding.
  100414. * @returns "PBRClearCoatConfiguration"
  100415. */
  100416. getClassName(): string;
  100417. /**
  100418. * Add fallbacks to the effect fallbacks list.
  100419. * @param defines defines the Base texture to use.
  100420. * @param fallbacks defines the current fallback list.
  100421. * @param currentRank defines the current fallback rank.
  100422. * @returns the new fallback rank.
  100423. */
  100424. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100425. /**
  100426. * Add the required uniforms to the current list.
  100427. * @param uniforms defines the current uniform list.
  100428. */
  100429. static AddUniforms(uniforms: string[]): void;
  100430. /**
  100431. * Add the required samplers to the current list.
  100432. * @param samplers defines the current sampler list.
  100433. */
  100434. static AddSamplers(samplers: string[]): void;
  100435. /**
  100436. * Add the required uniforms to the current buffer.
  100437. * @param uniformBuffer defines the current uniform buffer.
  100438. */
  100439. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100440. /**
  100441. * Makes a duplicate of the current configuration into another one.
  100442. * @param clearCoatConfiguration define the config where to copy the info
  100443. */
  100444. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100445. /**
  100446. * Serializes this clear coat configuration.
  100447. * @returns - An object with the serialized config.
  100448. */
  100449. serialize(): any;
  100450. /**
  100451. * Parses a Clear Coat Configuration from a serialized object.
  100452. * @param source - Serialized object.
  100453. */
  100454. parse(source: any): void;
  100455. }
  100456. }
  100457. declare module BABYLON {
  100458. /**
  100459. * @hidden
  100460. */
  100461. export interface IMaterialAnisotropicDefines {
  100462. ANISOTROPIC: boolean;
  100463. ANISOTROPIC_TEXTURE: boolean;
  100464. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100465. MAINUV1: boolean;
  100466. _areTexturesDirty: boolean;
  100467. _needUVs: boolean;
  100468. }
  100469. /**
  100470. * Define the code related to the anisotropic parameters of the pbr material.
  100471. */
  100472. export class PBRAnisotropicConfiguration {
  100473. private _isEnabled;
  100474. /**
  100475. * Defines if the anisotropy is enabled in the material.
  100476. */
  100477. isEnabled: boolean;
  100478. /**
  100479. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100480. */
  100481. intensity: number;
  100482. /**
  100483. * Defines if the effect is along the tangents, bitangents or in between.
  100484. * By default, the effect is "strectching" the highlights along the tangents.
  100485. */
  100486. direction: Vector2;
  100487. private _texture;
  100488. /**
  100489. * Stores the anisotropy values in a texture.
  100490. * rg is direction (like normal from -1 to 1)
  100491. * b is a intensity
  100492. */
  100493. texture: Nullable<BaseTexture>;
  100494. /** @hidden */
  100495. private _internalMarkAllSubMeshesAsTexturesDirty;
  100496. /** @hidden */
  100497. _markAllSubMeshesAsTexturesDirty(): void;
  100498. /**
  100499. * Instantiate a new istance of anisotropy configuration.
  100500. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100501. */
  100502. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100503. /**
  100504. * Specifies that the submesh is ready to be used.
  100505. * @param defines the list of "defines" to update.
  100506. * @param scene defines the scene the material belongs to.
  100507. * @returns - boolean indicating that the submesh is ready or not.
  100508. */
  100509. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  100510. /**
  100511. * Checks to see if a texture is used in the material.
  100512. * @param defines the list of "defines" to update.
  100513. * @param mesh the mesh we are preparing the defines for.
  100514. * @param scene defines the scene the material belongs to.
  100515. */
  100516. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  100517. /**
  100518. * Binds the material data.
  100519. * @param uniformBuffer defines the Uniform buffer to fill in.
  100520. * @param scene defines the scene the material belongs to.
  100521. * @param isFrozen defines wether the material is frozen or not.
  100522. */
  100523. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100524. /**
  100525. * Checks to see if a texture is used in the material.
  100526. * @param texture - Base texture to use.
  100527. * @returns - Boolean specifying if a texture is used in the material.
  100528. */
  100529. hasTexture(texture: BaseTexture): boolean;
  100530. /**
  100531. * Returns an array of the actively used textures.
  100532. * @param activeTextures Array of BaseTextures
  100533. */
  100534. getActiveTextures(activeTextures: BaseTexture[]): void;
  100535. /**
  100536. * Returns the animatable textures.
  100537. * @param animatables Array of animatable textures.
  100538. */
  100539. getAnimatables(animatables: IAnimatable[]): void;
  100540. /**
  100541. * Disposes the resources of the material.
  100542. * @param forceDisposeTextures - Forces the disposal of all textures.
  100543. */
  100544. dispose(forceDisposeTextures?: boolean): void;
  100545. /**
  100546. * Get the current class name of the texture useful for serialization or dynamic coding.
  100547. * @returns "PBRAnisotropicConfiguration"
  100548. */
  100549. getClassName(): string;
  100550. /**
  100551. * Add fallbacks to the effect fallbacks list.
  100552. * @param defines defines the Base texture to use.
  100553. * @param fallbacks defines the current fallback list.
  100554. * @param currentRank defines the current fallback rank.
  100555. * @returns the new fallback rank.
  100556. */
  100557. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100558. /**
  100559. * Add the required uniforms to the current list.
  100560. * @param uniforms defines the current uniform list.
  100561. */
  100562. static AddUniforms(uniforms: string[]): void;
  100563. /**
  100564. * Add the required uniforms to the current buffer.
  100565. * @param uniformBuffer defines the current uniform buffer.
  100566. */
  100567. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100568. /**
  100569. * Add the required samplers to the current list.
  100570. * @param samplers defines the current sampler list.
  100571. */
  100572. static AddSamplers(samplers: string[]): void;
  100573. /**
  100574. * Makes a duplicate of the current configuration into another one.
  100575. * @param anisotropicConfiguration define the config where to copy the info
  100576. */
  100577. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100578. /**
  100579. * Serializes this anisotropy configuration.
  100580. * @returns - An object with the serialized config.
  100581. */
  100582. serialize(): any;
  100583. /**
  100584. * Parses a anisotropy Configuration from a serialized object.
  100585. * @param source - Serialized object.
  100586. */
  100587. parse(source: any): void;
  100588. }
  100589. }
  100590. declare module BABYLON {
  100591. /**
  100592. * @hidden
  100593. */
  100594. export interface IMaterialBRDFDefines {
  100595. BRDF_V_HEIGHT_CORRELATED: boolean;
  100596. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100597. /** @hidden */
  100598. _areMiscDirty: boolean;
  100599. }
  100600. /**
  100601. * Define the code related to the BRDF parameters of the pbr material.
  100602. */
  100603. export class PBRBRDFConfiguration {
  100604. private _useEnergyConservation;
  100605. /**
  100606. * Defines if the material uses energy conservation.
  100607. */
  100608. useEnergyConservation: boolean;
  100609. private _useSmithVisibilityHeightCorrelated;
  100610. /**
  100611. * LEGACY Mode set to false
  100612. * Defines if the material uses height smith correlated visibility term.
  100613. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100614. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100615. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100616. * Not relying on height correlated will also disable energy conservation.
  100617. */
  100618. useSmithVisibilityHeightCorrelated: boolean;
  100619. /** @hidden */
  100620. private _internalMarkAllSubMeshesAsMiscDirty;
  100621. /** @hidden */
  100622. _markAllSubMeshesAsMiscDirty(): void;
  100623. /**
  100624. * Instantiate a new istance of clear coat configuration.
  100625. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100626. */
  100627. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100628. /**
  100629. * Checks to see if a texture is used in the material.
  100630. * @param defines the list of "defines" to update.
  100631. */
  100632. prepareDefines(defines: IMaterialBRDFDefines): void;
  100633. /**
  100634. * Get the current class name of the texture useful for serialization or dynamic coding.
  100635. * @returns "PBRClearCoatConfiguration"
  100636. */
  100637. getClassName(): string;
  100638. /**
  100639. * Makes a duplicate of the current configuration into another one.
  100640. * @param brdfConfiguration define the config where to copy the info
  100641. */
  100642. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100643. /**
  100644. * Serializes this BRDF configuration.
  100645. * @returns - An object with the serialized config.
  100646. */
  100647. serialize(): any;
  100648. /**
  100649. * Parses a BRDF Configuration from a serialized object.
  100650. * @param source - Serialized object.
  100651. */
  100652. parse(source: any): void;
  100653. }
  100654. }
  100655. declare module BABYLON {
  100656. /**
  100657. * @hidden
  100658. */
  100659. export interface IMaterialSheenDefines {
  100660. SHEEN: boolean;
  100661. SHEEN_TEXTURE: boolean;
  100662. SHEEN_TEXTUREDIRECTUV: number;
  100663. SHEEN_LINKWITHALBEDO: boolean;
  100664. /** @hidden */
  100665. _areTexturesDirty: boolean;
  100666. }
  100667. /**
  100668. * Define the code related to the Sheen parameters of the pbr material.
  100669. */
  100670. export class PBRSheenConfiguration {
  100671. private _isEnabled;
  100672. /**
  100673. * Defines if the material uses sheen.
  100674. */
  100675. isEnabled: boolean;
  100676. private _linkSheenWithAlbedo;
  100677. /**
  100678. * Defines if the sheen is linked to the sheen color.
  100679. */
  100680. linkSheenWithAlbedo: boolean;
  100681. /**
  100682. * Defines the sheen intensity.
  100683. */
  100684. intensity: number;
  100685. /**
  100686. * Defines the sheen color.
  100687. */
  100688. color: Color3;
  100689. private _texture;
  100690. /**
  100691. * Stores the sheen tint values in a texture.
  100692. * rgb is tint
  100693. * a is a intensity
  100694. */
  100695. texture: Nullable<BaseTexture>;
  100696. /** @hidden */
  100697. private _internalMarkAllSubMeshesAsTexturesDirty;
  100698. /** @hidden */
  100699. _markAllSubMeshesAsTexturesDirty(): void;
  100700. /**
  100701. * Instantiate a new istance of clear coat configuration.
  100702. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100703. */
  100704. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100705. /**
  100706. * Specifies that the submesh is ready to be used.
  100707. * @param defines the list of "defines" to update.
  100708. * @param scene defines the scene the material belongs to.
  100709. * @returns - boolean indicating that the submesh is ready or not.
  100710. */
  100711. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  100712. /**
  100713. * Checks to see if a texture is used in the material.
  100714. * @param defines the list of "defines" to update.
  100715. * @param scene defines the scene the material belongs to.
  100716. */
  100717. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  100718. /**
  100719. * Binds the material data.
  100720. * @param uniformBuffer defines the Uniform buffer to fill in.
  100721. * @param scene defines the scene the material belongs to.
  100722. * @param isFrozen defines wether the material is frozen or not.
  100723. */
  100724. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100725. /**
  100726. * Checks to see if a texture is used in the material.
  100727. * @param texture - Base texture to use.
  100728. * @returns - Boolean specifying if a texture is used in the material.
  100729. */
  100730. hasTexture(texture: BaseTexture): boolean;
  100731. /**
  100732. * Returns an array of the actively used textures.
  100733. * @param activeTextures Array of BaseTextures
  100734. */
  100735. getActiveTextures(activeTextures: BaseTexture[]): void;
  100736. /**
  100737. * Returns the animatable textures.
  100738. * @param animatables Array of animatable textures.
  100739. */
  100740. getAnimatables(animatables: IAnimatable[]): void;
  100741. /**
  100742. * Disposes the resources of the material.
  100743. * @param forceDisposeTextures - Forces the disposal of all textures.
  100744. */
  100745. dispose(forceDisposeTextures?: boolean): void;
  100746. /**
  100747. * Get the current class name of the texture useful for serialization or dynamic coding.
  100748. * @returns "PBRSheenConfiguration"
  100749. */
  100750. getClassName(): string;
  100751. /**
  100752. * Add fallbacks to the effect fallbacks list.
  100753. * @param defines defines the Base texture to use.
  100754. * @param fallbacks defines the current fallback list.
  100755. * @param currentRank defines the current fallback rank.
  100756. * @returns the new fallback rank.
  100757. */
  100758. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100759. /**
  100760. * Add the required uniforms to the current list.
  100761. * @param uniforms defines the current uniform list.
  100762. */
  100763. static AddUniforms(uniforms: string[]): void;
  100764. /**
  100765. * Add the required uniforms to the current buffer.
  100766. * @param uniformBuffer defines the current uniform buffer.
  100767. */
  100768. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100769. /**
  100770. * Add the required samplers to the current list.
  100771. * @param samplers defines the current sampler list.
  100772. */
  100773. static AddSamplers(samplers: string[]): void;
  100774. /**
  100775. * Makes a duplicate of the current configuration into another one.
  100776. * @param sheenConfiguration define the config where to copy the info
  100777. */
  100778. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  100779. /**
  100780. * Serializes this BRDF configuration.
  100781. * @returns - An object with the serialized config.
  100782. */
  100783. serialize(): any;
  100784. /**
  100785. * Parses a Sheen Configuration from a serialized object.
  100786. * @param source - Serialized object.
  100787. */
  100788. parse(source: any): void;
  100789. }
  100790. }
  100791. declare module BABYLON {
  100792. /** @hidden */
  100793. export var pbrFragmentDeclaration: {
  100794. name: string;
  100795. shader: string;
  100796. };
  100797. }
  100798. declare module BABYLON {
  100799. /** @hidden */
  100800. export var pbrUboDeclaration: {
  100801. name: string;
  100802. shader: string;
  100803. };
  100804. }
  100805. declare module BABYLON {
  100806. /** @hidden */
  100807. export var pbrFunctions: {
  100808. name: string;
  100809. shader: string;
  100810. };
  100811. }
  100812. declare module BABYLON {
  100813. /** @hidden */
  100814. export var harmonicsFunctions: {
  100815. name: string;
  100816. shader: string;
  100817. };
  100818. }
  100819. declare module BABYLON {
  100820. /** @hidden */
  100821. export var pbrPreLightingFunctions: {
  100822. name: string;
  100823. shader: string;
  100824. };
  100825. }
  100826. declare module BABYLON {
  100827. /** @hidden */
  100828. export var pbrFalloffLightingFunctions: {
  100829. name: string;
  100830. shader: string;
  100831. };
  100832. }
  100833. declare module BABYLON {
  100834. /** @hidden */
  100835. export var pbrLightingFunctions: {
  100836. name: string;
  100837. shader: string;
  100838. };
  100839. }
  100840. declare module BABYLON {
  100841. /** @hidden */
  100842. export var pbrDebug: {
  100843. name: string;
  100844. shader: string;
  100845. };
  100846. }
  100847. declare module BABYLON {
  100848. /** @hidden */
  100849. export var pbrPixelShader: {
  100850. name: string;
  100851. shader: string;
  100852. };
  100853. }
  100854. declare module BABYLON {
  100855. /** @hidden */
  100856. export var pbrVertexDeclaration: {
  100857. name: string;
  100858. shader: string;
  100859. };
  100860. }
  100861. declare module BABYLON {
  100862. /** @hidden */
  100863. export var pbrVertexShader: {
  100864. name: string;
  100865. shader: string;
  100866. };
  100867. }
  100868. declare module BABYLON {
  100869. /**
  100870. * The Physically based material base class of BJS.
  100871. *
  100872. * This offers the main features of a standard PBR material.
  100873. * For more information, please refer to the documentation :
  100874. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100875. */
  100876. export abstract class PBRBaseMaterial extends PushMaterial {
  100877. /**
  100878. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100879. */
  100880. static readonly PBRMATERIAL_OPAQUE: number;
  100881. /**
  100882. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100883. */
  100884. static readonly PBRMATERIAL_ALPHATEST: number;
  100885. /**
  100886. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100887. */
  100888. static readonly PBRMATERIAL_ALPHABLEND: number;
  100889. /**
  100890. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100891. * They are also discarded below the alpha cutoff threshold to improve performances.
  100892. */
  100893. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100894. /**
  100895. * Defines the default value of how much AO map is occluding the analytical lights
  100896. * (point spot...).
  100897. */
  100898. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100899. /**
  100900. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100901. */
  100902. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100903. /**
  100904. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100905. * to enhance interoperability with other engines.
  100906. */
  100907. static readonly LIGHTFALLOFF_GLTF: number;
  100908. /**
  100909. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100910. * to enhance interoperability with other materials.
  100911. */
  100912. static readonly LIGHTFALLOFF_STANDARD: number;
  100913. /**
  100914. * Intensity of the direct lights e.g. the four lights available in your scene.
  100915. * This impacts both the direct diffuse and specular highlights.
  100916. */
  100917. protected _directIntensity: number;
  100918. /**
  100919. * Intensity of the emissive part of the material.
  100920. * This helps controlling the emissive effect without modifying the emissive color.
  100921. */
  100922. protected _emissiveIntensity: number;
  100923. /**
  100924. * Intensity of the environment e.g. how much the environment will light the object
  100925. * either through harmonics for rough material or through the refelction for shiny ones.
  100926. */
  100927. protected _environmentIntensity: number;
  100928. /**
  100929. * This is a special control allowing the reduction of the specular highlights coming from the
  100930. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100931. */
  100932. protected _specularIntensity: number;
  100933. /**
  100934. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100935. */
  100936. private _lightingInfos;
  100937. /**
  100938. * Debug Control allowing disabling the bump map on this material.
  100939. */
  100940. protected _disableBumpMap: boolean;
  100941. /**
  100942. * AKA Diffuse Texture in standard nomenclature.
  100943. */
  100944. protected _albedoTexture: BaseTexture;
  100945. /**
  100946. * AKA Occlusion Texture in other nomenclature.
  100947. */
  100948. protected _ambientTexture: BaseTexture;
  100949. /**
  100950. * AKA Occlusion Texture Intensity in other nomenclature.
  100951. */
  100952. protected _ambientTextureStrength: number;
  100953. /**
  100954. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100955. * 1 means it completely occludes it
  100956. * 0 mean it has no impact
  100957. */
  100958. protected _ambientTextureImpactOnAnalyticalLights: number;
  100959. /**
  100960. * Stores the alpha values in a texture.
  100961. */
  100962. protected _opacityTexture: BaseTexture;
  100963. /**
  100964. * Stores the reflection values in a texture.
  100965. */
  100966. protected _reflectionTexture: BaseTexture;
  100967. /**
  100968. * Stores the refraction values in a texture.
  100969. */
  100970. protected _refractionTexture: BaseTexture;
  100971. /**
  100972. * Stores the emissive values in a texture.
  100973. */
  100974. protected _emissiveTexture: BaseTexture;
  100975. /**
  100976. * AKA Specular texture in other nomenclature.
  100977. */
  100978. protected _reflectivityTexture: BaseTexture;
  100979. /**
  100980. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100981. */
  100982. protected _metallicTexture: BaseTexture;
  100983. /**
  100984. * Specifies the metallic scalar of the metallic/roughness workflow.
  100985. * Can also be used to scale the metalness values of the metallic texture.
  100986. */
  100987. protected _metallic: Nullable<number>;
  100988. /**
  100989. * Specifies the roughness scalar of the metallic/roughness workflow.
  100990. * Can also be used to scale the roughness values of the metallic texture.
  100991. */
  100992. protected _roughness: Nullable<number>;
  100993. /**
  100994. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100995. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100996. */
  100997. protected _microSurfaceTexture: BaseTexture;
  100998. /**
  100999. * Stores surface normal data used to displace a mesh in a texture.
  101000. */
  101001. protected _bumpTexture: BaseTexture;
  101002. /**
  101003. * Stores the pre-calculated light information of a mesh in a texture.
  101004. */
  101005. protected _lightmapTexture: BaseTexture;
  101006. /**
  101007. * The color of a material in ambient lighting.
  101008. */
  101009. protected _ambientColor: Color3;
  101010. /**
  101011. * AKA Diffuse Color in other nomenclature.
  101012. */
  101013. protected _albedoColor: Color3;
  101014. /**
  101015. * AKA Specular Color in other nomenclature.
  101016. */
  101017. protected _reflectivityColor: Color3;
  101018. /**
  101019. * The color applied when light is reflected from a material.
  101020. */
  101021. protected _reflectionColor: Color3;
  101022. /**
  101023. * The color applied when light is emitted from a material.
  101024. */
  101025. protected _emissiveColor: Color3;
  101026. /**
  101027. * AKA Glossiness in other nomenclature.
  101028. */
  101029. protected _microSurface: number;
  101030. /**
  101031. * source material index of refraction (IOR)' / 'destination material IOR.
  101032. */
  101033. protected _indexOfRefraction: number;
  101034. /**
  101035. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101036. */
  101037. protected _invertRefractionY: boolean;
  101038. /**
  101039. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101040. * Materials half opaque for instance using refraction could benefit from this control.
  101041. */
  101042. protected _linkRefractionWithTransparency: boolean;
  101043. /**
  101044. * Specifies that the material will use the light map as a show map.
  101045. */
  101046. protected _useLightmapAsShadowmap: boolean;
  101047. /**
  101048. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101049. * makes the reflect vector face the model (under horizon).
  101050. */
  101051. protected _useHorizonOcclusion: boolean;
  101052. /**
  101053. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101054. * too much the area relying on ambient texture to define their ambient occlusion.
  101055. */
  101056. protected _useRadianceOcclusion: boolean;
  101057. /**
  101058. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101059. */
  101060. protected _useAlphaFromAlbedoTexture: boolean;
  101061. /**
  101062. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  101063. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101064. */
  101065. protected _useSpecularOverAlpha: boolean;
  101066. /**
  101067. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101068. */
  101069. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101070. /**
  101071. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101072. */
  101073. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  101074. /**
  101075. * Specifies if the metallic texture contains the roughness information in its green channel.
  101076. */
  101077. protected _useRoughnessFromMetallicTextureGreen: boolean;
  101078. /**
  101079. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101080. */
  101081. protected _useMetallnessFromMetallicTextureBlue: boolean;
  101082. /**
  101083. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101084. */
  101085. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  101086. /**
  101087. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101088. */
  101089. protected _useAmbientInGrayScale: boolean;
  101090. /**
  101091. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101092. * The material will try to infer what glossiness each pixel should be.
  101093. */
  101094. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  101095. /**
  101096. * Defines the falloff type used in this material.
  101097. * It by default is Physical.
  101098. */
  101099. protected _lightFalloff: number;
  101100. /**
  101101. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101102. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101103. */
  101104. protected _useRadianceOverAlpha: boolean;
  101105. /**
  101106. * Allows using an object space normal map (instead of tangent space).
  101107. */
  101108. protected _useObjectSpaceNormalMap: boolean;
  101109. /**
  101110. * Allows using the bump map in parallax mode.
  101111. */
  101112. protected _useParallax: boolean;
  101113. /**
  101114. * Allows using the bump map in parallax occlusion mode.
  101115. */
  101116. protected _useParallaxOcclusion: boolean;
  101117. /**
  101118. * Controls the scale bias of the parallax mode.
  101119. */
  101120. protected _parallaxScaleBias: number;
  101121. /**
  101122. * If sets to true, disables all the lights affecting the material.
  101123. */
  101124. protected _disableLighting: boolean;
  101125. /**
  101126. * Number of Simultaneous lights allowed on the material.
  101127. */
  101128. protected _maxSimultaneousLights: number;
  101129. /**
  101130. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101131. */
  101132. protected _invertNormalMapX: boolean;
  101133. /**
  101134. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101135. */
  101136. protected _invertNormalMapY: boolean;
  101137. /**
  101138. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101139. */
  101140. protected _twoSidedLighting: boolean;
  101141. /**
  101142. * Defines the alpha limits in alpha test mode.
  101143. */
  101144. protected _alphaCutOff: number;
  101145. /**
  101146. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101147. */
  101148. protected _forceAlphaTest: boolean;
  101149. /**
  101150. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101151. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101152. */
  101153. protected _useAlphaFresnel: boolean;
  101154. /**
  101155. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101156. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101157. */
  101158. protected _useLinearAlphaFresnel: boolean;
  101159. /**
  101160. * The transparency mode of the material.
  101161. */
  101162. protected _transparencyMode: Nullable<number>;
  101163. /**
  101164. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  101165. * from cos thetav and roughness:
  101166. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  101167. */
  101168. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  101169. /**
  101170. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101171. */
  101172. protected _forceIrradianceInFragment: boolean;
  101173. /**
  101174. * Force normal to face away from face.
  101175. */
  101176. protected _forceNormalForward: boolean;
  101177. /**
  101178. * Enables specular anti aliasing in the PBR shader.
  101179. * It will both interacts on the Geometry for analytical and IBL lighting.
  101180. * It also prefilter the roughness map based on the bump values.
  101181. */
  101182. protected _enableSpecularAntiAliasing: boolean;
  101183. /**
  101184. * Default configuration related to image processing available in the PBR Material.
  101185. */
  101186. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101187. /**
  101188. * Keep track of the image processing observer to allow dispose and replace.
  101189. */
  101190. private _imageProcessingObserver;
  101191. /**
  101192. * Attaches a new image processing configuration to the PBR Material.
  101193. * @param configuration
  101194. */
  101195. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101196. /**
  101197. * Stores the available render targets.
  101198. */
  101199. private _renderTargets;
  101200. /**
  101201. * Sets the global ambient color for the material used in lighting calculations.
  101202. */
  101203. private _globalAmbientColor;
  101204. /**
  101205. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  101206. */
  101207. private _useLogarithmicDepth;
  101208. /**
  101209. * If set to true, no lighting calculations will be applied.
  101210. */
  101211. private _unlit;
  101212. private _debugMode;
  101213. /**
  101214. * @hidden
  101215. * This is reserved for the inspector.
  101216. * Defines the material debug mode.
  101217. * It helps seeing only some components of the material while troubleshooting.
  101218. */
  101219. debugMode: number;
  101220. /**
  101221. * @hidden
  101222. * This is reserved for the inspector.
  101223. * Specify from where on screen the debug mode should start.
  101224. * The value goes from -1 (full screen) to 1 (not visible)
  101225. * It helps with side by side comparison against the final render
  101226. * This defaults to -1
  101227. */
  101228. private debugLimit;
  101229. /**
  101230. * @hidden
  101231. * This is reserved for the inspector.
  101232. * As the default viewing range might not be enough (if the ambient is really small for instance)
  101233. * You can use the factor to better multiply the final value.
  101234. */
  101235. private debugFactor;
  101236. /**
  101237. * Defines the clear coat layer parameters for the material.
  101238. */
  101239. readonly clearCoat: PBRClearCoatConfiguration;
  101240. /**
  101241. * Defines the anisotropic parameters for the material.
  101242. */
  101243. readonly anisotropy: PBRAnisotropicConfiguration;
  101244. /**
  101245. * Defines the BRDF parameters for the material.
  101246. */
  101247. readonly brdf: PBRBRDFConfiguration;
  101248. /**
  101249. * Defines the Sheen parameters for the material.
  101250. */
  101251. readonly sheen: PBRSheenConfiguration;
  101252. /**
  101253. * Instantiates a new PBRMaterial instance.
  101254. *
  101255. * @param name The material name
  101256. * @param scene The scene the material will be use in.
  101257. */
  101258. constructor(name: string, scene: Scene);
  101259. /**
  101260. * Gets a boolean indicating that current material needs to register RTT
  101261. */
  101262. readonly hasRenderTargetTextures: boolean;
  101263. /**
  101264. * Gets the name of the material class.
  101265. */
  101266. getClassName(): string;
  101267. /**
  101268. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101269. */
  101270. /**
  101271. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101272. */
  101273. useLogarithmicDepth: boolean;
  101274. /**
  101275. * Gets the current transparency mode.
  101276. */
  101277. /**
  101278. * Sets the transparency mode of the material.
  101279. *
  101280. * | Value | Type | Description |
  101281. * | ----- | ----------------------------------- | ----------- |
  101282. * | 0 | OPAQUE | |
  101283. * | 1 | ALPHATEST | |
  101284. * | 2 | ALPHABLEND | |
  101285. * | 3 | ALPHATESTANDBLEND | |
  101286. *
  101287. */
  101288. transparencyMode: Nullable<number>;
  101289. /**
  101290. * Returns true if alpha blending should be disabled.
  101291. */
  101292. private readonly _disableAlphaBlending;
  101293. /**
  101294. * Specifies whether or not this material should be rendered in alpha blend mode.
  101295. */
  101296. needAlphaBlending(): boolean;
  101297. /**
  101298. * Specifies if the mesh will require alpha blending.
  101299. * @param mesh - BJS mesh.
  101300. */
  101301. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101302. /**
  101303. * Specifies whether or not this material should be rendered in alpha test mode.
  101304. */
  101305. needAlphaTesting(): boolean;
  101306. /**
  101307. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  101308. */
  101309. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  101310. /**
  101311. * Gets the texture used for the alpha test.
  101312. */
  101313. getAlphaTestTexture(): BaseTexture;
  101314. /**
  101315. * Specifies that the submesh is ready to be used.
  101316. * @param mesh - BJS mesh.
  101317. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  101318. * @param useInstances - Specifies that instances should be used.
  101319. * @returns - boolean indicating that the submesh is ready or not.
  101320. */
  101321. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101322. /**
  101323. * Specifies if the material uses metallic roughness workflow.
  101324. * @returns boolean specifiying if the material uses metallic roughness workflow.
  101325. */
  101326. isMetallicWorkflow(): boolean;
  101327. private _prepareEffect;
  101328. private _prepareDefines;
  101329. /**
  101330. * Force shader compilation
  101331. */
  101332. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  101333. clipPlane: boolean;
  101334. }>): void;
  101335. /**
  101336. * Initializes the uniform buffer layout for the shader.
  101337. */
  101338. buildUniformLayout(): void;
  101339. /**
  101340. * Unbinds the textures.
  101341. */
  101342. unbind(): void;
  101343. /**
  101344. * Binds the submesh data.
  101345. * @param world - The world matrix.
  101346. * @param mesh - The BJS mesh.
  101347. * @param subMesh - A submesh of the BJS mesh.
  101348. */
  101349. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101350. /**
  101351. * Returns the animatable textures.
  101352. * @returns - Array of animatable textures.
  101353. */
  101354. getAnimatables(): IAnimatable[];
  101355. /**
  101356. * Returns the texture used for reflections.
  101357. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  101358. */
  101359. private _getReflectionTexture;
  101360. /**
  101361. * Returns the texture used for refraction or null if none is used.
  101362. * @returns - Refection texture if present. If no refraction texture and refraction
  101363. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101364. */
  101365. private _getRefractionTexture;
  101366. /**
  101367. * Returns an array of the actively used textures.
  101368. * @returns - Array of BaseTextures
  101369. */
  101370. getActiveTextures(): BaseTexture[];
  101371. /**
  101372. * Checks to see if a texture is used in the material.
  101373. * @param texture - Base texture to use.
  101374. * @returns - Boolean specifying if a texture is used in the material.
  101375. */
  101376. hasTexture(texture: BaseTexture): boolean;
  101377. /**
  101378. * Disposes the resources of the material.
  101379. * @param forceDisposeEffect - Forces the disposal of effects.
  101380. * @param forceDisposeTextures - Forces the disposal of all textures.
  101381. */
  101382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101383. }
  101384. }
  101385. declare module BABYLON {
  101386. /**
  101387. * The Physically based material of BJS.
  101388. *
  101389. * This offers the main features of a standard PBR material.
  101390. * For more information, please refer to the documentation :
  101391. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101392. */
  101393. export class PBRMaterial extends PBRBaseMaterial {
  101394. /**
  101395. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101396. */
  101397. static readonly PBRMATERIAL_OPAQUE: number;
  101398. /**
  101399. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101400. */
  101401. static readonly PBRMATERIAL_ALPHATEST: number;
  101402. /**
  101403. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101404. */
  101405. static readonly PBRMATERIAL_ALPHABLEND: number;
  101406. /**
  101407. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101408. * They are also discarded below the alpha cutoff threshold to improve performances.
  101409. */
  101410. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101411. /**
  101412. * Defines the default value of how much AO map is occluding the analytical lights
  101413. * (point spot...).
  101414. */
  101415. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101416. /**
  101417. * Intensity of the direct lights e.g. the four lights available in your scene.
  101418. * This impacts both the direct diffuse and specular highlights.
  101419. */
  101420. directIntensity: number;
  101421. /**
  101422. * Intensity of the emissive part of the material.
  101423. * This helps controlling the emissive effect without modifying the emissive color.
  101424. */
  101425. emissiveIntensity: number;
  101426. /**
  101427. * Intensity of the environment e.g. how much the environment will light the object
  101428. * either through harmonics for rough material or through the refelction for shiny ones.
  101429. */
  101430. environmentIntensity: number;
  101431. /**
  101432. * This is a special control allowing the reduction of the specular highlights coming from the
  101433. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101434. */
  101435. specularIntensity: number;
  101436. /**
  101437. * Debug Control allowing disabling the bump map on this material.
  101438. */
  101439. disableBumpMap: boolean;
  101440. /**
  101441. * AKA Diffuse Texture in standard nomenclature.
  101442. */
  101443. albedoTexture: BaseTexture;
  101444. /**
  101445. * AKA Occlusion Texture in other nomenclature.
  101446. */
  101447. ambientTexture: BaseTexture;
  101448. /**
  101449. * AKA Occlusion Texture Intensity in other nomenclature.
  101450. */
  101451. ambientTextureStrength: number;
  101452. /**
  101453. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101454. * 1 means it completely occludes it
  101455. * 0 mean it has no impact
  101456. */
  101457. ambientTextureImpactOnAnalyticalLights: number;
  101458. /**
  101459. * Stores the alpha values in a texture.
  101460. */
  101461. opacityTexture: BaseTexture;
  101462. /**
  101463. * Stores the reflection values in a texture.
  101464. */
  101465. reflectionTexture: Nullable<BaseTexture>;
  101466. /**
  101467. * Stores the emissive values in a texture.
  101468. */
  101469. emissiveTexture: BaseTexture;
  101470. /**
  101471. * AKA Specular texture in other nomenclature.
  101472. */
  101473. reflectivityTexture: BaseTexture;
  101474. /**
  101475. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101476. */
  101477. metallicTexture: BaseTexture;
  101478. /**
  101479. * Specifies the metallic scalar of the metallic/roughness workflow.
  101480. * Can also be used to scale the metalness values of the metallic texture.
  101481. */
  101482. metallic: Nullable<number>;
  101483. /**
  101484. * Specifies the roughness scalar of the metallic/roughness workflow.
  101485. * Can also be used to scale the roughness values of the metallic texture.
  101486. */
  101487. roughness: Nullable<number>;
  101488. /**
  101489. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101490. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101491. */
  101492. microSurfaceTexture: BaseTexture;
  101493. /**
  101494. * Stores surface normal data used to displace a mesh in a texture.
  101495. */
  101496. bumpTexture: BaseTexture;
  101497. /**
  101498. * Stores the pre-calculated light information of a mesh in a texture.
  101499. */
  101500. lightmapTexture: BaseTexture;
  101501. /**
  101502. * Stores the refracted light information in a texture.
  101503. */
  101504. refractionTexture: BaseTexture;
  101505. /**
  101506. * The color of a material in ambient lighting.
  101507. */
  101508. ambientColor: Color3;
  101509. /**
  101510. * AKA Diffuse Color in other nomenclature.
  101511. */
  101512. albedoColor: Color3;
  101513. /**
  101514. * AKA Specular Color in other nomenclature.
  101515. */
  101516. reflectivityColor: Color3;
  101517. /**
  101518. * The color reflected from the material.
  101519. */
  101520. reflectionColor: Color3;
  101521. /**
  101522. * The color emitted from the material.
  101523. */
  101524. emissiveColor: Color3;
  101525. /**
  101526. * AKA Glossiness in other nomenclature.
  101527. */
  101528. microSurface: number;
  101529. /**
  101530. * source material index of refraction (IOR)' / 'destination material IOR.
  101531. */
  101532. indexOfRefraction: number;
  101533. /**
  101534. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101535. */
  101536. invertRefractionY: boolean;
  101537. /**
  101538. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101539. * Materials half opaque for instance using refraction could benefit from this control.
  101540. */
  101541. linkRefractionWithTransparency: boolean;
  101542. /**
  101543. * If true, the light map contains occlusion information instead of lighting info.
  101544. */
  101545. useLightmapAsShadowmap: boolean;
  101546. /**
  101547. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101548. */
  101549. useAlphaFromAlbedoTexture: boolean;
  101550. /**
  101551. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101552. */
  101553. forceAlphaTest: boolean;
  101554. /**
  101555. * Defines the alpha limits in alpha test mode.
  101556. */
  101557. alphaCutOff: number;
  101558. /**
  101559. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101560. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101561. */
  101562. useSpecularOverAlpha: boolean;
  101563. /**
  101564. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101565. */
  101566. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101567. /**
  101568. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101569. */
  101570. useRoughnessFromMetallicTextureAlpha: boolean;
  101571. /**
  101572. * Specifies if the metallic texture contains the roughness information in its green channel.
  101573. */
  101574. useRoughnessFromMetallicTextureGreen: boolean;
  101575. /**
  101576. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101577. */
  101578. useMetallnessFromMetallicTextureBlue: boolean;
  101579. /**
  101580. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101581. */
  101582. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101583. /**
  101584. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101585. */
  101586. useAmbientInGrayScale: boolean;
  101587. /**
  101588. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101589. * The material will try to infer what glossiness each pixel should be.
  101590. */
  101591. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101592. /**
  101593. * BJS is using an harcoded light falloff based on a manually sets up range.
  101594. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101595. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101596. */
  101597. /**
  101598. * BJS is using an harcoded light falloff based on a manually sets up range.
  101599. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101600. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101601. */
  101602. usePhysicalLightFalloff: boolean;
  101603. /**
  101604. * In order to support the falloff compatibility with gltf, a special mode has been added
  101605. * to reproduce the gltf light falloff.
  101606. */
  101607. /**
  101608. * In order to support the falloff compatibility with gltf, a special mode has been added
  101609. * to reproduce the gltf light falloff.
  101610. */
  101611. useGLTFLightFalloff: boolean;
  101612. /**
  101613. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101614. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101615. */
  101616. useRadianceOverAlpha: boolean;
  101617. /**
  101618. * Allows using an object space normal map (instead of tangent space).
  101619. */
  101620. useObjectSpaceNormalMap: boolean;
  101621. /**
  101622. * Allows using the bump map in parallax mode.
  101623. */
  101624. useParallax: boolean;
  101625. /**
  101626. * Allows using the bump map in parallax occlusion mode.
  101627. */
  101628. useParallaxOcclusion: boolean;
  101629. /**
  101630. * Controls the scale bias of the parallax mode.
  101631. */
  101632. parallaxScaleBias: number;
  101633. /**
  101634. * If sets to true, disables all the lights affecting the material.
  101635. */
  101636. disableLighting: boolean;
  101637. /**
  101638. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101639. */
  101640. forceIrradianceInFragment: boolean;
  101641. /**
  101642. * Number of Simultaneous lights allowed on the material.
  101643. */
  101644. maxSimultaneousLights: number;
  101645. /**
  101646. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101647. */
  101648. invertNormalMapX: boolean;
  101649. /**
  101650. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101651. */
  101652. invertNormalMapY: boolean;
  101653. /**
  101654. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101655. */
  101656. twoSidedLighting: boolean;
  101657. /**
  101658. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101659. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101660. */
  101661. useAlphaFresnel: boolean;
  101662. /**
  101663. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101664. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101665. */
  101666. useLinearAlphaFresnel: boolean;
  101667. /**
  101668. * Let user defines the brdf lookup texture used for IBL.
  101669. * A default 8bit version is embedded but you could point at :
  101670. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101671. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101672. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101673. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101674. */
  101675. environmentBRDFTexture: Nullable<BaseTexture>;
  101676. /**
  101677. * Force normal to face away from face.
  101678. */
  101679. forceNormalForward: boolean;
  101680. /**
  101681. * Enables specular anti aliasing in the PBR shader.
  101682. * It will both interacts on the Geometry for analytical and IBL lighting.
  101683. * It also prefilter the roughness map based on the bump values.
  101684. */
  101685. enableSpecularAntiAliasing: boolean;
  101686. /**
  101687. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101688. * makes the reflect vector face the model (under horizon).
  101689. */
  101690. useHorizonOcclusion: boolean;
  101691. /**
  101692. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101693. * too much the area relying on ambient texture to define their ambient occlusion.
  101694. */
  101695. useRadianceOcclusion: boolean;
  101696. /**
  101697. * If set to true, no lighting calculations will be applied.
  101698. */
  101699. unlit: boolean;
  101700. /**
  101701. * Gets the image processing configuration used either in this material.
  101702. */
  101703. /**
  101704. * Sets the Default image processing configuration used either in the this material.
  101705. *
  101706. * If sets to null, the scene one is in use.
  101707. */
  101708. imageProcessingConfiguration: ImageProcessingConfiguration;
  101709. /**
  101710. * Gets wether the color curves effect is enabled.
  101711. */
  101712. /**
  101713. * Sets wether the color curves effect is enabled.
  101714. */
  101715. cameraColorCurvesEnabled: boolean;
  101716. /**
  101717. * Gets wether the color grading effect is enabled.
  101718. */
  101719. /**
  101720. * Gets wether the color grading effect is enabled.
  101721. */
  101722. cameraColorGradingEnabled: boolean;
  101723. /**
  101724. * Gets wether tonemapping is enabled or not.
  101725. */
  101726. /**
  101727. * Sets wether tonemapping is enabled or not
  101728. */
  101729. cameraToneMappingEnabled: boolean;
  101730. /**
  101731. * The camera exposure used on this material.
  101732. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101733. * This corresponds to a photographic exposure.
  101734. */
  101735. /**
  101736. * The camera exposure used on this material.
  101737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101738. * This corresponds to a photographic exposure.
  101739. */
  101740. cameraExposure: number;
  101741. /**
  101742. * Gets The camera contrast used on this material.
  101743. */
  101744. /**
  101745. * Sets The camera contrast used on this material.
  101746. */
  101747. cameraContrast: number;
  101748. /**
  101749. * Gets the Color Grading 2D Lookup Texture.
  101750. */
  101751. /**
  101752. * Sets the Color Grading 2D Lookup Texture.
  101753. */
  101754. cameraColorGradingTexture: Nullable<BaseTexture>;
  101755. /**
  101756. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101757. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101758. * 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;
  101759. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101760. */
  101761. /**
  101762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101764. * 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;
  101765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101766. */
  101767. cameraColorCurves: Nullable<ColorCurves>;
  101768. /**
  101769. * Instantiates a new PBRMaterial instance.
  101770. *
  101771. * @param name The material name
  101772. * @param scene The scene the material will be use in.
  101773. */
  101774. constructor(name: string, scene: Scene);
  101775. /**
  101776. * Returns the name of this material class.
  101777. */
  101778. getClassName(): string;
  101779. /**
  101780. * Makes a duplicate of the current material.
  101781. * @param name - name to use for the new material.
  101782. */
  101783. clone(name: string): PBRMaterial;
  101784. /**
  101785. * Serializes this PBR Material.
  101786. * @returns - An object with the serialized material.
  101787. */
  101788. serialize(): any;
  101789. /**
  101790. * Parses a PBR Material from a serialized object.
  101791. * @param source - Serialized object.
  101792. * @param scene - BJS scene instance.
  101793. * @param rootUrl - url for the scene object
  101794. * @returns - PBRMaterial
  101795. */
  101796. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101797. }
  101798. }
  101799. declare module BABYLON {
  101800. /**
  101801. * Direct draw surface info
  101802. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  101803. */
  101804. export interface DDSInfo {
  101805. /**
  101806. * Width of the texture
  101807. */
  101808. width: number;
  101809. /**
  101810. * Width of the texture
  101811. */
  101812. height: number;
  101813. /**
  101814. * Number of Mipmaps for the texture
  101815. * @see https://en.wikipedia.org/wiki/Mipmap
  101816. */
  101817. mipmapCount: number;
  101818. /**
  101819. * If the textures format is a known fourCC format
  101820. * @see https://www.fourcc.org/
  101821. */
  101822. isFourCC: boolean;
  101823. /**
  101824. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  101825. */
  101826. isRGB: boolean;
  101827. /**
  101828. * If the texture is a lumincance format
  101829. */
  101830. isLuminance: boolean;
  101831. /**
  101832. * If this is a cube texture
  101833. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  101834. */
  101835. isCube: boolean;
  101836. /**
  101837. * If the texture is a compressed format eg. FOURCC_DXT1
  101838. */
  101839. isCompressed: boolean;
  101840. /**
  101841. * The dxgiFormat of the texture
  101842. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  101843. */
  101844. dxgiFormat: number;
  101845. /**
  101846. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  101847. */
  101848. textureType: number;
  101849. /**
  101850. * Sphericle polynomial created for the dds texture
  101851. */
  101852. sphericalPolynomial?: SphericalPolynomial;
  101853. }
  101854. /**
  101855. * Class used to provide DDS decompression tools
  101856. */
  101857. export class DDSTools {
  101858. /**
  101859. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  101860. */
  101861. static StoreLODInAlphaChannel: boolean;
  101862. /**
  101863. * Gets DDS information from an array buffer
  101864. * @param arrayBuffer defines the array buffer to read data from
  101865. * @returns the DDS information
  101866. */
  101867. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  101868. private static _FloatView;
  101869. private static _Int32View;
  101870. private static _ToHalfFloat;
  101871. private static _FromHalfFloat;
  101872. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  101873. private static _GetHalfFloatRGBAArrayBuffer;
  101874. private static _GetFloatRGBAArrayBuffer;
  101875. private static _GetFloatAsUIntRGBAArrayBuffer;
  101876. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  101877. private static _GetRGBAArrayBuffer;
  101878. private static _ExtractLongWordOrder;
  101879. private static _GetRGBArrayBuffer;
  101880. private static _GetLuminanceArrayBuffer;
  101881. /**
  101882. * Uploads DDS Levels to a Babylon Texture
  101883. * @hidden
  101884. */
  101885. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  101886. }
  101887. interface Engine {
  101888. /**
  101889. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  101890. * @param rootUrl defines the url where the file to load is located
  101891. * @param scene defines the current scene
  101892. * @param lodScale defines scale to apply to the mip map selection
  101893. * @param lodOffset defines offset to apply to the mip map selection
  101894. * @param onLoad defines an optional callback raised when the texture is loaded
  101895. * @param onError defines an optional callback raised if there is an issue to load the texture
  101896. * @param format defines the format of the data
  101897. * @param forcedExtension defines the extension to use to pick the right loader
  101898. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  101899. * @returns the cube texture as an InternalTexture
  101900. */
  101901. 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;
  101902. }
  101903. }
  101904. declare module BABYLON {
  101905. /**
  101906. * Implementation of the DDS Texture Loader.
  101907. * @hidden
  101908. */
  101909. export class _DDSTextureLoader implements IInternalTextureLoader {
  101910. /**
  101911. * Defines wether the loader supports cascade loading the different faces.
  101912. */
  101913. readonly supportCascades: boolean;
  101914. /**
  101915. * This returns if the loader support the current file information.
  101916. * @param extension defines the file extension of the file being loaded
  101917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101918. * @param fallback defines the fallback internal texture if any
  101919. * @param isBase64 defines whether the texture is encoded as a base64
  101920. * @param isBuffer defines whether the texture data are stored as a buffer
  101921. * @returns true if the loader can load the specified file
  101922. */
  101923. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  101924. /**
  101925. * Transform the url before loading if required.
  101926. * @param rootUrl the url of the texture
  101927. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101928. * @returns the transformed texture
  101929. */
  101930. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  101931. /**
  101932. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  101933. * @param rootUrl the url of the texture
  101934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101935. * @returns the fallback texture
  101936. */
  101937. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  101938. /**
  101939. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  101940. * @param data contains the texture data
  101941. * @param texture defines the BabylonJS internal texture
  101942. * @param createPolynomials will be true if polynomials have been requested
  101943. * @param onLoad defines the callback to trigger once the texture is ready
  101944. * @param onError defines the callback to trigger in case of error
  101945. */
  101946. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  101947. /**
  101948. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  101949. * @param data contains the texture data
  101950. * @param texture defines the BabylonJS internal texture
  101951. * @param callback defines the method to call once ready to upload
  101952. */
  101953. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  101954. }
  101955. }
  101956. declare module BABYLON {
  101957. /** @hidden */
  101958. export var rgbdEncodePixelShader: {
  101959. name: string;
  101960. shader: string;
  101961. };
  101962. }
  101963. declare module BABYLON {
  101964. /** @hidden */
  101965. export var rgbdDecodePixelShader: {
  101966. name: string;
  101967. shader: string;
  101968. };
  101969. }
  101970. declare module BABYLON {
  101971. /**
  101972. * Raw texture data and descriptor sufficient for WebGL texture upload
  101973. */
  101974. export interface EnvironmentTextureInfo {
  101975. /**
  101976. * Version of the environment map
  101977. */
  101978. version: number;
  101979. /**
  101980. * Width of image
  101981. */
  101982. width: number;
  101983. /**
  101984. * Irradiance information stored in the file.
  101985. */
  101986. irradiance: any;
  101987. /**
  101988. * Specular information stored in the file.
  101989. */
  101990. specular: any;
  101991. }
  101992. /**
  101993. * Sets of helpers addressing the serialization and deserialization of environment texture
  101994. * stored in a BabylonJS env file.
  101995. * Those files are usually stored as .env files.
  101996. */
  101997. export class EnvironmentTextureTools {
  101998. /**
  101999. * Magic number identifying the env file.
  102000. */
  102001. private static _MagicBytes;
  102002. /**
  102003. * Gets the environment info from an env file.
  102004. * @param data The array buffer containing the .env bytes.
  102005. * @returns the environment file info (the json header) if successfully parsed.
  102006. */
  102007. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102008. /**
  102009. * Creates an environment texture from a loaded cube texture.
  102010. * @param texture defines the cube texture to convert in env file
  102011. * @return a promise containing the environment data if succesfull.
  102012. */
  102013. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102014. /**
  102015. * Creates a JSON representation of the spherical data.
  102016. * @param texture defines the texture containing the polynomials
  102017. * @return the JSON representation of the spherical info
  102018. */
  102019. private static _CreateEnvTextureIrradiance;
  102020. /**
  102021. * Uploads the texture info contained in the env file to the GPU.
  102022. * @param texture defines the internal texture to upload to
  102023. * @param arrayBuffer defines the buffer cotaining the data to load
  102024. * @param info defines the texture info retrieved through the GetEnvInfo method
  102025. * @returns a promise
  102026. */
  102027. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102028. /**
  102029. * Uploads the levels of image data to the GPU.
  102030. * @param texture defines the internal texture to upload to
  102031. * @param imageData defines the array buffer views of image data [mipmap][face]
  102032. * @returns a promise
  102033. */
  102034. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102035. /**
  102036. * Uploads spherical polynomials information to the texture.
  102037. * @param texture defines the texture we are trying to upload the information to
  102038. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102039. */
  102040. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102041. /** @hidden */
  102042. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102043. }
  102044. }
  102045. declare module BABYLON {
  102046. /**
  102047. * Implementation of the ENV Texture Loader.
  102048. * @hidden
  102049. */
  102050. export class _ENVTextureLoader implements IInternalTextureLoader {
  102051. /**
  102052. * Defines wether the loader supports cascade loading the different faces.
  102053. */
  102054. readonly supportCascades: boolean;
  102055. /**
  102056. * This returns if the loader support the current file information.
  102057. * @param extension defines the file extension of the file being loaded
  102058. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102059. * @param fallback defines the fallback internal texture if any
  102060. * @param isBase64 defines whether the texture is encoded as a base64
  102061. * @param isBuffer defines whether the texture data are stored as a buffer
  102062. * @returns true if the loader can load the specified file
  102063. */
  102064. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102065. /**
  102066. * Transform the url before loading if required.
  102067. * @param rootUrl the url of the texture
  102068. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102069. * @returns the transformed texture
  102070. */
  102071. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102072. /**
  102073. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102074. * @param rootUrl the url of the texture
  102075. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102076. * @returns the fallback texture
  102077. */
  102078. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102079. /**
  102080. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102081. * @param data contains the texture data
  102082. * @param texture defines the BabylonJS internal texture
  102083. * @param createPolynomials will be true if polynomials have been requested
  102084. * @param onLoad defines the callback to trigger once the texture is ready
  102085. * @param onError defines the callback to trigger in case of error
  102086. */
  102087. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102088. /**
  102089. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102090. * @param data contains the texture data
  102091. * @param texture defines the BabylonJS internal texture
  102092. * @param callback defines the method to call once ready to upload
  102093. */
  102094. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102095. }
  102096. }
  102097. declare module BABYLON {
  102098. /**
  102099. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102100. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102101. */
  102102. export class KhronosTextureContainer {
  102103. /** contents of the KTX container file */
  102104. arrayBuffer: any;
  102105. private static HEADER_LEN;
  102106. private static COMPRESSED_2D;
  102107. private static COMPRESSED_3D;
  102108. private static TEX_2D;
  102109. private static TEX_3D;
  102110. /**
  102111. * Gets the openGL type
  102112. */
  102113. glType: number;
  102114. /**
  102115. * Gets the openGL type size
  102116. */
  102117. glTypeSize: number;
  102118. /**
  102119. * Gets the openGL format
  102120. */
  102121. glFormat: number;
  102122. /**
  102123. * Gets the openGL internal format
  102124. */
  102125. glInternalFormat: number;
  102126. /**
  102127. * Gets the base internal format
  102128. */
  102129. glBaseInternalFormat: number;
  102130. /**
  102131. * Gets image width in pixel
  102132. */
  102133. pixelWidth: number;
  102134. /**
  102135. * Gets image height in pixel
  102136. */
  102137. pixelHeight: number;
  102138. /**
  102139. * Gets image depth in pixels
  102140. */
  102141. pixelDepth: number;
  102142. /**
  102143. * Gets the number of array elements
  102144. */
  102145. numberOfArrayElements: number;
  102146. /**
  102147. * Gets the number of faces
  102148. */
  102149. numberOfFaces: number;
  102150. /**
  102151. * Gets the number of mipmap levels
  102152. */
  102153. numberOfMipmapLevels: number;
  102154. /**
  102155. * Gets the bytes of key value data
  102156. */
  102157. bytesOfKeyValueData: number;
  102158. /**
  102159. * Gets the load type
  102160. */
  102161. loadType: number;
  102162. /**
  102163. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102164. */
  102165. isInvalid: boolean;
  102166. /**
  102167. * Creates a new KhronosTextureContainer
  102168. * @param arrayBuffer contents of the KTX container file
  102169. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102170. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102171. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102172. */
  102173. constructor(
  102174. /** contents of the KTX container file */
  102175. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102176. /**
  102177. * Uploads KTX content to a Babylon Texture.
  102178. * It is assumed that the texture has already been created & is currently bound
  102179. * @hidden
  102180. */
  102181. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102182. private _upload2DCompressedLevels;
  102183. }
  102184. }
  102185. declare module BABYLON {
  102186. /**
  102187. * Implementation of the KTX Texture Loader.
  102188. * @hidden
  102189. */
  102190. export class _KTXTextureLoader implements IInternalTextureLoader {
  102191. /**
  102192. * Defines wether the loader supports cascade loading the different faces.
  102193. */
  102194. readonly supportCascades: boolean;
  102195. /**
  102196. * This returns if the loader support the current file information.
  102197. * @param extension defines the file extension of the file being loaded
  102198. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102199. * @param fallback defines the fallback internal texture if any
  102200. * @param isBase64 defines whether the texture is encoded as a base64
  102201. * @param isBuffer defines whether the texture data are stored as a buffer
  102202. * @returns true if the loader can load the specified file
  102203. */
  102204. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102205. /**
  102206. * Transform the url before loading if required.
  102207. * @param rootUrl the url of the texture
  102208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102209. * @returns the transformed texture
  102210. */
  102211. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102212. /**
  102213. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102214. * @param rootUrl the url of the texture
  102215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102216. * @returns the fallback texture
  102217. */
  102218. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102219. /**
  102220. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102221. * @param data contains the texture data
  102222. * @param texture defines the BabylonJS internal texture
  102223. * @param createPolynomials will be true if polynomials have been requested
  102224. * @param onLoad defines the callback to trigger once the texture is ready
  102225. * @param onError defines the callback to trigger in case of error
  102226. */
  102227. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102228. /**
  102229. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102230. * @param data contains the texture data
  102231. * @param texture defines the BabylonJS internal texture
  102232. * @param callback defines the method to call once ready to upload
  102233. */
  102234. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102235. }
  102236. }
  102237. declare module BABYLON {
  102238. /** @hidden */
  102239. export var _forceSceneHelpersToBundle: boolean;
  102240. interface Scene {
  102241. /**
  102242. * Creates a default light for the scene.
  102243. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  102244. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  102245. */
  102246. createDefaultLight(replace?: boolean): void;
  102247. /**
  102248. * Creates a default camera for the scene.
  102249. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  102250. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102251. * @param replace has default false, when true replaces the active camera in the scene
  102252. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  102253. */
  102254. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102255. /**
  102256. * Creates a default camera and a default light.
  102257. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  102258. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102259. * @param replace has the default false, when true replaces the active camera/light in the scene
  102260. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  102261. */
  102262. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102263. /**
  102264. * Creates a new sky box
  102265. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  102266. * @param environmentTexture defines the texture to use as environment texture
  102267. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  102268. * @param scale defines the overall scale of the skybox
  102269. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  102270. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  102271. * @returns a new mesh holding the sky box
  102272. */
  102273. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  102274. /**
  102275. * Creates a new environment
  102276. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  102277. * @param options defines the options you can use to configure the environment
  102278. * @returns the new EnvironmentHelper
  102279. */
  102280. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  102281. /**
  102282. * Creates a new VREXperienceHelper
  102283. * @see http://doc.babylonjs.com/how_to/webvr_helper
  102284. * @param webVROptions defines the options used to create the new VREXperienceHelper
  102285. * @returns a new VREXperienceHelper
  102286. */
  102287. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  102288. /**
  102289. * Creates a new XREXperienceHelper
  102290. * @see http://doc.babylonjs.com/how_to/webxr
  102291. * @returns a promise for a new XREXperienceHelper
  102292. */
  102293. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  102294. }
  102295. }
  102296. declare module BABYLON {
  102297. /**
  102298. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  102299. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  102300. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  102301. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102302. */
  102303. export class VideoDome extends TransformNode {
  102304. /**
  102305. * Define the video source as a Monoscopic panoramic 360 video.
  102306. */
  102307. static readonly MODE_MONOSCOPIC: number;
  102308. /**
  102309. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102310. */
  102311. static readonly MODE_TOPBOTTOM: number;
  102312. /**
  102313. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102314. */
  102315. static readonly MODE_SIDEBYSIDE: number;
  102316. private _useDirectMapping;
  102317. /**
  102318. * The video texture being displayed on the sphere
  102319. */
  102320. protected _videoTexture: VideoTexture;
  102321. /**
  102322. * Gets the video texture being displayed on the sphere
  102323. */
  102324. readonly videoTexture: VideoTexture;
  102325. /**
  102326. * The skybox material
  102327. */
  102328. protected _material: BackgroundMaterial;
  102329. /**
  102330. * The surface used for the skybox
  102331. */
  102332. protected _mesh: Mesh;
  102333. /**
  102334. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102335. * Also see the options.resolution property.
  102336. */
  102337. fovMultiplier: number;
  102338. private _videoMode;
  102339. /**
  102340. * Gets or set the current video mode for the video. It can be:
  102341. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  102342. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102343. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102344. */
  102345. videoMode: number;
  102346. /**
  102347. * Oberserver used in Stereoscopic VR Mode.
  102348. */
  102349. private _onBeforeCameraRenderObserver;
  102350. /**
  102351. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  102352. * @param name Element's name, child elements will append suffixes for their own names.
  102353. * @param urlsOrVideo defines the url(s) or the video element to use
  102354. * @param options An object containing optional or exposed sub element properties
  102355. */
  102356. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  102357. resolution?: number;
  102358. clickToPlay?: boolean;
  102359. autoPlay?: boolean;
  102360. loop?: boolean;
  102361. size?: number;
  102362. poster?: string;
  102363. useDirectMapping?: boolean;
  102364. }, scene: Scene);
  102365. private _changeVideoMode;
  102366. /**
  102367. * Releases resources associated with this node.
  102368. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102369. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102370. */
  102371. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102372. }
  102373. }
  102374. declare module BABYLON {
  102375. /**
  102376. * This class can be used to get instrumentation data from a Babylon engine
  102377. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102378. */
  102379. export class EngineInstrumentation implements IDisposable {
  102380. /**
  102381. * Define the instrumented engine.
  102382. */
  102383. engine: Engine;
  102384. private _captureGPUFrameTime;
  102385. private _gpuFrameTimeToken;
  102386. private _gpuFrameTime;
  102387. private _captureShaderCompilationTime;
  102388. private _shaderCompilationTime;
  102389. private _onBeginFrameObserver;
  102390. private _onEndFrameObserver;
  102391. private _onBeforeShaderCompilationObserver;
  102392. private _onAfterShaderCompilationObserver;
  102393. /**
  102394. * Gets the perf counter used for GPU frame time
  102395. */
  102396. readonly gpuFrameTimeCounter: PerfCounter;
  102397. /**
  102398. * Gets the GPU frame time capture status
  102399. */
  102400. /**
  102401. * Enable or disable the GPU frame time capture
  102402. */
  102403. captureGPUFrameTime: boolean;
  102404. /**
  102405. * Gets the perf counter used for shader compilation time
  102406. */
  102407. readonly shaderCompilationTimeCounter: PerfCounter;
  102408. /**
  102409. * Gets the shader compilation time capture status
  102410. */
  102411. /**
  102412. * Enable or disable the shader compilation time capture
  102413. */
  102414. captureShaderCompilationTime: boolean;
  102415. /**
  102416. * Instantiates a new engine instrumentation.
  102417. * This class can be used to get instrumentation data from a Babylon engine
  102418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102419. * @param engine Defines the engine to instrument
  102420. */
  102421. constructor(
  102422. /**
  102423. * Define the instrumented engine.
  102424. */
  102425. engine: Engine);
  102426. /**
  102427. * Dispose and release associated resources.
  102428. */
  102429. dispose(): void;
  102430. }
  102431. }
  102432. declare module BABYLON {
  102433. /**
  102434. * This class can be used to get instrumentation data from a Babylon engine
  102435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102436. */
  102437. export class SceneInstrumentation implements IDisposable {
  102438. /**
  102439. * Defines the scene to instrument
  102440. */
  102441. scene: Scene;
  102442. private _captureActiveMeshesEvaluationTime;
  102443. private _activeMeshesEvaluationTime;
  102444. private _captureRenderTargetsRenderTime;
  102445. private _renderTargetsRenderTime;
  102446. private _captureFrameTime;
  102447. private _frameTime;
  102448. private _captureRenderTime;
  102449. private _renderTime;
  102450. private _captureInterFrameTime;
  102451. private _interFrameTime;
  102452. private _captureParticlesRenderTime;
  102453. private _particlesRenderTime;
  102454. private _captureSpritesRenderTime;
  102455. private _spritesRenderTime;
  102456. private _capturePhysicsTime;
  102457. private _physicsTime;
  102458. private _captureAnimationsTime;
  102459. private _animationsTime;
  102460. private _captureCameraRenderTime;
  102461. private _cameraRenderTime;
  102462. private _onBeforeActiveMeshesEvaluationObserver;
  102463. private _onAfterActiveMeshesEvaluationObserver;
  102464. private _onBeforeRenderTargetsRenderObserver;
  102465. private _onAfterRenderTargetsRenderObserver;
  102466. private _onAfterRenderObserver;
  102467. private _onBeforeDrawPhaseObserver;
  102468. private _onAfterDrawPhaseObserver;
  102469. private _onBeforeAnimationsObserver;
  102470. private _onBeforeParticlesRenderingObserver;
  102471. private _onAfterParticlesRenderingObserver;
  102472. private _onBeforeSpritesRenderingObserver;
  102473. private _onAfterSpritesRenderingObserver;
  102474. private _onBeforePhysicsObserver;
  102475. private _onAfterPhysicsObserver;
  102476. private _onAfterAnimationsObserver;
  102477. private _onBeforeCameraRenderObserver;
  102478. private _onAfterCameraRenderObserver;
  102479. /**
  102480. * Gets the perf counter used for active meshes evaluation time
  102481. */
  102482. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  102483. /**
  102484. * Gets the active meshes evaluation time capture status
  102485. */
  102486. /**
  102487. * Enable or disable the active meshes evaluation time capture
  102488. */
  102489. captureActiveMeshesEvaluationTime: boolean;
  102490. /**
  102491. * Gets the perf counter used for render targets render time
  102492. */
  102493. readonly renderTargetsRenderTimeCounter: PerfCounter;
  102494. /**
  102495. * Gets the render targets render time capture status
  102496. */
  102497. /**
  102498. * Enable or disable the render targets render time capture
  102499. */
  102500. captureRenderTargetsRenderTime: boolean;
  102501. /**
  102502. * Gets the perf counter used for particles render time
  102503. */
  102504. readonly particlesRenderTimeCounter: PerfCounter;
  102505. /**
  102506. * Gets the particles render time capture status
  102507. */
  102508. /**
  102509. * Enable or disable the particles render time capture
  102510. */
  102511. captureParticlesRenderTime: boolean;
  102512. /**
  102513. * Gets the perf counter used for sprites render time
  102514. */
  102515. readonly spritesRenderTimeCounter: PerfCounter;
  102516. /**
  102517. * Gets the sprites render time capture status
  102518. */
  102519. /**
  102520. * Enable or disable the sprites render time capture
  102521. */
  102522. captureSpritesRenderTime: boolean;
  102523. /**
  102524. * Gets the perf counter used for physics time
  102525. */
  102526. readonly physicsTimeCounter: PerfCounter;
  102527. /**
  102528. * Gets the physics time capture status
  102529. */
  102530. /**
  102531. * Enable or disable the physics time capture
  102532. */
  102533. capturePhysicsTime: boolean;
  102534. /**
  102535. * Gets the perf counter used for animations time
  102536. */
  102537. readonly animationsTimeCounter: PerfCounter;
  102538. /**
  102539. * Gets the animations time capture status
  102540. */
  102541. /**
  102542. * Enable or disable the animations time capture
  102543. */
  102544. captureAnimationsTime: boolean;
  102545. /**
  102546. * Gets the perf counter used for frame time capture
  102547. */
  102548. readonly frameTimeCounter: PerfCounter;
  102549. /**
  102550. * Gets the frame time capture status
  102551. */
  102552. /**
  102553. * Enable or disable the frame time capture
  102554. */
  102555. captureFrameTime: boolean;
  102556. /**
  102557. * Gets the perf counter used for inter-frames time capture
  102558. */
  102559. readonly interFrameTimeCounter: PerfCounter;
  102560. /**
  102561. * Gets the inter-frames time capture status
  102562. */
  102563. /**
  102564. * Enable or disable the inter-frames time capture
  102565. */
  102566. captureInterFrameTime: boolean;
  102567. /**
  102568. * Gets the perf counter used for render time capture
  102569. */
  102570. readonly renderTimeCounter: PerfCounter;
  102571. /**
  102572. * Gets the render time capture status
  102573. */
  102574. /**
  102575. * Enable or disable the render time capture
  102576. */
  102577. captureRenderTime: boolean;
  102578. /**
  102579. * Gets the perf counter used for camera render time capture
  102580. */
  102581. readonly cameraRenderTimeCounter: PerfCounter;
  102582. /**
  102583. * Gets the camera render time capture status
  102584. */
  102585. /**
  102586. * Enable or disable the camera render time capture
  102587. */
  102588. captureCameraRenderTime: boolean;
  102589. /**
  102590. * Gets the perf counter used for draw calls
  102591. */
  102592. readonly drawCallsCounter: PerfCounter;
  102593. /**
  102594. * Gets the perf counter used for texture collisions
  102595. */
  102596. readonly textureCollisionsCounter: PerfCounter;
  102597. /**
  102598. * Instantiates a new scene instrumentation.
  102599. * This class can be used to get instrumentation data from a Babylon engine
  102600. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102601. * @param scene Defines the scene to instrument
  102602. */
  102603. constructor(
  102604. /**
  102605. * Defines the scene to instrument
  102606. */
  102607. scene: Scene);
  102608. /**
  102609. * Dispose and release associated resources.
  102610. */
  102611. dispose(): void;
  102612. }
  102613. }
  102614. declare module BABYLON {
  102615. /** @hidden */
  102616. export var glowMapGenerationPixelShader: {
  102617. name: string;
  102618. shader: string;
  102619. };
  102620. }
  102621. declare module BABYLON {
  102622. /** @hidden */
  102623. export var glowMapGenerationVertexShader: {
  102624. name: string;
  102625. shader: string;
  102626. };
  102627. }
  102628. declare module BABYLON {
  102629. /**
  102630. * Effect layer options. This helps customizing the behaviour
  102631. * of the effect layer.
  102632. */
  102633. export interface IEffectLayerOptions {
  102634. /**
  102635. * Multiplication factor apply to the canvas size to compute the render target size
  102636. * used to generated the objects (the smaller the faster).
  102637. */
  102638. mainTextureRatio: number;
  102639. /**
  102640. * Enforces a fixed size texture to ensure effect stability across devices.
  102641. */
  102642. mainTextureFixedSize?: number;
  102643. /**
  102644. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  102645. */
  102646. alphaBlendingMode: number;
  102647. /**
  102648. * The camera attached to the layer.
  102649. */
  102650. camera: Nullable<Camera>;
  102651. /**
  102652. * The rendering group to draw the layer in.
  102653. */
  102654. renderingGroupId: number;
  102655. }
  102656. /**
  102657. * The effect layer Helps adding post process effect blended with the main pass.
  102658. *
  102659. * This can be for instance use to generate glow or higlight effects on the scene.
  102660. *
  102661. * The effect layer class can not be used directly and is intented to inherited from to be
  102662. * customized per effects.
  102663. */
  102664. export abstract class EffectLayer {
  102665. private _vertexBuffers;
  102666. private _indexBuffer;
  102667. private _cachedDefines;
  102668. private _effectLayerMapGenerationEffect;
  102669. private _effectLayerOptions;
  102670. private _mergeEffect;
  102671. protected _scene: Scene;
  102672. protected _engine: Engine;
  102673. protected _maxSize: number;
  102674. protected _mainTextureDesiredSize: ISize;
  102675. protected _mainTexture: RenderTargetTexture;
  102676. protected _shouldRender: boolean;
  102677. protected _postProcesses: PostProcess[];
  102678. protected _textures: BaseTexture[];
  102679. protected _emissiveTextureAndColor: {
  102680. texture: Nullable<BaseTexture>;
  102681. color: Color4;
  102682. };
  102683. /**
  102684. * The name of the layer
  102685. */
  102686. name: string;
  102687. /**
  102688. * The clear color of the texture used to generate the glow map.
  102689. */
  102690. neutralColor: Color4;
  102691. /**
  102692. * Specifies wether the highlight layer is enabled or not.
  102693. */
  102694. isEnabled: boolean;
  102695. /**
  102696. * Gets the camera attached to the layer.
  102697. */
  102698. readonly camera: Nullable<Camera>;
  102699. /**
  102700. * Gets the rendering group id the layer should render in.
  102701. */
  102702. readonly renderingGroupId: number;
  102703. /**
  102704. * An event triggered when the effect layer has been disposed.
  102705. */
  102706. onDisposeObservable: Observable<EffectLayer>;
  102707. /**
  102708. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  102709. */
  102710. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  102711. /**
  102712. * An event triggered when the generated texture is being merged in the scene.
  102713. */
  102714. onBeforeComposeObservable: Observable<EffectLayer>;
  102715. /**
  102716. * An event triggered when the generated texture has been merged in the scene.
  102717. */
  102718. onAfterComposeObservable: Observable<EffectLayer>;
  102719. /**
  102720. * An event triggered when the efffect layer changes its size.
  102721. */
  102722. onSizeChangedObservable: Observable<EffectLayer>;
  102723. /** @hidden */
  102724. static _SceneComponentInitialization: (scene: Scene) => void;
  102725. /**
  102726. * Instantiates a new effect Layer and references it in the scene.
  102727. * @param name The name of the layer
  102728. * @param scene The scene to use the layer in
  102729. */
  102730. constructor(
  102731. /** The Friendly of the effect in the scene */
  102732. name: string, scene: Scene);
  102733. /**
  102734. * Get the effect name of the layer.
  102735. * @return The effect name
  102736. */
  102737. abstract getEffectName(): string;
  102738. /**
  102739. * Checks for the readiness of the element composing the layer.
  102740. * @param subMesh the mesh to check for
  102741. * @param useInstances specify wether or not to use instances to render the mesh
  102742. * @return true if ready otherwise, false
  102743. */
  102744. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102745. /**
  102746. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102747. * @returns true if the effect requires stencil during the main canvas render pass.
  102748. */
  102749. abstract needStencil(): boolean;
  102750. /**
  102751. * Create the merge effect. This is the shader use to blit the information back
  102752. * to the main canvas at the end of the scene rendering.
  102753. * @returns The effect containing the shader used to merge the effect on the main canvas
  102754. */
  102755. protected abstract _createMergeEffect(): Effect;
  102756. /**
  102757. * Creates the render target textures and post processes used in the effect layer.
  102758. */
  102759. protected abstract _createTextureAndPostProcesses(): void;
  102760. /**
  102761. * Implementation specific of rendering the generating effect on the main canvas.
  102762. * @param effect The effect used to render through
  102763. */
  102764. protected abstract _internalRender(effect: Effect): void;
  102765. /**
  102766. * Sets the required values for both the emissive texture and and the main color.
  102767. */
  102768. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102769. /**
  102770. * Free any resources and references associated to a mesh.
  102771. * Internal use
  102772. * @param mesh The mesh to free.
  102773. */
  102774. abstract _disposeMesh(mesh: Mesh): void;
  102775. /**
  102776. * Serializes this layer (Glow or Highlight for example)
  102777. * @returns a serialized layer object
  102778. */
  102779. abstract serialize?(): any;
  102780. /**
  102781. * Initializes the effect layer with the required options.
  102782. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  102783. */
  102784. protected _init(options: Partial<IEffectLayerOptions>): void;
  102785. /**
  102786. * Generates the index buffer of the full screen quad blending to the main canvas.
  102787. */
  102788. private _generateIndexBuffer;
  102789. /**
  102790. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  102791. */
  102792. private _genrateVertexBuffer;
  102793. /**
  102794. * Sets the main texture desired size which is the closest power of two
  102795. * of the engine canvas size.
  102796. */
  102797. private _setMainTextureSize;
  102798. /**
  102799. * Creates the main texture for the effect layer.
  102800. */
  102801. protected _createMainTexture(): void;
  102802. /**
  102803. * Adds specific effects defines.
  102804. * @param defines The defines to add specifics to.
  102805. */
  102806. protected _addCustomEffectDefines(defines: string[]): void;
  102807. /**
  102808. * Checks for the readiness of the element composing the layer.
  102809. * @param subMesh the mesh to check for
  102810. * @param useInstances specify wether or not to use instances to render the mesh
  102811. * @param emissiveTexture the associated emissive texture used to generate the glow
  102812. * @return true if ready otherwise, false
  102813. */
  102814. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  102815. /**
  102816. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  102817. */
  102818. render(): void;
  102819. /**
  102820. * Determine if a given mesh will be used in the current effect.
  102821. * @param mesh mesh to test
  102822. * @returns true if the mesh will be used
  102823. */
  102824. hasMesh(mesh: AbstractMesh): boolean;
  102825. /**
  102826. * Returns true if the layer contains information to display, otherwise false.
  102827. * @returns true if the glow layer should be rendered
  102828. */
  102829. shouldRender(): boolean;
  102830. /**
  102831. * Returns true if the mesh should render, otherwise false.
  102832. * @param mesh The mesh to render
  102833. * @returns true if it should render otherwise false
  102834. */
  102835. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  102836. /**
  102837. * Returns true if the mesh can be rendered, otherwise false.
  102838. * @param mesh The mesh to render
  102839. * @param material The material used on the mesh
  102840. * @returns true if it can be rendered otherwise false
  102841. */
  102842. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102843. /**
  102844. * Returns true if the mesh should render, otherwise false.
  102845. * @param mesh The mesh to render
  102846. * @returns true if it should render otherwise false
  102847. */
  102848. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  102849. /**
  102850. * Renders the submesh passed in parameter to the generation map.
  102851. */
  102852. protected _renderSubMesh(subMesh: SubMesh): void;
  102853. /**
  102854. * Rebuild the required buffers.
  102855. * @hidden Internal use only.
  102856. */
  102857. _rebuild(): void;
  102858. /**
  102859. * Dispose only the render target textures and post process.
  102860. */
  102861. private _disposeTextureAndPostProcesses;
  102862. /**
  102863. * Dispose the highlight layer and free resources.
  102864. */
  102865. dispose(): void;
  102866. /**
  102867. * Gets the class name of the effect layer
  102868. * @returns the string with the class name of the effect layer
  102869. */
  102870. getClassName(): string;
  102871. /**
  102872. * Creates an effect layer from parsed effect layer data
  102873. * @param parsedEffectLayer defines effect layer data
  102874. * @param scene defines the current scene
  102875. * @param rootUrl defines the root URL containing the effect layer information
  102876. * @returns a parsed effect Layer
  102877. */
  102878. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  102879. }
  102880. }
  102881. declare module BABYLON {
  102882. interface AbstractScene {
  102883. /**
  102884. * The list of effect layers (highlights/glow) added to the scene
  102885. * @see http://doc.babylonjs.com/how_to/highlight_layer
  102886. * @see http://doc.babylonjs.com/how_to/glow_layer
  102887. */
  102888. effectLayers: Array<EffectLayer>;
  102889. /**
  102890. * Removes the given effect layer from this scene.
  102891. * @param toRemove defines the effect layer to remove
  102892. * @returns the index of the removed effect layer
  102893. */
  102894. removeEffectLayer(toRemove: EffectLayer): number;
  102895. /**
  102896. * Adds the given effect layer to this scene
  102897. * @param newEffectLayer defines the effect layer to add
  102898. */
  102899. addEffectLayer(newEffectLayer: EffectLayer): void;
  102900. }
  102901. /**
  102902. * Defines the layer scene component responsible to manage any effect layers
  102903. * in a given scene.
  102904. */
  102905. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  102906. /**
  102907. * The component name helpfull to identify the component in the list of scene components.
  102908. */
  102909. readonly name: string;
  102910. /**
  102911. * The scene the component belongs to.
  102912. */
  102913. scene: Scene;
  102914. private _engine;
  102915. private _renderEffects;
  102916. private _needStencil;
  102917. private _previousStencilState;
  102918. /**
  102919. * Creates a new instance of the component for the given scene
  102920. * @param scene Defines the scene to register the component in
  102921. */
  102922. constructor(scene: Scene);
  102923. /**
  102924. * Registers the component in a given scene
  102925. */
  102926. register(): void;
  102927. /**
  102928. * Rebuilds the elements related to this component in case of
  102929. * context lost for instance.
  102930. */
  102931. rebuild(): void;
  102932. /**
  102933. * Serializes the component data to the specified json object
  102934. * @param serializationObject The object to serialize to
  102935. */
  102936. serialize(serializationObject: any): void;
  102937. /**
  102938. * Adds all the element from the container to the scene
  102939. * @param container the container holding the elements
  102940. */
  102941. addFromContainer(container: AbstractScene): void;
  102942. /**
  102943. * Removes all the elements in the container from the scene
  102944. * @param container contains the elements to remove
  102945. */
  102946. removeFromContainer(container: AbstractScene): void;
  102947. /**
  102948. * Disposes the component and the associated ressources.
  102949. */
  102950. dispose(): void;
  102951. private _isReadyForMesh;
  102952. private _renderMainTexture;
  102953. private _setStencil;
  102954. private _setStencilBack;
  102955. private _draw;
  102956. private _drawCamera;
  102957. private _drawRenderingGroup;
  102958. }
  102959. }
  102960. declare module BABYLON {
  102961. /** @hidden */
  102962. export var glowMapMergePixelShader: {
  102963. name: string;
  102964. shader: string;
  102965. };
  102966. }
  102967. declare module BABYLON {
  102968. /** @hidden */
  102969. export var glowMapMergeVertexShader: {
  102970. name: string;
  102971. shader: string;
  102972. };
  102973. }
  102974. declare module BABYLON {
  102975. interface AbstractScene {
  102976. /**
  102977. * Return a the first highlight layer of the scene with a given name.
  102978. * @param name The name of the highlight layer to look for.
  102979. * @return The highlight layer if found otherwise null.
  102980. */
  102981. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  102982. }
  102983. /**
  102984. * Glow layer options. This helps customizing the behaviour
  102985. * of the glow layer.
  102986. */
  102987. export interface IGlowLayerOptions {
  102988. /**
  102989. * Multiplication factor apply to the canvas size to compute the render target size
  102990. * used to generated the glowing objects (the smaller the faster).
  102991. */
  102992. mainTextureRatio: number;
  102993. /**
  102994. * Enforces a fixed size texture to ensure resize independant blur.
  102995. */
  102996. mainTextureFixedSize?: number;
  102997. /**
  102998. * How big is the kernel of the blur texture.
  102999. */
  103000. blurKernelSize: number;
  103001. /**
  103002. * The camera attached to the layer.
  103003. */
  103004. camera: Nullable<Camera>;
  103005. /**
  103006. * Enable MSAA by chosing the number of samples.
  103007. */
  103008. mainTextureSamples?: number;
  103009. /**
  103010. * The rendering group to draw the layer in.
  103011. */
  103012. renderingGroupId: number;
  103013. }
  103014. /**
  103015. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  103016. *
  103017. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103018. * glowy meshes to your scene.
  103019. *
  103020. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  103021. */
  103022. export class GlowLayer extends EffectLayer {
  103023. /**
  103024. * Effect Name of the layer.
  103025. */
  103026. static readonly EffectName: string;
  103027. /**
  103028. * The default blur kernel size used for the glow.
  103029. */
  103030. static DefaultBlurKernelSize: number;
  103031. /**
  103032. * The default texture size ratio used for the glow.
  103033. */
  103034. static DefaultTextureRatio: number;
  103035. /**
  103036. * Sets the kernel size of the blur.
  103037. */
  103038. /**
  103039. * Gets the kernel size of the blur.
  103040. */
  103041. blurKernelSize: number;
  103042. /**
  103043. * Sets the glow intensity.
  103044. */
  103045. /**
  103046. * Gets the glow intensity.
  103047. */
  103048. intensity: number;
  103049. private _options;
  103050. private _intensity;
  103051. private _horizontalBlurPostprocess1;
  103052. private _verticalBlurPostprocess1;
  103053. private _horizontalBlurPostprocess2;
  103054. private _verticalBlurPostprocess2;
  103055. private _blurTexture1;
  103056. private _blurTexture2;
  103057. private _postProcesses1;
  103058. private _postProcesses2;
  103059. private _includedOnlyMeshes;
  103060. private _excludedMeshes;
  103061. /**
  103062. * Callback used to let the user override the color selection on a per mesh basis
  103063. */
  103064. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  103065. /**
  103066. * Callback used to let the user override the texture selection on a per mesh basis
  103067. */
  103068. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  103069. /**
  103070. * Instantiates a new glow Layer and references it to the scene.
  103071. * @param name The name of the layer
  103072. * @param scene The scene to use the layer in
  103073. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  103074. */
  103075. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  103076. /**
  103077. * Get the effect name of the layer.
  103078. * @return The effect name
  103079. */
  103080. getEffectName(): string;
  103081. /**
  103082. * Create the merge effect. This is the shader use to blit the information back
  103083. * to the main canvas at the end of the scene rendering.
  103084. */
  103085. protected _createMergeEffect(): Effect;
  103086. /**
  103087. * Creates the render target textures and post processes used in the glow layer.
  103088. */
  103089. protected _createTextureAndPostProcesses(): void;
  103090. /**
  103091. * Checks for the readiness of the element composing the layer.
  103092. * @param subMesh the mesh to check for
  103093. * @param useInstances specify wether or not to use instances to render the mesh
  103094. * @param emissiveTexture the associated emissive texture used to generate the glow
  103095. * @return true if ready otherwise, false
  103096. */
  103097. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103098. /**
  103099. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103100. */
  103101. needStencil(): boolean;
  103102. /**
  103103. * Returns true if the mesh can be rendered, otherwise false.
  103104. * @param mesh The mesh to render
  103105. * @param material The material used on the mesh
  103106. * @returns true if it can be rendered otherwise false
  103107. */
  103108. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103109. /**
  103110. * Implementation specific of rendering the generating effect on the main canvas.
  103111. * @param effect The effect used to render through
  103112. */
  103113. protected _internalRender(effect: Effect): void;
  103114. /**
  103115. * Sets the required values for both the emissive texture and and the main color.
  103116. */
  103117. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103118. /**
  103119. * Returns true if the mesh should render, otherwise false.
  103120. * @param mesh The mesh to render
  103121. * @returns true if it should render otherwise false
  103122. */
  103123. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103124. /**
  103125. * Adds specific effects defines.
  103126. * @param defines The defines to add specifics to.
  103127. */
  103128. protected _addCustomEffectDefines(defines: string[]): void;
  103129. /**
  103130. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  103131. * @param mesh The mesh to exclude from the glow layer
  103132. */
  103133. addExcludedMesh(mesh: Mesh): void;
  103134. /**
  103135. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  103136. * @param mesh The mesh to remove
  103137. */
  103138. removeExcludedMesh(mesh: Mesh): void;
  103139. /**
  103140. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  103141. * @param mesh The mesh to include in the glow layer
  103142. */
  103143. addIncludedOnlyMesh(mesh: Mesh): void;
  103144. /**
  103145. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  103146. * @param mesh The mesh to remove
  103147. */
  103148. removeIncludedOnlyMesh(mesh: Mesh): void;
  103149. /**
  103150. * Determine if a given mesh will be used in the glow layer
  103151. * @param mesh The mesh to test
  103152. * @returns true if the mesh will be highlighted by the current glow layer
  103153. */
  103154. hasMesh(mesh: AbstractMesh): boolean;
  103155. /**
  103156. * Free any resources and references associated to a mesh.
  103157. * Internal use
  103158. * @param mesh The mesh to free.
  103159. * @hidden
  103160. */
  103161. _disposeMesh(mesh: Mesh): void;
  103162. /**
  103163. * Gets the class name of the effect layer
  103164. * @returns the string with the class name of the effect layer
  103165. */
  103166. getClassName(): string;
  103167. /**
  103168. * Serializes this glow layer
  103169. * @returns a serialized glow layer object
  103170. */
  103171. serialize(): any;
  103172. /**
  103173. * Creates a Glow Layer from parsed glow layer data
  103174. * @param parsedGlowLayer defines glow layer data
  103175. * @param scene defines the current scene
  103176. * @param rootUrl defines the root URL containing the glow layer information
  103177. * @returns a parsed Glow Layer
  103178. */
  103179. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  103180. }
  103181. }
  103182. declare module BABYLON {
  103183. /** @hidden */
  103184. export var glowBlurPostProcessPixelShader: {
  103185. name: string;
  103186. shader: string;
  103187. };
  103188. }
  103189. declare module BABYLON {
  103190. interface AbstractScene {
  103191. /**
  103192. * Return a the first highlight layer of the scene with a given name.
  103193. * @param name The name of the highlight layer to look for.
  103194. * @return The highlight layer if found otherwise null.
  103195. */
  103196. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  103197. }
  103198. /**
  103199. * Highlight layer options. This helps customizing the behaviour
  103200. * of the highlight layer.
  103201. */
  103202. export interface IHighlightLayerOptions {
  103203. /**
  103204. * Multiplication factor apply to the canvas size to compute the render target size
  103205. * used to generated the glowing objects (the smaller the faster).
  103206. */
  103207. mainTextureRatio: number;
  103208. /**
  103209. * Enforces a fixed size texture to ensure resize independant blur.
  103210. */
  103211. mainTextureFixedSize?: number;
  103212. /**
  103213. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  103214. * of the picture to blur (the smaller the faster).
  103215. */
  103216. blurTextureSizeRatio: number;
  103217. /**
  103218. * How big in texel of the blur texture is the vertical blur.
  103219. */
  103220. blurVerticalSize: number;
  103221. /**
  103222. * How big in texel of the blur texture is the horizontal blur.
  103223. */
  103224. blurHorizontalSize: number;
  103225. /**
  103226. * Alpha blending mode used to apply the blur. Default is combine.
  103227. */
  103228. alphaBlendingMode: number;
  103229. /**
  103230. * The camera attached to the layer.
  103231. */
  103232. camera: Nullable<Camera>;
  103233. /**
  103234. * Should we display highlight as a solid stroke?
  103235. */
  103236. isStroke?: boolean;
  103237. /**
  103238. * The rendering group to draw the layer in.
  103239. */
  103240. renderingGroupId: number;
  103241. }
  103242. /**
  103243. * The highlight layer Helps adding a glow effect around a mesh.
  103244. *
  103245. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103246. * glowy meshes to your scene.
  103247. *
  103248. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  103249. */
  103250. export class HighlightLayer extends EffectLayer {
  103251. name: string;
  103252. /**
  103253. * Effect Name of the highlight layer.
  103254. */
  103255. static readonly EffectName: string;
  103256. /**
  103257. * The neutral color used during the preparation of the glow effect.
  103258. * This is black by default as the blend operation is a blend operation.
  103259. */
  103260. static NeutralColor: Color4;
  103261. /**
  103262. * Stencil value used for glowing meshes.
  103263. */
  103264. static GlowingMeshStencilReference: number;
  103265. /**
  103266. * Stencil value used for the other meshes in the scene.
  103267. */
  103268. static NormalMeshStencilReference: number;
  103269. /**
  103270. * Specifies whether or not the inner glow is ACTIVE in the layer.
  103271. */
  103272. innerGlow: boolean;
  103273. /**
  103274. * Specifies whether or not the outer glow is ACTIVE in the layer.
  103275. */
  103276. outerGlow: boolean;
  103277. /**
  103278. * Specifies the horizontal size of the blur.
  103279. */
  103280. /**
  103281. * Gets the horizontal size of the blur.
  103282. */
  103283. blurHorizontalSize: number;
  103284. /**
  103285. * Specifies the vertical size of the blur.
  103286. */
  103287. /**
  103288. * Gets the vertical size of the blur.
  103289. */
  103290. blurVerticalSize: number;
  103291. /**
  103292. * An event triggered when the highlight layer is being blurred.
  103293. */
  103294. onBeforeBlurObservable: Observable<HighlightLayer>;
  103295. /**
  103296. * An event triggered when the highlight layer has been blurred.
  103297. */
  103298. onAfterBlurObservable: Observable<HighlightLayer>;
  103299. private _instanceGlowingMeshStencilReference;
  103300. private _options;
  103301. private _downSamplePostprocess;
  103302. private _horizontalBlurPostprocess;
  103303. private _verticalBlurPostprocess;
  103304. private _blurTexture;
  103305. private _meshes;
  103306. private _excludedMeshes;
  103307. /**
  103308. * Instantiates a new highlight Layer and references it to the scene..
  103309. * @param name The name of the layer
  103310. * @param scene The scene to use the layer in
  103311. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  103312. */
  103313. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  103314. /**
  103315. * Get the effect name of the layer.
  103316. * @return The effect name
  103317. */
  103318. getEffectName(): string;
  103319. /**
  103320. * Create the merge effect. This is the shader use to blit the information back
  103321. * to the main canvas at the end of the scene rendering.
  103322. */
  103323. protected _createMergeEffect(): Effect;
  103324. /**
  103325. * Creates the render target textures and post processes used in the highlight layer.
  103326. */
  103327. protected _createTextureAndPostProcesses(): void;
  103328. /**
  103329. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103330. */
  103331. needStencil(): boolean;
  103332. /**
  103333. * Checks for the readiness of the element composing the layer.
  103334. * @param subMesh the mesh to check for
  103335. * @param useInstances specify wether or not to use instances to render the mesh
  103336. * @param emissiveTexture the associated emissive texture used to generate the glow
  103337. * @return true if ready otherwise, false
  103338. */
  103339. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103340. /**
  103341. * Implementation specific of rendering the generating effect on the main canvas.
  103342. * @param effect The effect used to render through
  103343. */
  103344. protected _internalRender(effect: Effect): void;
  103345. /**
  103346. * Returns true if the layer contains information to display, otherwise false.
  103347. */
  103348. shouldRender(): boolean;
  103349. /**
  103350. * Returns true if the mesh should render, otherwise false.
  103351. * @param mesh The mesh to render
  103352. * @returns true if it should render otherwise false
  103353. */
  103354. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103355. /**
  103356. * Sets the required values for both the emissive texture and and the main color.
  103357. */
  103358. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103359. /**
  103360. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  103361. * @param mesh The mesh to exclude from the highlight layer
  103362. */
  103363. addExcludedMesh(mesh: Mesh): void;
  103364. /**
  103365. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  103366. * @param mesh The mesh to highlight
  103367. */
  103368. removeExcludedMesh(mesh: Mesh): void;
  103369. /**
  103370. * Determine if a given mesh will be highlighted by the current HighlightLayer
  103371. * @param mesh mesh to test
  103372. * @returns true if the mesh will be highlighted by the current HighlightLayer
  103373. */
  103374. hasMesh(mesh: AbstractMesh): boolean;
  103375. /**
  103376. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  103377. * @param mesh The mesh to highlight
  103378. * @param color The color of the highlight
  103379. * @param glowEmissiveOnly Extract the glow from the emissive texture
  103380. */
  103381. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  103382. /**
  103383. * Remove a mesh from the highlight layer in order to make it stop glowing.
  103384. * @param mesh The mesh to highlight
  103385. */
  103386. removeMesh(mesh: Mesh): void;
  103387. /**
  103388. * Force the stencil to the normal expected value for none glowing parts
  103389. */
  103390. private _defaultStencilReference;
  103391. /**
  103392. * Free any resources and references associated to a mesh.
  103393. * Internal use
  103394. * @param mesh The mesh to free.
  103395. * @hidden
  103396. */
  103397. _disposeMesh(mesh: Mesh): void;
  103398. /**
  103399. * Dispose the highlight layer and free resources.
  103400. */
  103401. dispose(): void;
  103402. /**
  103403. * Gets the class name of the effect layer
  103404. * @returns the string with the class name of the effect layer
  103405. */
  103406. getClassName(): string;
  103407. /**
  103408. * Serializes this Highlight layer
  103409. * @returns a serialized Highlight layer object
  103410. */
  103411. serialize(): any;
  103412. /**
  103413. * Creates a Highlight layer from parsed Highlight layer data
  103414. * @param parsedHightlightLayer defines the Highlight layer data
  103415. * @param scene defines the current scene
  103416. * @param rootUrl defines the root URL containing the Highlight layer information
  103417. * @returns a parsed Highlight layer
  103418. */
  103419. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  103420. }
  103421. }
  103422. declare module BABYLON {
  103423. /** @hidden */
  103424. export var lensFlarePixelShader: {
  103425. name: string;
  103426. shader: string;
  103427. };
  103428. }
  103429. declare module BABYLON {
  103430. /** @hidden */
  103431. export var lensFlareVertexShader: {
  103432. name: string;
  103433. shader: string;
  103434. };
  103435. }
  103436. declare module BABYLON {
  103437. /**
  103438. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103439. * It is usually composed of several `lensFlare`.
  103440. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103441. */
  103442. export class LensFlareSystem {
  103443. /**
  103444. * Define the name of the lens flare system
  103445. */
  103446. name: string;
  103447. /**
  103448. * List of lens flares used in this system.
  103449. */
  103450. lensFlares: LensFlare[];
  103451. /**
  103452. * Define a limit from the border the lens flare can be visible.
  103453. */
  103454. borderLimit: number;
  103455. /**
  103456. * Define a viewport border we do not want to see the lens flare in.
  103457. */
  103458. viewportBorder: number;
  103459. /**
  103460. * Define a predicate which could limit the list of meshes able to occlude the effect.
  103461. */
  103462. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103463. /**
  103464. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  103465. */
  103466. layerMask: number;
  103467. /**
  103468. * Define the id of the lens flare system in the scene.
  103469. * (equal to name by default)
  103470. */
  103471. id: string;
  103472. private _scene;
  103473. private _emitter;
  103474. private _vertexBuffers;
  103475. private _indexBuffer;
  103476. private _effect;
  103477. private _positionX;
  103478. private _positionY;
  103479. private _isEnabled;
  103480. /** @hidden */
  103481. static _SceneComponentInitialization: (scene: Scene) => void;
  103482. /**
  103483. * Instantiates a lens flare system.
  103484. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103485. * It is usually composed of several `lensFlare`.
  103486. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103487. * @param name Define the name of the lens flare system in the scene
  103488. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  103489. * @param scene Define the scene the lens flare system belongs to
  103490. */
  103491. constructor(
  103492. /**
  103493. * Define the name of the lens flare system
  103494. */
  103495. name: string, emitter: any, scene: Scene);
  103496. /**
  103497. * Define if the lens flare system is enabled.
  103498. */
  103499. isEnabled: boolean;
  103500. /**
  103501. * Get the scene the effects belongs to.
  103502. * @returns the scene holding the lens flare system
  103503. */
  103504. getScene(): Scene;
  103505. /**
  103506. * Get the emitter of the lens flare system.
  103507. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103508. * @returns the emitter of the lens flare system
  103509. */
  103510. getEmitter(): any;
  103511. /**
  103512. * Set the emitter of the lens flare system.
  103513. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103514. * @param newEmitter Define the new emitter of the system
  103515. */
  103516. setEmitter(newEmitter: any): void;
  103517. /**
  103518. * Get the lens flare system emitter position.
  103519. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  103520. * @returns the position
  103521. */
  103522. getEmitterPosition(): Vector3;
  103523. /**
  103524. * @hidden
  103525. */
  103526. computeEffectivePosition(globalViewport: Viewport): boolean;
  103527. /** @hidden */
  103528. _isVisible(): boolean;
  103529. /**
  103530. * @hidden
  103531. */
  103532. render(): boolean;
  103533. /**
  103534. * Dispose and release the lens flare with its associated resources.
  103535. */
  103536. dispose(): void;
  103537. /**
  103538. * Parse a lens flare system from a JSON repressentation
  103539. * @param parsedLensFlareSystem Define the JSON to parse
  103540. * @param scene Define the scene the parsed system should be instantiated in
  103541. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  103542. * @returns the parsed system
  103543. */
  103544. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  103545. /**
  103546. * Serialize the current Lens Flare System into a JSON representation.
  103547. * @returns the serialized JSON
  103548. */
  103549. serialize(): any;
  103550. }
  103551. }
  103552. declare module BABYLON {
  103553. /**
  103554. * This represents one of the lens effect in a `lensFlareSystem`.
  103555. * It controls one of the indiviual texture used in the effect.
  103556. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103557. */
  103558. export class LensFlare {
  103559. /**
  103560. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103561. */
  103562. size: number;
  103563. /**
  103564. * 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.
  103565. */
  103566. position: number;
  103567. /**
  103568. * Define the lens color.
  103569. */
  103570. color: Color3;
  103571. /**
  103572. * Define the lens texture.
  103573. */
  103574. texture: Nullable<Texture>;
  103575. /**
  103576. * Define the alpha mode to render this particular lens.
  103577. */
  103578. alphaMode: number;
  103579. private _system;
  103580. /**
  103581. * Creates a new Lens Flare.
  103582. * This represents one of the lens effect in a `lensFlareSystem`.
  103583. * It controls one of the indiviual texture used in the effect.
  103584. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103585. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  103586. * @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.
  103587. * @param color Define the lens color
  103588. * @param imgUrl Define the lens texture url
  103589. * @param system Define the `lensFlareSystem` this flare is part of
  103590. * @returns The newly created Lens Flare
  103591. */
  103592. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  103593. /**
  103594. * Instantiates a new Lens Flare.
  103595. * This represents one of the lens effect in a `lensFlareSystem`.
  103596. * It controls one of the indiviual texture used in the effect.
  103597. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103598. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  103599. * @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.
  103600. * @param color Define the lens color
  103601. * @param imgUrl Define the lens texture url
  103602. * @param system Define the `lensFlareSystem` this flare is part of
  103603. */
  103604. constructor(
  103605. /**
  103606. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103607. */
  103608. size: number,
  103609. /**
  103610. * 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.
  103611. */
  103612. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  103613. /**
  103614. * Dispose and release the lens flare with its associated resources.
  103615. */
  103616. dispose(): void;
  103617. }
  103618. }
  103619. declare module BABYLON {
  103620. interface AbstractScene {
  103621. /**
  103622. * The list of lens flare system added to the scene
  103623. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103624. */
  103625. lensFlareSystems: Array<LensFlareSystem>;
  103626. /**
  103627. * Removes the given lens flare system from this scene.
  103628. * @param toRemove The lens flare system to remove
  103629. * @returns The index of the removed lens flare system
  103630. */
  103631. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  103632. /**
  103633. * Adds the given lens flare system to this scene
  103634. * @param newLensFlareSystem The lens flare system to add
  103635. */
  103636. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  103637. /**
  103638. * Gets a lens flare system using its name
  103639. * @param name defines the name to look for
  103640. * @returns the lens flare system or null if not found
  103641. */
  103642. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  103643. /**
  103644. * Gets a lens flare system using its id
  103645. * @param id defines the id to look for
  103646. * @returns the lens flare system or null if not found
  103647. */
  103648. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  103649. }
  103650. /**
  103651. * Defines the lens flare scene component responsible to manage any lens flares
  103652. * in a given scene.
  103653. */
  103654. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  103655. /**
  103656. * The component name helpfull to identify the component in the list of scene components.
  103657. */
  103658. readonly name: string;
  103659. /**
  103660. * The scene the component belongs to.
  103661. */
  103662. scene: Scene;
  103663. /**
  103664. * Creates a new instance of the component for the given scene
  103665. * @param scene Defines the scene to register the component in
  103666. */
  103667. constructor(scene: Scene);
  103668. /**
  103669. * Registers the component in a given scene
  103670. */
  103671. register(): void;
  103672. /**
  103673. * Rebuilds the elements related to this component in case of
  103674. * context lost for instance.
  103675. */
  103676. rebuild(): void;
  103677. /**
  103678. * Adds all the element from the container to the scene
  103679. * @param container the container holding the elements
  103680. */
  103681. addFromContainer(container: AbstractScene): void;
  103682. /**
  103683. * Removes all the elements in the container from the scene
  103684. * @param container contains the elements to remove
  103685. */
  103686. removeFromContainer(container: AbstractScene): void;
  103687. /**
  103688. * Serializes the component data to the specified json object
  103689. * @param serializationObject The object to serialize to
  103690. */
  103691. serialize(serializationObject: any): void;
  103692. /**
  103693. * Disposes the component and the associated ressources.
  103694. */
  103695. dispose(): void;
  103696. private _draw;
  103697. }
  103698. }
  103699. declare module BABYLON {
  103700. /**
  103701. * Defines the shadow generator component responsible to manage any shadow generators
  103702. * in a given scene.
  103703. */
  103704. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  103705. /**
  103706. * The component name helpfull to identify the component in the list of scene components.
  103707. */
  103708. readonly name: string;
  103709. /**
  103710. * The scene the component belongs to.
  103711. */
  103712. scene: Scene;
  103713. /**
  103714. * Creates a new instance of the component for the given scene
  103715. * @param scene Defines the scene to register the component in
  103716. */
  103717. constructor(scene: Scene);
  103718. /**
  103719. * Registers the component in a given scene
  103720. */
  103721. register(): void;
  103722. /**
  103723. * Rebuilds the elements related to this component in case of
  103724. * context lost for instance.
  103725. */
  103726. rebuild(): void;
  103727. /**
  103728. * Serializes the component data to the specified json object
  103729. * @param serializationObject The object to serialize to
  103730. */
  103731. serialize(serializationObject: any): void;
  103732. /**
  103733. * Adds all the element from the container to the scene
  103734. * @param container the container holding the elements
  103735. */
  103736. addFromContainer(container: AbstractScene): void;
  103737. /**
  103738. * Removes all the elements in the container from the scene
  103739. * @param container contains the elements to remove
  103740. */
  103741. removeFromContainer(container: AbstractScene): void;
  103742. /**
  103743. * Rebuilds the elements related to this component in case of
  103744. * context lost for instance.
  103745. */
  103746. dispose(): void;
  103747. private _gatherRenderTargets;
  103748. }
  103749. }
  103750. declare module BABYLON {
  103751. /**
  103752. * A directional light is defined by a direction (what a surprise!).
  103753. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  103754. * 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.
  103755. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103756. */
  103757. export class DirectionalLight extends ShadowLight {
  103758. private _shadowFrustumSize;
  103759. /**
  103760. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  103761. */
  103762. /**
  103763. * Specifies a fix frustum size for the shadow generation.
  103764. */
  103765. shadowFrustumSize: number;
  103766. private _shadowOrthoScale;
  103767. /**
  103768. * Gets the shadow projection scale against the optimal computed one.
  103769. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103770. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103771. */
  103772. /**
  103773. * Sets the shadow projection scale against the optimal computed one.
  103774. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103775. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103776. */
  103777. shadowOrthoScale: number;
  103778. /**
  103779. * Automatically compute the projection matrix to best fit (including all the casters)
  103780. * on each frame.
  103781. */
  103782. autoUpdateExtends: boolean;
  103783. private _orthoLeft;
  103784. private _orthoRight;
  103785. private _orthoTop;
  103786. private _orthoBottom;
  103787. /**
  103788. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  103789. * The directional light is emitted from everywhere in the given direction.
  103790. * It can cast shadows.
  103791. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103792. * @param name The friendly name of the light
  103793. * @param direction The direction of the light
  103794. * @param scene The scene the light belongs to
  103795. */
  103796. constructor(name: string, direction: Vector3, scene: Scene);
  103797. /**
  103798. * Returns the string "DirectionalLight".
  103799. * @return The class name
  103800. */
  103801. getClassName(): string;
  103802. /**
  103803. * Returns the integer 1.
  103804. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103805. */
  103806. getTypeID(): number;
  103807. /**
  103808. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103812. /**
  103813. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  103814. * Returns the DirectionalLight Shadow projection matrix.
  103815. */
  103816. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  103817. /**
  103818. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  103819. * Returns the DirectionalLight Shadow projection matrix.
  103820. */
  103821. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103822. protected _buildUniformLayout(): void;
  103823. /**
  103824. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  103825. * @param effect The effect to update
  103826. * @param lightIndex The index of the light in the effect to update
  103827. * @returns The directional light
  103828. */
  103829. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  103830. /**
  103831. * Gets the minZ used for shadow according to both the scene and the light.
  103832. *
  103833. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103834. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103835. * @param activeCamera The camera we are returning the min for
  103836. * @returns the depth min z
  103837. */
  103838. getDepthMinZ(activeCamera: Camera): number;
  103839. /**
  103840. * Gets the maxZ used for shadow according to both the scene and the light.
  103841. *
  103842. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103843. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103844. * @param activeCamera The camera we are returning the max for
  103845. * @returns the depth max z
  103846. */
  103847. getDepthMaxZ(activeCamera: Camera): number;
  103848. /**
  103849. * Prepares the list of defines specific to the light type.
  103850. * @param defines the list of defines
  103851. * @param lightIndex defines the index of the light for the effect
  103852. */
  103853. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103854. }
  103855. }
  103856. declare module BABYLON {
  103857. /**
  103858. * A point light is a light defined by an unique point in world space.
  103859. * The light is emitted in every direction from this point.
  103860. * A good example of a point light is a standard light bulb.
  103861. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103862. */
  103863. export class PointLight extends ShadowLight {
  103864. private _shadowAngle;
  103865. /**
  103866. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103867. * This specifies what angle the shadow will use to be created.
  103868. *
  103869. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103870. */
  103871. /**
  103872. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103873. * This specifies what angle the shadow will use to be created.
  103874. *
  103875. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103876. */
  103877. shadowAngle: number;
  103878. /**
  103879. * Gets the direction if it has been set.
  103880. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103881. */
  103882. /**
  103883. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103884. */
  103885. direction: Vector3;
  103886. /**
  103887. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  103888. * A PointLight emits the light in every direction.
  103889. * It can cast shadows.
  103890. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  103891. * ```javascript
  103892. * var pointLight = new PointLight("pl", camera.position, scene);
  103893. * ```
  103894. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103895. * @param name The light friendly name
  103896. * @param position The position of the point light in the scene
  103897. * @param scene The scene the lights belongs to
  103898. */
  103899. constructor(name: string, position: Vector3, scene: Scene);
  103900. /**
  103901. * Returns the string "PointLight"
  103902. * @returns the class name
  103903. */
  103904. getClassName(): string;
  103905. /**
  103906. * Returns the integer 0.
  103907. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103908. */
  103909. getTypeID(): number;
  103910. /**
  103911. * Specifies wether or not the shadowmap should be a cube texture.
  103912. * @returns true if the shadowmap needs to be a cube texture.
  103913. */
  103914. needCube(): boolean;
  103915. /**
  103916. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  103917. * @param faceIndex The index of the face we are computed the direction to generate shadow
  103918. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  103919. */
  103920. getShadowDirection(faceIndex?: number): Vector3;
  103921. /**
  103922. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  103923. * - fov = PI / 2
  103924. * - aspect ratio : 1.0
  103925. * - z-near and far equal to the active camera minZ and maxZ.
  103926. * Returns the PointLight.
  103927. */
  103928. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103929. protected _buildUniformLayout(): void;
  103930. /**
  103931. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  103932. * @param effect The effect to update
  103933. * @param lightIndex The index of the light in the effect to update
  103934. * @returns The point light
  103935. */
  103936. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  103937. /**
  103938. * Prepares the list of defines specific to the light type.
  103939. * @param defines the list of defines
  103940. * @param lightIndex defines the index of the light for the effect
  103941. */
  103942. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103943. }
  103944. }
  103945. declare module BABYLON {
  103946. /**
  103947. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103948. * These values define a cone of light starting from the position, emitting toward the direction.
  103949. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103950. * and the exponent defines the speed of the decay of the light with distance (reach).
  103951. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103952. */
  103953. export class SpotLight extends ShadowLight {
  103954. private _angle;
  103955. private _innerAngle;
  103956. private _cosHalfAngle;
  103957. private _lightAngleScale;
  103958. private _lightAngleOffset;
  103959. /**
  103960. * Gets the cone angle of the spot light in Radians.
  103961. */
  103962. /**
  103963. * Sets the cone angle of the spot light in Radians.
  103964. */
  103965. angle: number;
  103966. /**
  103967. * Only used in gltf falloff mode, this defines the angle where
  103968. * the directional falloff will start before cutting at angle which could be seen
  103969. * as outer angle.
  103970. */
  103971. /**
  103972. * Only used in gltf falloff mode, this defines the angle where
  103973. * the directional falloff will start before cutting at angle which could be seen
  103974. * as outer angle.
  103975. */
  103976. innerAngle: number;
  103977. private _shadowAngleScale;
  103978. /**
  103979. * Allows scaling the angle of the light for shadow generation only.
  103980. */
  103981. /**
  103982. * Allows scaling the angle of the light for shadow generation only.
  103983. */
  103984. shadowAngleScale: number;
  103985. /**
  103986. * The light decay speed with the distance from the emission spot.
  103987. */
  103988. exponent: number;
  103989. private _projectionTextureMatrix;
  103990. /**
  103991. * Allows reading the projecton texture
  103992. */
  103993. readonly projectionTextureMatrix: Matrix;
  103994. protected _projectionTextureLightNear: number;
  103995. /**
  103996. * Gets the near clip of the Spotlight for texture projection.
  103997. */
  103998. /**
  103999. * Sets the near clip of the Spotlight for texture projection.
  104000. */
  104001. projectionTextureLightNear: number;
  104002. protected _projectionTextureLightFar: number;
  104003. /**
  104004. * Gets the far clip of the Spotlight for texture projection.
  104005. */
  104006. /**
  104007. * Sets the far clip of the Spotlight for texture projection.
  104008. */
  104009. projectionTextureLightFar: number;
  104010. protected _projectionTextureUpDirection: Vector3;
  104011. /**
  104012. * Gets the Up vector of the Spotlight for texture projection.
  104013. */
  104014. /**
  104015. * Sets the Up vector of the Spotlight for texture projection.
  104016. */
  104017. projectionTextureUpDirection: Vector3;
  104018. private _projectionTexture;
  104019. /**
  104020. * Gets the projection texture of the light.
  104021. */
  104022. /**
  104023. * Sets the projection texture of the light.
  104024. */
  104025. projectionTexture: Nullable<BaseTexture>;
  104026. private _projectionTextureViewLightDirty;
  104027. private _projectionTextureProjectionLightDirty;
  104028. private _projectionTextureDirty;
  104029. private _projectionTextureViewTargetVector;
  104030. private _projectionTextureViewLightMatrix;
  104031. private _projectionTextureProjectionLightMatrix;
  104032. private _projectionTextureScalingMatrix;
  104033. /**
  104034. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  104035. * It can cast shadows.
  104036. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104037. * @param name The light friendly name
  104038. * @param position The position of the spot light in the scene
  104039. * @param direction The direction of the light in the scene
  104040. * @param angle The cone angle of the light in Radians
  104041. * @param exponent The light decay speed with the distance from the emission spot
  104042. * @param scene The scene the lights belongs to
  104043. */
  104044. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  104045. /**
  104046. * Returns the string "SpotLight".
  104047. * @returns the class name
  104048. */
  104049. getClassName(): string;
  104050. /**
  104051. * Returns the integer 2.
  104052. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104053. */
  104054. getTypeID(): number;
  104055. /**
  104056. * Overrides the direction setter to recompute the projection texture view light Matrix.
  104057. */
  104058. protected _setDirection(value: Vector3): void;
  104059. /**
  104060. * Overrides the position setter to recompute the projection texture view light Matrix.
  104061. */
  104062. protected _setPosition(value: Vector3): void;
  104063. /**
  104064. * 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.
  104065. * Returns the SpotLight.
  104066. */
  104067. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104068. protected _computeProjectionTextureViewLightMatrix(): void;
  104069. protected _computeProjectionTextureProjectionLightMatrix(): void;
  104070. /**
  104071. * Main function for light texture projection matrix computing.
  104072. */
  104073. protected _computeProjectionTextureMatrix(): void;
  104074. protected _buildUniformLayout(): void;
  104075. private _computeAngleValues;
  104076. /**
  104077. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  104078. * @param effect The effect to update
  104079. * @param lightIndex The index of the light in the effect to update
  104080. * @returns The spot light
  104081. */
  104082. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  104083. /**
  104084. * Disposes the light and the associated resources.
  104085. */
  104086. dispose(): void;
  104087. /**
  104088. * Prepares the list of defines specific to the light type.
  104089. * @param defines the list of defines
  104090. * @param lightIndex defines the index of the light for the effect
  104091. */
  104092. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104093. }
  104094. }
  104095. declare module BABYLON {
  104096. /**
  104097. * Header information of HDR texture files.
  104098. */
  104099. export interface HDRInfo {
  104100. /**
  104101. * The height of the texture in pixels.
  104102. */
  104103. height: number;
  104104. /**
  104105. * The width of the texture in pixels.
  104106. */
  104107. width: number;
  104108. /**
  104109. * The index of the beginning of the data in the binary file.
  104110. */
  104111. dataPosition: number;
  104112. }
  104113. /**
  104114. * This groups tools to convert HDR texture to native colors array.
  104115. */
  104116. export class HDRTools {
  104117. private static Ldexp;
  104118. private static Rgbe2float;
  104119. private static readStringLine;
  104120. /**
  104121. * Reads header information from an RGBE texture stored in a native array.
  104122. * More information on this format are available here:
  104123. * https://en.wikipedia.org/wiki/RGBE_image_format
  104124. *
  104125. * @param uint8array The binary file stored in native array.
  104126. * @return The header information.
  104127. */
  104128. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  104129. /**
  104130. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  104131. * This RGBE texture needs to store the information as a panorama.
  104132. *
  104133. * More information on this format are available here:
  104134. * https://en.wikipedia.org/wiki/RGBE_image_format
  104135. *
  104136. * @param buffer The binary file stored in an array buffer.
  104137. * @param size The expected size of the extracted cubemap.
  104138. * @return The Cube Map information.
  104139. */
  104140. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  104141. /**
  104142. * Returns the pixels data extracted from an RGBE texture.
  104143. * This pixels will be stored left to right up to down in the R G B order in one array.
  104144. *
  104145. * More information on this format are available here:
  104146. * https://en.wikipedia.org/wiki/RGBE_image_format
  104147. *
  104148. * @param uint8array The binary file stored in an array buffer.
  104149. * @param hdrInfo The header information of the file.
  104150. * @return The pixels data in RGB right to left up to down order.
  104151. */
  104152. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  104153. private static RGBE_ReadPixels_RLE;
  104154. }
  104155. }
  104156. declare module BABYLON {
  104157. /**
  104158. * This represents a texture coming from an HDR input.
  104159. *
  104160. * The only supported format is currently panorama picture stored in RGBE format.
  104161. * Example of such files can be found on HDRLib: http://hdrlib.com/
  104162. */
  104163. export class HDRCubeTexture extends BaseTexture {
  104164. private static _facesMapping;
  104165. private _generateHarmonics;
  104166. private _noMipmap;
  104167. private _textureMatrix;
  104168. private _size;
  104169. private _onLoad;
  104170. private _onError;
  104171. /**
  104172. * The texture URL.
  104173. */
  104174. url: string;
  104175. /**
  104176. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  104177. */
  104178. coordinatesMode: number;
  104179. protected _isBlocking: boolean;
  104180. /**
  104181. * Sets wether or not the texture is blocking during loading.
  104182. */
  104183. /**
  104184. * Gets wether or not the texture is blocking during loading.
  104185. */
  104186. isBlocking: boolean;
  104187. protected _rotationY: number;
  104188. /**
  104189. * Sets texture matrix rotation angle around Y axis in radians.
  104190. */
  104191. /**
  104192. * Gets texture matrix rotation angle around Y axis radians.
  104193. */
  104194. rotationY: number;
  104195. /**
  104196. * Gets or sets the center of the bounding box associated with the cube texture
  104197. * It must define where the camera used to render the texture was set
  104198. */
  104199. boundingBoxPosition: Vector3;
  104200. private _boundingBoxSize;
  104201. /**
  104202. * Gets or sets the size of the bounding box associated with the cube texture
  104203. * When defined, the cubemap will switch to local mode
  104204. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104205. * @example https://www.babylonjs-playground.com/#RNASML
  104206. */
  104207. boundingBoxSize: Vector3;
  104208. /**
  104209. * Instantiates an HDRTexture from the following parameters.
  104210. *
  104211. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  104212. * @param scene The scene the texture will be used in
  104213. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  104214. * @param noMipmap Forces to not generate the mipmap if true
  104215. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  104216. * @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)
  104217. * @param reserved Reserved flag for internal use.
  104218. */
  104219. 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>);
  104220. /**
  104221. * Get the current class name of the texture useful for serialization or dynamic coding.
  104222. * @returns "HDRCubeTexture"
  104223. */
  104224. getClassName(): string;
  104225. /**
  104226. * Occurs when the file is raw .hdr file.
  104227. */
  104228. private loadTexture;
  104229. clone(): HDRCubeTexture;
  104230. delayLoad(): void;
  104231. /**
  104232. * Get the texture reflection matrix used to rotate/transform the reflection.
  104233. * @returns the reflection matrix
  104234. */
  104235. getReflectionTextureMatrix(): Matrix;
  104236. /**
  104237. * Set the texture reflection matrix used to rotate/transform the reflection.
  104238. * @param value Define the reflection matrix to set
  104239. */
  104240. setReflectionTextureMatrix(value: Matrix): void;
  104241. /**
  104242. * Parses a JSON representation of an HDR Texture in order to create the texture
  104243. * @param parsedTexture Define the JSON representation
  104244. * @param scene Define the scene the texture should be created in
  104245. * @param rootUrl Define the root url in case we need to load relative dependencies
  104246. * @returns the newly created texture after parsing
  104247. */
  104248. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  104249. serialize(): any;
  104250. }
  104251. }
  104252. declare module BABYLON {
  104253. /**
  104254. * Class used to control physics engine
  104255. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104256. */
  104257. export class PhysicsEngine implements IPhysicsEngine {
  104258. private _physicsPlugin;
  104259. /**
  104260. * Global value used to control the smallest number supported by the simulation
  104261. */
  104262. static Epsilon: number;
  104263. private _impostors;
  104264. private _joints;
  104265. /**
  104266. * Gets the gravity vector used by the simulation
  104267. */
  104268. gravity: Vector3;
  104269. /**
  104270. * Factory used to create the default physics plugin.
  104271. * @returns The default physics plugin
  104272. */
  104273. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  104274. /**
  104275. * Creates a new Physics Engine
  104276. * @param gravity defines the gravity vector used by the simulation
  104277. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  104278. */
  104279. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  104280. /**
  104281. * Sets the gravity vector used by the simulation
  104282. * @param gravity defines the gravity vector to use
  104283. */
  104284. setGravity(gravity: Vector3): void;
  104285. /**
  104286. * Set the time step of the physics engine.
  104287. * Default is 1/60.
  104288. * To slow it down, enter 1/600 for example.
  104289. * To speed it up, 1/30
  104290. * @param newTimeStep defines the new timestep to apply to this world.
  104291. */
  104292. setTimeStep(newTimeStep?: number): void;
  104293. /**
  104294. * Get the time step of the physics engine.
  104295. * @returns the current time step
  104296. */
  104297. getTimeStep(): number;
  104298. /**
  104299. * Release all resources
  104300. */
  104301. dispose(): void;
  104302. /**
  104303. * Gets the name of the current physics plugin
  104304. * @returns the name of the plugin
  104305. */
  104306. getPhysicsPluginName(): string;
  104307. /**
  104308. * Adding a new impostor for the impostor tracking.
  104309. * This will be done by the impostor itself.
  104310. * @param impostor the impostor to add
  104311. */
  104312. addImpostor(impostor: PhysicsImpostor): void;
  104313. /**
  104314. * Remove an impostor from the engine.
  104315. * This impostor and its mesh will not longer be updated by the physics engine.
  104316. * @param impostor the impostor to remove
  104317. */
  104318. removeImpostor(impostor: PhysicsImpostor): void;
  104319. /**
  104320. * Add a joint to the physics engine
  104321. * @param mainImpostor defines the main impostor to which the joint is added.
  104322. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104323. * @param joint defines the joint that will connect both impostors.
  104324. */
  104325. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104326. /**
  104327. * Removes a joint from the simulation
  104328. * @param mainImpostor defines the impostor used with the joint
  104329. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104330. * @param joint defines the joint to remove
  104331. */
  104332. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104333. /**
  104334. * Called by the scene. No need to call it.
  104335. * @param delta defines the timespam between frames
  104336. */
  104337. _step(delta: number): void;
  104338. /**
  104339. * Gets the current plugin used to run the simulation
  104340. * @returns current plugin
  104341. */
  104342. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104343. /**
  104344. * Gets the list of physic impostors
  104345. * @returns an array of PhysicsImpostor
  104346. */
  104347. getImpostors(): Array<PhysicsImpostor>;
  104348. /**
  104349. * Gets the impostor for a physics enabled object
  104350. * @param object defines the object impersonated by the impostor
  104351. * @returns the PhysicsImpostor or null if not found
  104352. */
  104353. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104354. /**
  104355. * Gets the impostor for a physics body object
  104356. * @param body defines physics body used by the impostor
  104357. * @returns the PhysicsImpostor or null if not found
  104358. */
  104359. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104360. }
  104361. }
  104362. declare module BABYLON {
  104363. /** @hidden */
  104364. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  104365. private _useDeltaForWorldStep;
  104366. world: any;
  104367. name: string;
  104368. private _physicsMaterials;
  104369. private _fixedTimeStep;
  104370. BJSCANNON: any;
  104371. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  104372. setGravity(gravity: Vector3): void;
  104373. setTimeStep(timeStep: number): void;
  104374. getTimeStep(): number;
  104375. executeStep(delta: number): void;
  104376. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104377. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104378. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104379. private _processChildMeshes;
  104380. removePhysicsBody(impostor: PhysicsImpostor): void;
  104381. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104382. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104383. private _addMaterial;
  104384. private _checkWithEpsilon;
  104385. private _createShape;
  104386. private _createHeightmap;
  104387. private _minus90X;
  104388. private _plus90X;
  104389. private _tmpPosition;
  104390. private _tmpDeltaPosition;
  104391. private _tmpUnityRotation;
  104392. private _updatePhysicsBodyTransformation;
  104393. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104394. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104395. isSupported(): boolean;
  104396. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104397. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104398. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104399. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104400. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104401. getBodyMass(impostor: PhysicsImpostor): number;
  104402. getBodyFriction(impostor: PhysicsImpostor): number;
  104403. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104404. getBodyRestitution(impostor: PhysicsImpostor): number;
  104405. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104406. sleepBody(impostor: PhysicsImpostor): void;
  104407. wakeUpBody(impostor: PhysicsImpostor): void;
  104408. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  104409. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  104410. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104411. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104412. getRadius(impostor: PhysicsImpostor): number;
  104413. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104414. dispose(): void;
  104415. private _extendNamespace;
  104416. }
  104417. }
  104418. declare module BABYLON {
  104419. /** @hidden */
  104420. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  104421. world: any;
  104422. name: string;
  104423. BJSOIMO: any;
  104424. constructor(iterations?: number, oimoInjection?: any);
  104425. setGravity(gravity: Vector3): void;
  104426. setTimeStep(timeStep: number): void;
  104427. getTimeStep(): number;
  104428. private _tmpImpostorsArray;
  104429. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104430. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104431. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104432. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104433. private _tmpPositionVector;
  104434. removePhysicsBody(impostor: PhysicsImpostor): void;
  104435. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104436. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104437. isSupported(): boolean;
  104438. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104439. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104440. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104441. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104442. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104443. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104444. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104445. getBodyMass(impostor: PhysicsImpostor): number;
  104446. getBodyFriction(impostor: PhysicsImpostor): number;
  104447. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104448. getBodyRestitution(impostor: PhysicsImpostor): number;
  104449. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104450. sleepBody(impostor: PhysicsImpostor): void;
  104451. wakeUpBody(impostor: PhysicsImpostor): void;
  104452. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104453. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  104454. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104455. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104456. getRadius(impostor: PhysicsImpostor): number;
  104457. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104458. dispose(): void;
  104459. }
  104460. }
  104461. declare module BABYLON {
  104462. interface AbstractScene {
  104463. /**
  104464. * The list of reflection probes added to the scene
  104465. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104466. */
  104467. reflectionProbes: Array<ReflectionProbe>;
  104468. /**
  104469. * Removes the given reflection probe from this scene.
  104470. * @param toRemove The reflection probe to remove
  104471. * @returns The index of the removed reflection probe
  104472. */
  104473. removeReflectionProbe(toRemove: ReflectionProbe): number;
  104474. /**
  104475. * Adds the given reflection probe to this scene.
  104476. * @param newReflectionProbe The reflection probe to add
  104477. */
  104478. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  104479. }
  104480. /**
  104481. * Class used to generate realtime reflection / refraction cube textures
  104482. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104483. */
  104484. export class ReflectionProbe {
  104485. /** defines the name of the probe */
  104486. name: string;
  104487. private _scene;
  104488. private _renderTargetTexture;
  104489. private _projectionMatrix;
  104490. private _viewMatrix;
  104491. private _target;
  104492. private _add;
  104493. private _attachedMesh;
  104494. private _invertYAxis;
  104495. /** Gets or sets probe position (center of the cube map) */
  104496. position: Vector3;
  104497. /**
  104498. * Creates a new reflection probe
  104499. * @param name defines the name of the probe
  104500. * @param size defines the texture resolution (for each face)
  104501. * @param scene defines the hosting scene
  104502. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  104503. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  104504. */
  104505. constructor(
  104506. /** defines the name of the probe */
  104507. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  104508. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  104509. samples: number;
  104510. /** Gets or sets the refresh rate to use (on every frame by default) */
  104511. refreshRate: number;
  104512. /**
  104513. * Gets the hosting scene
  104514. * @returns a Scene
  104515. */
  104516. getScene(): Scene;
  104517. /** Gets the internal CubeTexture used to render to */
  104518. readonly cubeTexture: RenderTargetTexture;
  104519. /** Gets the list of meshes to render */
  104520. readonly renderList: Nullable<AbstractMesh[]>;
  104521. /**
  104522. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  104523. * @param mesh defines the mesh to attach to
  104524. */
  104525. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104526. /**
  104527. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  104528. * @param renderingGroupId The rendering group id corresponding to its index
  104529. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104530. */
  104531. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104532. /**
  104533. * Clean all associated resources
  104534. */
  104535. dispose(): void;
  104536. /**
  104537. * Converts the reflection probe information to a readable string for debug purpose.
  104538. * @param fullDetails Supports for multiple levels of logging within scene loading
  104539. * @returns the human readable reflection probe info
  104540. */
  104541. toString(fullDetails?: boolean): string;
  104542. /**
  104543. * Get the class name of the relfection probe.
  104544. * @returns "ReflectionProbe"
  104545. */
  104546. getClassName(): string;
  104547. /**
  104548. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  104549. * @returns The JSON representation of the texture
  104550. */
  104551. serialize(): any;
  104552. /**
  104553. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  104554. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  104555. * @param scene Define the scene the parsed reflection probe should be instantiated in
  104556. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104557. * @returns The parsed reflection probe if successful
  104558. */
  104559. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  104560. }
  104561. }
  104562. declare module BABYLON {
  104563. /** @hidden */
  104564. export var _BabylonLoaderRegistered: boolean;
  104565. }
  104566. declare module BABYLON {
  104567. /**
  104568. * The Physically based simple base material of BJS.
  104569. *
  104570. * This enables better naming and convention enforcements on top of the pbrMaterial.
  104571. * It is used as the base class for both the specGloss and metalRough conventions.
  104572. */
  104573. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  104574. /**
  104575. * Number of Simultaneous lights allowed on the material.
  104576. */
  104577. maxSimultaneousLights: number;
  104578. /**
  104579. * If sets to true, disables all the lights affecting the material.
  104580. */
  104581. disableLighting: boolean;
  104582. /**
  104583. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  104584. */
  104585. environmentTexture: BaseTexture;
  104586. /**
  104587. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104588. */
  104589. invertNormalMapX: boolean;
  104590. /**
  104591. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104592. */
  104593. invertNormalMapY: boolean;
  104594. /**
  104595. * Normal map used in the model.
  104596. */
  104597. normalTexture: BaseTexture;
  104598. /**
  104599. * Emissivie color used to self-illuminate the model.
  104600. */
  104601. emissiveColor: Color3;
  104602. /**
  104603. * Emissivie texture used to self-illuminate the model.
  104604. */
  104605. emissiveTexture: BaseTexture;
  104606. /**
  104607. * Occlusion Channel Strenght.
  104608. */
  104609. occlusionStrength: number;
  104610. /**
  104611. * Occlusion Texture of the material (adding extra occlusion effects).
  104612. */
  104613. occlusionTexture: BaseTexture;
  104614. /**
  104615. * Defines the alpha limits in alpha test mode.
  104616. */
  104617. alphaCutOff: number;
  104618. /**
  104619. * Gets the current double sided mode.
  104620. */
  104621. /**
  104622. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104623. */
  104624. doubleSided: boolean;
  104625. /**
  104626. * Stores the pre-calculated light information of a mesh in a texture.
  104627. */
  104628. lightmapTexture: BaseTexture;
  104629. /**
  104630. * If true, the light map contains occlusion information instead of lighting info.
  104631. */
  104632. useLightmapAsShadowmap: boolean;
  104633. /**
  104634. * Instantiates a new PBRMaterial instance.
  104635. *
  104636. * @param name The material name
  104637. * @param scene The scene the material will be use in.
  104638. */
  104639. constructor(name: string, scene: Scene);
  104640. getClassName(): string;
  104641. }
  104642. }
  104643. declare module BABYLON {
  104644. /**
  104645. * The PBR material of BJS following the metal roughness convention.
  104646. *
  104647. * This fits to the PBR convention in the GLTF definition:
  104648. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  104649. */
  104650. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  104651. /**
  104652. * The base color has two different interpretations depending on the value of metalness.
  104653. * When the material is a metal, the base color is the specific measured reflectance value
  104654. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  104655. * of the material.
  104656. */
  104657. baseColor: Color3;
  104658. /**
  104659. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  104660. * well as opacity information in the alpha channel.
  104661. */
  104662. baseTexture: BaseTexture;
  104663. /**
  104664. * Specifies the metallic scalar value of the material.
  104665. * Can also be used to scale the metalness values of the metallic texture.
  104666. */
  104667. metallic: number;
  104668. /**
  104669. * Specifies the roughness scalar value of the material.
  104670. * Can also be used to scale the roughness values of the metallic texture.
  104671. */
  104672. roughness: number;
  104673. /**
  104674. * Texture containing both the metallic value in the B channel and the
  104675. * roughness value in the G channel to keep better precision.
  104676. */
  104677. metallicRoughnessTexture: BaseTexture;
  104678. /**
  104679. * Instantiates a new PBRMetalRoughnessMaterial instance.
  104680. *
  104681. * @param name The material name
  104682. * @param scene The scene the material will be use in.
  104683. */
  104684. constructor(name: string, scene: Scene);
  104685. /**
  104686. * Return the currrent class name of the material.
  104687. */
  104688. getClassName(): string;
  104689. /**
  104690. * Makes a duplicate of the current material.
  104691. * @param name - name to use for the new material.
  104692. */
  104693. clone(name: string): PBRMetallicRoughnessMaterial;
  104694. /**
  104695. * Serialize the material to a parsable JSON object.
  104696. */
  104697. serialize(): any;
  104698. /**
  104699. * Parses a JSON object correponding to the serialize function.
  104700. */
  104701. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  104702. }
  104703. }
  104704. declare module BABYLON {
  104705. /**
  104706. * The PBR material of BJS following the specular glossiness convention.
  104707. *
  104708. * This fits to the PBR convention in the GLTF definition:
  104709. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  104710. */
  104711. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  104712. /**
  104713. * Specifies the diffuse color of the material.
  104714. */
  104715. diffuseColor: Color3;
  104716. /**
  104717. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  104718. * channel.
  104719. */
  104720. diffuseTexture: BaseTexture;
  104721. /**
  104722. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  104723. */
  104724. specularColor: Color3;
  104725. /**
  104726. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  104727. */
  104728. glossiness: number;
  104729. /**
  104730. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  104731. */
  104732. specularGlossinessTexture: BaseTexture;
  104733. /**
  104734. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  104735. *
  104736. * @param name The material name
  104737. * @param scene The scene the material will be use in.
  104738. */
  104739. constructor(name: string, scene: Scene);
  104740. /**
  104741. * Return the currrent class name of the material.
  104742. */
  104743. getClassName(): string;
  104744. /**
  104745. * Makes a duplicate of the current material.
  104746. * @param name - name to use for the new material.
  104747. */
  104748. clone(name: string): PBRSpecularGlossinessMaterial;
  104749. /**
  104750. * Serialize the material to a parsable JSON object.
  104751. */
  104752. serialize(): any;
  104753. /**
  104754. * Parses a JSON object correponding to the serialize function.
  104755. */
  104756. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  104757. }
  104758. }
  104759. declare module BABYLON {
  104760. /**
  104761. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  104762. * It can help converting any input color in a desired output one. This can then be used to create effects
  104763. * from sepia, black and white to sixties or futuristic rendering...
  104764. *
  104765. * The only supported format is currently 3dl.
  104766. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  104767. */
  104768. export class ColorGradingTexture extends BaseTexture {
  104769. /**
  104770. * The current texture matrix. (will always be identity in color grading texture)
  104771. */
  104772. private _textureMatrix;
  104773. /**
  104774. * The texture URL.
  104775. */
  104776. url: string;
  104777. /**
  104778. * Empty line regex stored for GC.
  104779. */
  104780. private static _noneEmptyLineRegex;
  104781. private _engine;
  104782. /**
  104783. * Instantiates a ColorGradingTexture from the following parameters.
  104784. *
  104785. * @param url The location of the color gradind data (currently only supporting 3dl)
  104786. * @param scene The scene the texture will be used in
  104787. */
  104788. constructor(url: string, scene: Scene);
  104789. /**
  104790. * Returns the texture matrix used in most of the material.
  104791. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  104792. */
  104793. getTextureMatrix(): Matrix;
  104794. /**
  104795. * Occurs when the file being loaded is a .3dl LUT file.
  104796. */
  104797. private load3dlTexture;
  104798. /**
  104799. * Starts the loading process of the texture.
  104800. */
  104801. private loadTexture;
  104802. /**
  104803. * Clones the color gradind texture.
  104804. */
  104805. clone(): ColorGradingTexture;
  104806. /**
  104807. * Called during delayed load for textures.
  104808. */
  104809. delayLoad(): void;
  104810. /**
  104811. * Parses a color grading texture serialized by Babylon.
  104812. * @param parsedTexture The texture information being parsedTexture
  104813. * @param scene The scene to load the texture in
  104814. * @param rootUrl The root url of the data assets to load
  104815. * @return A color gradind texture
  104816. */
  104817. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  104818. /**
  104819. * Serializes the LUT texture to json format.
  104820. */
  104821. serialize(): any;
  104822. }
  104823. }
  104824. declare module BABYLON {
  104825. /**
  104826. * Based on jsTGALoader - Javascript loader for TGA file
  104827. * By Vincent Thibault
  104828. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104829. */
  104830. export class TGATools {
  104831. private static _TYPE_INDEXED;
  104832. private static _TYPE_RGB;
  104833. private static _TYPE_GREY;
  104834. private static _TYPE_RLE_INDEXED;
  104835. private static _TYPE_RLE_RGB;
  104836. private static _TYPE_RLE_GREY;
  104837. private static _ORIGIN_MASK;
  104838. private static _ORIGIN_SHIFT;
  104839. private static _ORIGIN_BL;
  104840. private static _ORIGIN_BR;
  104841. private static _ORIGIN_UL;
  104842. private static _ORIGIN_UR;
  104843. /**
  104844. * Gets the header of a TGA file
  104845. * @param data defines the TGA data
  104846. * @returns the header
  104847. */
  104848. static GetTGAHeader(data: Uint8Array): any;
  104849. /**
  104850. * Uploads TGA content to a Babylon Texture
  104851. * @hidden
  104852. */
  104853. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104854. /** @hidden */
  104855. 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;
  104856. /** @hidden */
  104857. 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;
  104858. /** @hidden */
  104859. 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;
  104860. /** @hidden */
  104861. 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;
  104862. /** @hidden */
  104863. 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;
  104864. /** @hidden */
  104865. 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;
  104866. }
  104867. }
  104868. declare module BABYLON {
  104869. /**
  104870. * Implementation of the TGA Texture Loader.
  104871. * @hidden
  104872. */
  104873. export class _TGATextureLoader implements IInternalTextureLoader {
  104874. /**
  104875. * Defines wether the loader supports cascade loading the different faces.
  104876. */
  104877. readonly supportCascades: boolean;
  104878. /**
  104879. * This returns if the loader support the current file information.
  104880. * @param extension defines the file extension of the file being loaded
  104881. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104882. * @param fallback defines the fallback internal texture if any
  104883. * @param isBase64 defines whether the texture is encoded as a base64
  104884. * @param isBuffer defines whether the texture data are stored as a buffer
  104885. * @returns true if the loader can load the specified file
  104886. */
  104887. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104888. /**
  104889. * Transform the url before loading if required.
  104890. * @param rootUrl the url of the texture
  104891. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104892. * @returns the transformed texture
  104893. */
  104894. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104895. /**
  104896. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104897. * @param rootUrl the url of the texture
  104898. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104899. * @returns the fallback texture
  104900. */
  104901. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104902. /**
  104903. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104904. * @param data contains the texture data
  104905. * @param texture defines the BabylonJS internal texture
  104906. * @param createPolynomials will be true if polynomials have been requested
  104907. * @param onLoad defines the callback to trigger once the texture is ready
  104908. * @param onError defines the callback to trigger in case of error
  104909. */
  104910. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104911. /**
  104912. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104913. * @param data contains the texture data
  104914. * @param texture defines the BabylonJS internal texture
  104915. * @param callback defines the method to call once ready to upload
  104916. */
  104917. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104918. }
  104919. }
  104920. declare module BABYLON {
  104921. /**
  104922. * 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.
  104923. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104924. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104925. */
  104926. export class CustomProceduralTexture extends ProceduralTexture {
  104927. private _animate;
  104928. private _time;
  104929. private _config;
  104930. private _texturePath;
  104931. /**
  104932. * Instantiates a new Custom Procedural Texture.
  104933. * 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.
  104934. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104935. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104936. * @param name Define the name of the texture
  104937. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104938. * @param size Define the size of the texture to create
  104939. * @param scene Define the scene the texture belongs to
  104940. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104941. * @param generateMipMaps Define if the texture should creates mip maps or not
  104942. */
  104943. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104944. private _loadJson;
  104945. /**
  104946. * Is the texture ready to be used ? (rendered at least once)
  104947. * @returns true if ready, otherwise, false.
  104948. */
  104949. isReady(): boolean;
  104950. /**
  104951. * Render the texture to its associated render target.
  104952. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  104953. */
  104954. render(useCameraPostProcess?: boolean): void;
  104955. /**
  104956. * Update the list of dependant textures samplers in the shader.
  104957. */
  104958. updateTextures(): void;
  104959. /**
  104960. * Update the uniform values of the procedural texture in the shader.
  104961. */
  104962. updateShaderUniforms(): void;
  104963. /**
  104964. * Define if the texture animates or not.
  104965. */
  104966. animate: boolean;
  104967. }
  104968. }
  104969. declare module BABYLON {
  104970. /** @hidden */
  104971. export var noisePixelShader: {
  104972. name: string;
  104973. shader: string;
  104974. };
  104975. }
  104976. declare module BABYLON {
  104977. /**
  104978. * Class used to generate noise procedural textures
  104979. */
  104980. export class NoiseProceduralTexture extends ProceduralTexture {
  104981. private _time;
  104982. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  104983. brightness: number;
  104984. /** Defines the number of octaves to process */
  104985. octaves: number;
  104986. /** Defines the level of persistence (0.8 by default) */
  104987. persistence: number;
  104988. /** Gets or sets animation speed factor (default is 1) */
  104989. animationSpeedFactor: number;
  104990. /**
  104991. * Creates a new NoiseProceduralTexture
  104992. * @param name defines the name fo the texture
  104993. * @param size defines the size of the texture (default is 256)
  104994. * @param scene defines the hosting scene
  104995. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  104996. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  104997. */
  104998. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104999. private _updateShaderUniforms;
  105000. protected _getDefines(): string;
  105001. /** Generate the current state of the procedural texture */
  105002. render(useCameraPostProcess?: boolean): void;
  105003. /**
  105004. * Serializes this noise procedural texture
  105005. * @returns a serialized noise procedural texture object
  105006. */
  105007. serialize(): any;
  105008. /**
  105009. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  105010. * @param parsedTexture defines parsed texture data
  105011. * @param scene defines the current scene
  105012. * @param rootUrl defines the root URL containing noise procedural texture information
  105013. * @returns a parsed NoiseProceduralTexture
  105014. */
  105015. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  105016. }
  105017. }
  105018. declare module BABYLON {
  105019. /**
  105020. * Raw cube texture where the raw buffers are passed in
  105021. */
  105022. export class RawCubeTexture extends CubeTexture {
  105023. /**
  105024. * Creates a cube texture where the raw buffers are passed in.
  105025. * @param scene defines the scene the texture is attached to
  105026. * @param data defines the array of data to use to create each face
  105027. * @param size defines the size of the textures
  105028. * @param format defines the format of the data
  105029. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105030. * @param generateMipMaps defines if the engine should generate the mip levels
  105031. * @param invertY defines if data must be stored with Y axis inverted
  105032. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105033. * @param compression defines the compression used (null by default)
  105034. */
  105035. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  105036. /**
  105037. * Updates the raw cube texture.
  105038. * @param data defines the data to store
  105039. * @param format defines the data format
  105040. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105041. * @param invertY defines if data must be stored with Y axis inverted
  105042. * @param compression defines the compression used (null by default)
  105043. * @param level defines which level of the texture to update
  105044. */
  105045. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  105046. /**
  105047. * Updates a raw cube texture with RGBD encoded data.
  105048. * @param data defines the array of data [mipmap][face] to use to create each face
  105049. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  105050. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  105051. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  105052. * @returns a promsie that resolves when the operation is complete
  105053. */
  105054. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  105055. /**
  105056. * Clones the raw cube texture.
  105057. * @return a new cube texture
  105058. */
  105059. clone(): CubeTexture;
  105060. /** @hidden */
  105061. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105062. }
  105063. }
  105064. declare module BABYLON {
  105065. /**
  105066. * Class used to store 3D textures containing user data
  105067. */
  105068. export class RawTexture3D extends Texture {
  105069. /** Gets or sets the texture format to use */
  105070. format: number;
  105071. private _engine;
  105072. /**
  105073. * Create a new RawTexture3D
  105074. * @param data defines the data of the texture
  105075. * @param width defines the width of the texture
  105076. * @param height defines the height of the texture
  105077. * @param depth defines the depth of the texture
  105078. * @param format defines the texture format to use
  105079. * @param scene defines the hosting scene
  105080. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  105081. * @param invertY defines if texture must be stored with Y axis inverted
  105082. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  105083. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  105084. */
  105085. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  105086. /** Gets or sets the texture format to use */
  105087. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  105088. /**
  105089. * Update the texture with new data
  105090. * @param data defines the data to store in the texture
  105091. */
  105092. update(data: ArrayBufferView): void;
  105093. }
  105094. }
  105095. declare module BABYLON {
  105096. /**
  105097. * Creates a refraction texture used by refraction channel of the standard material.
  105098. * It is like a mirror but to see through a material.
  105099. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105100. */
  105101. export class RefractionTexture extends RenderTargetTexture {
  105102. /**
  105103. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  105104. * 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.
  105105. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105106. */
  105107. refractionPlane: Plane;
  105108. /**
  105109. * Define how deep under the surface we should see.
  105110. */
  105111. depth: number;
  105112. /**
  105113. * Creates a refraction texture used by refraction channel of the standard material.
  105114. * It is like a mirror but to see through a material.
  105115. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105116. * @param name Define the texture name
  105117. * @param size Define the size of the underlying texture
  105118. * @param scene Define the scene the refraction belongs to
  105119. * @param generateMipMaps Define if we need to generate mips level for the refraction
  105120. */
  105121. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  105122. /**
  105123. * Clone the refraction texture.
  105124. * @returns the cloned texture
  105125. */
  105126. clone(): RefractionTexture;
  105127. /**
  105128. * Serialize the texture to a JSON representation you could use in Parse later on
  105129. * @returns the serialized JSON representation
  105130. */
  105131. serialize(): any;
  105132. }
  105133. }
  105134. declare module BABYLON {
  105135. /**
  105136. * Configuration for Draco compression
  105137. */
  105138. export interface IDracoCompressionConfiguration {
  105139. /**
  105140. * Configuration for the decoder.
  105141. */
  105142. decoder?: {
  105143. /**
  105144. * The url to the WebAssembly module.
  105145. */
  105146. wasmUrl?: string;
  105147. /**
  105148. * The url to the WebAssembly binary.
  105149. */
  105150. wasmBinaryUrl?: string;
  105151. /**
  105152. * The url to the fallback JavaScript module.
  105153. */
  105154. fallbackUrl?: string;
  105155. };
  105156. }
  105157. /**
  105158. * Draco compression (https://google.github.io/draco/)
  105159. *
  105160. * This class wraps the Draco module.
  105161. *
  105162. * **Encoder**
  105163. *
  105164. * The encoder is not currently implemented.
  105165. *
  105166. * **Decoder**
  105167. *
  105168. * 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.
  105169. *
  105170. * To update the configuration, use the following code:
  105171. * ```javascript
  105172. * DracoCompression.Configuration = {
  105173. * decoder: {
  105174. * wasmUrl: "<url to the WebAssembly library>",
  105175. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  105176. * fallbackUrl: "<url to the fallback JavaScript library>",
  105177. * }
  105178. * };
  105179. * ```
  105180. *
  105181. * 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.
  105182. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  105183. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  105184. *
  105185. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  105186. * ```javascript
  105187. * var dracoCompression = new DracoCompression();
  105188. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  105189. * [VertexBuffer.PositionKind]: 0
  105190. * });
  105191. * ```
  105192. *
  105193. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  105194. */
  105195. export class DracoCompression implements IDisposable {
  105196. private static _DecoderModulePromise;
  105197. /**
  105198. * The configuration. Defaults to the following urls:
  105199. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  105200. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  105201. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  105202. */
  105203. static Configuration: IDracoCompressionConfiguration;
  105204. /**
  105205. * Returns true if the decoder is available.
  105206. */
  105207. static readonly DecoderAvailable: boolean;
  105208. /**
  105209. * Constructor
  105210. */
  105211. constructor();
  105212. /**
  105213. * Stop all async operations and release resources.
  105214. */
  105215. dispose(): void;
  105216. /**
  105217. * Decode Draco compressed mesh data to vertex data.
  105218. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  105219. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  105220. * @returns A promise that resolves with the decoded vertex data
  105221. */
  105222. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  105223. [kind: string]: number;
  105224. }): Promise<VertexData>;
  105225. private static _GetDecoderModule;
  105226. private static _LoadScriptAsync;
  105227. private static _LoadFileAsync;
  105228. }
  105229. }
  105230. declare module BABYLON {
  105231. /**
  105232. * Class for building Constructive Solid Geometry
  105233. */
  105234. export class CSG {
  105235. private polygons;
  105236. /**
  105237. * The world matrix
  105238. */
  105239. matrix: Matrix;
  105240. /**
  105241. * Stores the position
  105242. */
  105243. position: Vector3;
  105244. /**
  105245. * Stores the rotation
  105246. */
  105247. rotation: Vector3;
  105248. /**
  105249. * Stores the rotation quaternion
  105250. */
  105251. rotationQuaternion: Nullable<Quaternion>;
  105252. /**
  105253. * Stores the scaling vector
  105254. */
  105255. scaling: Vector3;
  105256. /**
  105257. * Convert the Mesh to CSG
  105258. * @param mesh The Mesh to convert to CSG
  105259. * @returns A new CSG from the Mesh
  105260. */
  105261. static FromMesh(mesh: Mesh): CSG;
  105262. /**
  105263. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  105264. * @param polygons Polygons used to construct a CSG solid
  105265. */
  105266. private static FromPolygons;
  105267. /**
  105268. * Clones, or makes a deep copy, of the CSG
  105269. * @returns A new CSG
  105270. */
  105271. clone(): CSG;
  105272. /**
  105273. * Unions this CSG with another CSG
  105274. * @param csg The CSG to union against this CSG
  105275. * @returns The unioned CSG
  105276. */
  105277. union(csg: CSG): CSG;
  105278. /**
  105279. * Unions this CSG with another CSG in place
  105280. * @param csg The CSG to union against this CSG
  105281. */
  105282. unionInPlace(csg: CSG): void;
  105283. /**
  105284. * Subtracts this CSG with another CSG
  105285. * @param csg The CSG to subtract against this CSG
  105286. * @returns A new CSG
  105287. */
  105288. subtract(csg: CSG): CSG;
  105289. /**
  105290. * Subtracts this CSG with another CSG in place
  105291. * @param csg The CSG to subtact against this CSG
  105292. */
  105293. subtractInPlace(csg: CSG): void;
  105294. /**
  105295. * Intersect this CSG with another CSG
  105296. * @param csg The CSG to intersect against this CSG
  105297. * @returns A new CSG
  105298. */
  105299. intersect(csg: CSG): CSG;
  105300. /**
  105301. * Intersects this CSG with another CSG in place
  105302. * @param csg The CSG to intersect against this CSG
  105303. */
  105304. intersectInPlace(csg: CSG): void;
  105305. /**
  105306. * Return a new CSG solid with solid and empty space switched. This solid is
  105307. * not modified.
  105308. * @returns A new CSG solid with solid and empty space switched
  105309. */
  105310. inverse(): CSG;
  105311. /**
  105312. * Inverses the CSG in place
  105313. */
  105314. inverseInPlace(): void;
  105315. /**
  105316. * This is used to keep meshes transformations so they can be restored
  105317. * when we build back a Babylon Mesh
  105318. * NB : All CSG operations are performed in world coordinates
  105319. * @param csg The CSG to copy the transform attributes from
  105320. * @returns This CSG
  105321. */
  105322. copyTransformAttributes(csg: CSG): CSG;
  105323. /**
  105324. * Build Raw mesh from CSG
  105325. * Coordinates here are in world space
  105326. * @param name The name of the mesh geometry
  105327. * @param scene The Scene
  105328. * @param keepSubMeshes Specifies if the submeshes should be kept
  105329. * @returns A new Mesh
  105330. */
  105331. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  105332. /**
  105333. * Build Mesh from CSG taking material and transforms into account
  105334. * @param name The name of the Mesh
  105335. * @param material The material of the Mesh
  105336. * @param scene The Scene
  105337. * @param keepSubMeshes Specifies if submeshes should be kept
  105338. * @returns The new Mesh
  105339. */
  105340. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  105341. }
  105342. }
  105343. declare module BABYLON {
  105344. /**
  105345. * Class used to create a trail following a mesh
  105346. */
  105347. export class TrailMesh extends Mesh {
  105348. private _generator;
  105349. private _autoStart;
  105350. private _running;
  105351. private _diameter;
  105352. private _length;
  105353. private _sectionPolygonPointsCount;
  105354. private _sectionVectors;
  105355. private _sectionNormalVectors;
  105356. private _beforeRenderObserver;
  105357. /**
  105358. * @constructor
  105359. * @param name The value used by scene.getMeshByName() to do a lookup.
  105360. * @param generator The mesh to generate a trail.
  105361. * @param scene The scene to add this mesh to.
  105362. * @param diameter Diameter of trailing mesh. Default is 1.
  105363. * @param length Length of trailing mesh. Default is 60.
  105364. * @param autoStart Automatically start trailing mesh. Default true.
  105365. */
  105366. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  105367. /**
  105368. * "TrailMesh"
  105369. * @returns "TrailMesh"
  105370. */
  105371. getClassName(): string;
  105372. private _createMesh;
  105373. /**
  105374. * Start trailing mesh.
  105375. */
  105376. start(): void;
  105377. /**
  105378. * Stop trailing mesh.
  105379. */
  105380. stop(): void;
  105381. /**
  105382. * Update trailing mesh geometry.
  105383. */
  105384. update(): void;
  105385. /**
  105386. * Returns a new TrailMesh object.
  105387. * @param name is a string, the name given to the new mesh
  105388. * @param newGenerator use new generator object for cloned trail mesh
  105389. * @returns a new mesh
  105390. */
  105391. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  105392. /**
  105393. * Serializes this trail mesh
  105394. * @param serializationObject object to write serialization to
  105395. */
  105396. serialize(serializationObject: any): void;
  105397. /**
  105398. * Parses a serialized trail mesh
  105399. * @param parsedMesh the serialized mesh
  105400. * @param scene the scene to create the trail mesh in
  105401. * @returns the created trail mesh
  105402. */
  105403. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  105404. }
  105405. }
  105406. declare module BABYLON {
  105407. /**
  105408. * Class containing static functions to help procedurally build meshes
  105409. */
  105410. export class RibbonBuilder {
  105411. /**
  105412. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105413. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105414. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105415. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105416. * * 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
  105417. * * 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
  105418. * * 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
  105419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105422. * * 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
  105423. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105424. * * 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
  105425. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105427. * @param name defines the name of the mesh
  105428. * @param options defines the options used to create the mesh
  105429. * @param scene defines the hosting scene
  105430. * @returns the ribbon mesh
  105431. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105432. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105433. */
  105434. static CreateRibbon(name: string, options: {
  105435. pathArray: Vector3[][];
  105436. closeArray?: boolean;
  105437. closePath?: boolean;
  105438. offset?: number;
  105439. updatable?: boolean;
  105440. sideOrientation?: number;
  105441. frontUVs?: Vector4;
  105442. backUVs?: Vector4;
  105443. instance?: Mesh;
  105444. invertUV?: boolean;
  105445. uvs?: Vector2[];
  105446. colors?: Color4[];
  105447. }, scene?: Nullable<Scene>): Mesh;
  105448. }
  105449. }
  105450. declare module BABYLON {
  105451. /**
  105452. * Class containing static functions to help procedurally build meshes
  105453. */
  105454. export class TorusKnotBuilder {
  105455. /**
  105456. * Creates a torus knot mesh
  105457. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105458. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105459. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105460. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105464. * @param name defines the name of the mesh
  105465. * @param options defines the options used to create the mesh
  105466. * @param scene defines the hosting scene
  105467. * @returns the torus knot mesh
  105468. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105469. */
  105470. static CreateTorusKnot(name: string, options: {
  105471. radius?: number;
  105472. tube?: number;
  105473. radialSegments?: number;
  105474. tubularSegments?: number;
  105475. p?: number;
  105476. q?: number;
  105477. updatable?: boolean;
  105478. sideOrientation?: number;
  105479. frontUVs?: Vector4;
  105480. backUVs?: Vector4;
  105481. }, scene: any): Mesh;
  105482. }
  105483. }
  105484. declare module BABYLON {
  105485. /**
  105486. * Polygon
  105487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105488. */
  105489. export class Polygon {
  105490. /**
  105491. * Creates a rectangle
  105492. * @param xmin bottom X coord
  105493. * @param ymin bottom Y coord
  105494. * @param xmax top X coord
  105495. * @param ymax top Y coord
  105496. * @returns points that make the resulting rectation
  105497. */
  105498. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105499. /**
  105500. * Creates a circle
  105501. * @param radius radius of circle
  105502. * @param cx scale in x
  105503. * @param cy scale in y
  105504. * @param numberOfSides number of sides that make up the circle
  105505. * @returns points that make the resulting circle
  105506. */
  105507. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105508. /**
  105509. * Creates a polygon from input string
  105510. * @param input Input polygon data
  105511. * @returns the parsed points
  105512. */
  105513. static Parse(input: string): Vector2[];
  105514. /**
  105515. * Starts building a polygon from x and y coordinates
  105516. * @param x x coordinate
  105517. * @param y y coordinate
  105518. * @returns the started path2
  105519. */
  105520. static StartingAt(x: number, y: number): Path2;
  105521. }
  105522. /**
  105523. * Builds a polygon
  105524. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105525. */
  105526. export class PolygonMeshBuilder {
  105527. private _points;
  105528. private _outlinepoints;
  105529. private _holes;
  105530. private _name;
  105531. private _scene;
  105532. private _epoints;
  105533. private _eholes;
  105534. private _addToepoint;
  105535. /**
  105536. * Babylon reference to the earcut plugin.
  105537. */
  105538. bjsEarcut: any;
  105539. /**
  105540. * Creates a PolygonMeshBuilder
  105541. * @param name name of the builder
  105542. * @param contours Path of the polygon
  105543. * @param scene scene to add to
  105544. * @param earcutInjection can be used to inject your own earcut reference
  105545. */
  105546. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105547. /**
  105548. * Adds a whole within the polygon
  105549. * @param hole Array of points defining the hole
  105550. * @returns this
  105551. */
  105552. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105553. /**
  105554. * Creates the polygon
  105555. * @param updatable If the mesh should be updatable
  105556. * @param depth The depth of the mesh created
  105557. * @returns the created mesh
  105558. */
  105559. build(updatable?: boolean, depth?: number): Mesh;
  105560. /**
  105561. * Adds a side to the polygon
  105562. * @param positions points that make the polygon
  105563. * @param normals normals of the polygon
  105564. * @param uvs uvs of the polygon
  105565. * @param indices indices of the polygon
  105566. * @param bounds bounds of the polygon
  105567. * @param points points of the polygon
  105568. * @param depth depth of the polygon
  105569. * @param flip flip of the polygon
  105570. */
  105571. private addSide;
  105572. }
  105573. }
  105574. declare module BABYLON {
  105575. /**
  105576. * Class containing static functions to help procedurally build meshes
  105577. */
  105578. export class PolygonBuilder {
  105579. /**
  105580. * Creates a polygon mesh
  105581. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105582. * * 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
  105583. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105586. * * Remember you can only change the shape positions, not their number when updating a polygon
  105587. * @param name defines the name of the mesh
  105588. * @param options defines the options used to create the mesh
  105589. * @param scene defines the hosting scene
  105590. * @param earcutInjection can be used to inject your own earcut reference
  105591. * @returns the polygon mesh
  105592. */
  105593. static CreatePolygon(name: string, options: {
  105594. shape: Vector3[];
  105595. holes?: Vector3[][];
  105596. depth?: number;
  105597. faceUV?: Vector4[];
  105598. faceColors?: Color4[];
  105599. updatable?: boolean;
  105600. sideOrientation?: number;
  105601. frontUVs?: Vector4;
  105602. backUVs?: Vector4;
  105603. }, scene: Scene, earcutInjection?: any): Mesh;
  105604. /**
  105605. * Creates an extruded polygon mesh, with depth in the Y direction.
  105606. * * 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)
  105607. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105608. * @param name defines the name of the mesh
  105609. * @param options defines the options used to create the mesh
  105610. * @param scene defines the hosting scene
  105611. * @param earcutInjection can be used to inject your own earcut reference
  105612. * @returns the polygon mesh
  105613. */
  105614. static ExtrudePolygon(name: string, options: {
  105615. shape: Vector3[];
  105616. holes?: Vector3[][];
  105617. depth?: number;
  105618. faceUV?: Vector4[];
  105619. faceColors?: Color4[];
  105620. updatable?: boolean;
  105621. sideOrientation?: number;
  105622. frontUVs?: Vector4;
  105623. backUVs?: Vector4;
  105624. }, scene: Scene, earcutInjection?: any): Mesh;
  105625. }
  105626. }
  105627. declare module BABYLON {
  105628. /**
  105629. * Class containing static functions to help procedurally build meshes
  105630. */
  105631. export class ShapeBuilder {
  105632. /**
  105633. * 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.
  105634. * * 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.
  105635. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105636. * * 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.
  105637. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105638. * * 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
  105639. * * 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
  105640. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105643. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105645. * @param name defines the name of the mesh
  105646. * @param options defines the options used to create the mesh
  105647. * @param scene defines the hosting scene
  105648. * @returns the extruded shape mesh
  105649. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105650. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105651. */
  105652. static ExtrudeShape(name: string, options: {
  105653. shape: Vector3[];
  105654. path: Vector3[];
  105655. scale?: number;
  105656. rotation?: number;
  105657. cap?: number;
  105658. updatable?: boolean;
  105659. sideOrientation?: number;
  105660. frontUVs?: Vector4;
  105661. backUVs?: Vector4;
  105662. instance?: Mesh;
  105663. invertUV?: boolean;
  105664. }, scene?: Nullable<Scene>): Mesh;
  105665. /**
  105666. * Creates an custom extruded shape mesh.
  105667. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105668. * * 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.
  105669. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105670. * * 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
  105671. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105672. * * 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
  105673. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105674. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105675. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105676. * * 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
  105677. * * 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
  105678. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105681. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105683. * @param name defines the name of the mesh
  105684. * @param options defines the options used to create the mesh
  105685. * @param scene defines the hosting scene
  105686. * @returns the custom extruded shape mesh
  105687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105688. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105690. */
  105691. static ExtrudeShapeCustom(name: string, options: {
  105692. shape: Vector3[];
  105693. path: Vector3[];
  105694. scaleFunction?: any;
  105695. rotationFunction?: any;
  105696. ribbonCloseArray?: boolean;
  105697. ribbonClosePath?: boolean;
  105698. cap?: number;
  105699. updatable?: boolean;
  105700. sideOrientation?: number;
  105701. frontUVs?: Vector4;
  105702. backUVs?: Vector4;
  105703. instance?: Mesh;
  105704. invertUV?: boolean;
  105705. }, scene: Scene): Mesh;
  105706. private static _ExtrudeShapeGeneric;
  105707. }
  105708. }
  105709. declare module BABYLON {
  105710. /**
  105711. * Class containing static functions to help procedurally build meshes
  105712. */
  105713. export class LatheBuilder {
  105714. /**
  105715. * Creates lathe mesh.
  105716. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105717. * * 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
  105718. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105719. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105720. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105721. * * 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
  105722. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105723. * * 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
  105724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105728. * @param name defines the name of the mesh
  105729. * @param options defines the options used to create the mesh
  105730. * @param scene defines the hosting scene
  105731. * @returns the lathe mesh
  105732. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105733. */
  105734. static CreateLathe(name: string, options: {
  105735. shape: Vector3[];
  105736. radius?: number;
  105737. tessellation?: number;
  105738. clip?: number;
  105739. arc?: number;
  105740. closed?: boolean;
  105741. updatable?: boolean;
  105742. sideOrientation?: number;
  105743. frontUVs?: Vector4;
  105744. backUVs?: Vector4;
  105745. cap?: number;
  105746. invertUV?: boolean;
  105747. }, scene: Scene): Mesh;
  105748. }
  105749. }
  105750. declare module BABYLON {
  105751. /**
  105752. * Class containing static functions to help procedurally build meshes
  105753. */
  105754. export class TubeBuilder {
  105755. /**
  105756. * Creates a tube mesh.
  105757. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105758. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105759. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105760. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105761. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105762. * * 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)
  105763. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105764. * * 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
  105765. * * 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
  105766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105768. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105770. * @param name defines the name of the mesh
  105771. * @param options defines the options used to create the mesh
  105772. * @param scene defines the hosting scene
  105773. * @returns the tube mesh
  105774. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105775. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105776. */
  105777. static CreateTube(name: string, options: {
  105778. path: Vector3[];
  105779. radius?: number;
  105780. tessellation?: number;
  105781. radiusFunction?: {
  105782. (i: number, distance: number): number;
  105783. };
  105784. cap?: number;
  105785. arc?: number;
  105786. updatable?: boolean;
  105787. sideOrientation?: number;
  105788. frontUVs?: Vector4;
  105789. backUVs?: Vector4;
  105790. instance?: Mesh;
  105791. invertUV?: boolean;
  105792. }, scene: Scene): Mesh;
  105793. }
  105794. }
  105795. declare module BABYLON {
  105796. /**
  105797. * Class containing static functions to help procedurally build meshes
  105798. */
  105799. export class IcoSphereBuilder {
  105800. /**
  105801. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105802. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105803. * * 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`)
  105804. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105805. * * 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
  105806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105809. * @param name defines the name of the mesh
  105810. * @param options defines the options used to create the mesh
  105811. * @param scene defines the hosting scene
  105812. * @returns the icosahedron mesh
  105813. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105814. */
  105815. static CreateIcoSphere(name: string, options: {
  105816. radius?: number;
  105817. radiusX?: number;
  105818. radiusY?: number;
  105819. radiusZ?: number;
  105820. flat?: boolean;
  105821. subdivisions?: number;
  105822. sideOrientation?: number;
  105823. frontUVs?: Vector4;
  105824. backUVs?: Vector4;
  105825. updatable?: boolean;
  105826. }, scene: Scene): Mesh;
  105827. }
  105828. }
  105829. declare module BABYLON {
  105830. /**
  105831. * Class containing static functions to help procedurally build meshes
  105832. */
  105833. export class DecalBuilder {
  105834. /**
  105835. * Creates a decal mesh.
  105836. * 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
  105837. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105838. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105839. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105840. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105841. * @param name defines the name of the mesh
  105842. * @param sourceMesh defines the mesh where the decal must be applied
  105843. * @param options defines the options used to create the mesh
  105844. * @param scene defines the hosting scene
  105845. * @returns the decal mesh
  105846. * @see https://doc.babylonjs.com/how_to/decals
  105847. */
  105848. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105849. position?: Vector3;
  105850. normal?: Vector3;
  105851. size?: Vector3;
  105852. angle?: number;
  105853. }): Mesh;
  105854. }
  105855. }
  105856. declare module BABYLON {
  105857. /**
  105858. * Class containing static functions to help procedurally build meshes
  105859. */
  105860. export class MeshBuilder {
  105861. /**
  105862. * Creates a box mesh
  105863. * * The parameter `size` sets the size (float) of each box side (default 1)
  105864. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105865. * * 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)
  105866. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105870. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105871. * @param name defines the name of the mesh
  105872. * @param options defines the options used to create the mesh
  105873. * @param scene defines the hosting scene
  105874. * @returns the box mesh
  105875. */
  105876. static CreateBox(name: string, options: {
  105877. size?: number;
  105878. width?: number;
  105879. height?: number;
  105880. depth?: number;
  105881. faceUV?: Vector4[];
  105882. faceColors?: Color4[];
  105883. sideOrientation?: number;
  105884. frontUVs?: Vector4;
  105885. backUVs?: Vector4;
  105886. updatable?: boolean;
  105887. }, scene?: Nullable<Scene>): Mesh;
  105888. /**
  105889. * Creates a sphere mesh
  105890. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105891. * * 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`)
  105892. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105893. * * 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
  105894. * * 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)
  105895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105898. * @param name defines the name of the mesh
  105899. * @param options defines the options used to create the mesh
  105900. * @param scene defines the hosting scene
  105901. * @returns the sphere mesh
  105902. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105903. */
  105904. static CreateSphere(name: string, options: {
  105905. segments?: number;
  105906. diameter?: number;
  105907. diameterX?: number;
  105908. diameterY?: number;
  105909. diameterZ?: number;
  105910. arc?: number;
  105911. slice?: number;
  105912. sideOrientation?: number;
  105913. frontUVs?: Vector4;
  105914. backUVs?: Vector4;
  105915. updatable?: boolean;
  105916. }, scene: any): Mesh;
  105917. /**
  105918. * Creates a plane polygonal mesh. By default, this is a disc
  105919. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105920. * * 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
  105921. * * 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
  105922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105925. * @param name defines the name of the mesh
  105926. * @param options defines the options used to create the mesh
  105927. * @param scene defines the hosting scene
  105928. * @returns the plane polygonal mesh
  105929. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105930. */
  105931. static CreateDisc(name: string, options: {
  105932. radius?: number;
  105933. tessellation?: number;
  105934. arc?: number;
  105935. updatable?: boolean;
  105936. sideOrientation?: number;
  105937. frontUVs?: Vector4;
  105938. backUVs?: Vector4;
  105939. }, scene?: Nullable<Scene>): Mesh;
  105940. /**
  105941. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105942. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105943. * * 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`)
  105944. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105945. * * 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
  105946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105949. * @param name defines the name of the mesh
  105950. * @param options defines the options used to create the mesh
  105951. * @param scene defines the hosting scene
  105952. * @returns the icosahedron mesh
  105953. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105954. */
  105955. static CreateIcoSphere(name: string, options: {
  105956. radius?: number;
  105957. radiusX?: number;
  105958. radiusY?: number;
  105959. radiusZ?: number;
  105960. flat?: boolean;
  105961. subdivisions?: number;
  105962. sideOrientation?: number;
  105963. frontUVs?: Vector4;
  105964. backUVs?: Vector4;
  105965. updatable?: boolean;
  105966. }, scene: Scene): Mesh;
  105967. /**
  105968. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105969. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105970. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105971. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105972. * * 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
  105973. * * 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
  105974. * * 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
  105975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105977. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105978. * * 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
  105979. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105980. * * 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
  105981. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105983. * @param name defines the name of the mesh
  105984. * @param options defines the options used to create the mesh
  105985. * @param scene defines the hosting scene
  105986. * @returns the ribbon mesh
  105987. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105988. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105989. */
  105990. static CreateRibbon(name: string, options: {
  105991. pathArray: Vector3[][];
  105992. closeArray?: boolean;
  105993. closePath?: boolean;
  105994. offset?: number;
  105995. updatable?: boolean;
  105996. sideOrientation?: number;
  105997. frontUVs?: Vector4;
  105998. backUVs?: Vector4;
  105999. instance?: Mesh;
  106000. invertUV?: boolean;
  106001. uvs?: Vector2[];
  106002. colors?: Color4[];
  106003. }, scene?: Nullable<Scene>): Mesh;
  106004. /**
  106005. * Creates a cylinder or a cone mesh
  106006. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106007. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106008. * * 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.
  106009. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106010. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106011. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106012. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106013. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106014. * * 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).
  106015. * * 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
  106016. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106017. * * 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
  106018. * * 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.
  106019. * * If `enclose` is false, a ring surface is one element.
  106020. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106021. * * 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
  106022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106023. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106025. * @param name defines the name of the mesh
  106026. * @param options defines the options used to create the mesh
  106027. * @param scene defines the hosting scene
  106028. * @returns the cylinder mesh
  106029. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106030. */
  106031. static CreateCylinder(name: string, options: {
  106032. height?: number;
  106033. diameterTop?: number;
  106034. diameterBottom?: number;
  106035. diameter?: number;
  106036. tessellation?: number;
  106037. subdivisions?: number;
  106038. arc?: number;
  106039. faceColors?: Color4[];
  106040. faceUV?: Vector4[];
  106041. updatable?: boolean;
  106042. hasRings?: boolean;
  106043. enclose?: boolean;
  106044. sideOrientation?: number;
  106045. frontUVs?: Vector4;
  106046. backUVs?: Vector4;
  106047. }, scene: any): Mesh;
  106048. /**
  106049. * Creates a torus mesh
  106050. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106051. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106052. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106056. * @param name defines the name of the mesh
  106057. * @param options defines the options used to create the mesh
  106058. * @param scene defines the hosting scene
  106059. * @returns the torus mesh
  106060. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106061. */
  106062. static CreateTorus(name: string, options: {
  106063. diameter?: number;
  106064. thickness?: number;
  106065. tessellation?: number;
  106066. updatable?: boolean;
  106067. sideOrientation?: number;
  106068. frontUVs?: Vector4;
  106069. backUVs?: Vector4;
  106070. }, scene: any): Mesh;
  106071. /**
  106072. * Creates a torus knot mesh
  106073. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106074. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106075. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106076. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106080. * @param name defines the name of the mesh
  106081. * @param options defines the options used to create the mesh
  106082. * @param scene defines the hosting scene
  106083. * @returns the torus knot mesh
  106084. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106085. */
  106086. static CreateTorusKnot(name: string, options: {
  106087. radius?: number;
  106088. tube?: number;
  106089. radialSegments?: number;
  106090. tubularSegments?: number;
  106091. p?: number;
  106092. q?: number;
  106093. updatable?: boolean;
  106094. sideOrientation?: number;
  106095. frontUVs?: Vector4;
  106096. backUVs?: Vector4;
  106097. }, scene: any): Mesh;
  106098. /**
  106099. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106100. * * 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
  106101. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106102. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106103. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106104. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106105. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106106. * * 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
  106107. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106109. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106110. * @param name defines the name of the new line system
  106111. * @param options defines the options used to create the line system
  106112. * @param scene defines the hosting scene
  106113. * @returns a new line system mesh
  106114. */
  106115. static CreateLineSystem(name: string, options: {
  106116. lines: Vector3[][];
  106117. updatable?: boolean;
  106118. instance?: Nullable<LinesMesh>;
  106119. colors?: Nullable<Color4[][]>;
  106120. useVertexAlpha?: boolean;
  106121. }, scene: Nullable<Scene>): LinesMesh;
  106122. /**
  106123. * Creates a line mesh
  106124. * 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
  106125. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106126. * * The parameter `points` is an array successive Vector3
  106127. * * 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
  106128. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106129. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106130. * * When updating an instance, remember that only point positions can change, not the number of points
  106131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106133. * @param name defines the name of the new line system
  106134. * @param options defines the options used to create the line system
  106135. * @param scene defines the hosting scene
  106136. * @returns a new line mesh
  106137. */
  106138. static CreateLines(name: string, options: {
  106139. points: Vector3[];
  106140. updatable?: boolean;
  106141. instance?: Nullable<LinesMesh>;
  106142. colors?: Color4[];
  106143. useVertexAlpha?: boolean;
  106144. }, scene?: Nullable<Scene>): LinesMesh;
  106145. /**
  106146. * Creates a dashed line mesh
  106147. * * 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
  106148. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106149. * * The parameter `points` is an array successive Vector3
  106150. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106151. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106152. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106153. * * 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
  106154. * * When updating an instance, remember that only point positions can change, not the number of points
  106155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106156. * @param name defines the name of the mesh
  106157. * @param options defines the options used to create the mesh
  106158. * @param scene defines the hosting scene
  106159. * @returns the dashed line mesh
  106160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106161. */
  106162. static CreateDashedLines(name: string, options: {
  106163. points: Vector3[];
  106164. dashSize?: number;
  106165. gapSize?: number;
  106166. dashNb?: number;
  106167. updatable?: boolean;
  106168. instance?: LinesMesh;
  106169. }, scene?: Nullable<Scene>): LinesMesh;
  106170. /**
  106171. * 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.
  106172. * * 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.
  106173. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106174. * * 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.
  106175. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106176. * * 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
  106177. * * 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
  106178. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106181. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106183. * @param name defines the name of the mesh
  106184. * @param options defines the options used to create the mesh
  106185. * @param scene defines the hosting scene
  106186. * @returns the extruded shape mesh
  106187. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106189. */
  106190. static ExtrudeShape(name: string, options: {
  106191. shape: Vector3[];
  106192. path: Vector3[];
  106193. scale?: number;
  106194. rotation?: number;
  106195. cap?: number;
  106196. updatable?: boolean;
  106197. sideOrientation?: number;
  106198. frontUVs?: Vector4;
  106199. backUVs?: Vector4;
  106200. instance?: Mesh;
  106201. invertUV?: boolean;
  106202. }, scene?: Nullable<Scene>): Mesh;
  106203. /**
  106204. * Creates an custom extruded shape mesh.
  106205. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106206. * * 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.
  106207. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106208. * * 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
  106209. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106210. * * 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
  106211. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106212. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106213. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106214. * * 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
  106215. * * 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
  106216. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106221. * @param name defines the name of the mesh
  106222. * @param options defines the options used to create the mesh
  106223. * @param scene defines the hosting scene
  106224. * @returns the custom extruded shape mesh
  106225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106227. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106228. */
  106229. static ExtrudeShapeCustom(name: string, options: {
  106230. shape: Vector3[];
  106231. path: Vector3[];
  106232. scaleFunction?: any;
  106233. rotationFunction?: any;
  106234. ribbonCloseArray?: boolean;
  106235. ribbonClosePath?: boolean;
  106236. cap?: number;
  106237. updatable?: boolean;
  106238. sideOrientation?: number;
  106239. frontUVs?: Vector4;
  106240. backUVs?: Vector4;
  106241. instance?: Mesh;
  106242. invertUV?: boolean;
  106243. }, scene: Scene): Mesh;
  106244. /**
  106245. * Creates lathe mesh.
  106246. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106247. * * 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
  106248. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106249. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106250. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106251. * * 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
  106252. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106253. * * 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
  106254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106256. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106258. * @param name defines the name of the mesh
  106259. * @param options defines the options used to create the mesh
  106260. * @param scene defines the hosting scene
  106261. * @returns the lathe mesh
  106262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106263. */
  106264. static CreateLathe(name: string, options: {
  106265. shape: Vector3[];
  106266. radius?: number;
  106267. tessellation?: number;
  106268. clip?: number;
  106269. arc?: number;
  106270. closed?: boolean;
  106271. updatable?: boolean;
  106272. sideOrientation?: number;
  106273. frontUVs?: Vector4;
  106274. backUVs?: Vector4;
  106275. cap?: number;
  106276. invertUV?: boolean;
  106277. }, scene: Scene): Mesh;
  106278. /**
  106279. * Creates a plane mesh
  106280. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  106281. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  106282. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  106283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106286. * @param name defines the name of the mesh
  106287. * @param options defines the options used to create the mesh
  106288. * @param scene defines the hosting scene
  106289. * @returns the plane mesh
  106290. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  106291. */
  106292. static CreatePlane(name: string, options: {
  106293. size?: number;
  106294. width?: number;
  106295. height?: number;
  106296. sideOrientation?: number;
  106297. frontUVs?: Vector4;
  106298. backUVs?: Vector4;
  106299. updatable?: boolean;
  106300. sourcePlane?: Plane;
  106301. }, scene: Scene): Mesh;
  106302. /**
  106303. * Creates a ground mesh
  106304. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106305. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106307. * @param name defines the name of the mesh
  106308. * @param options defines the options used to create the mesh
  106309. * @param scene defines the hosting scene
  106310. * @returns the ground mesh
  106311. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106312. */
  106313. static CreateGround(name: string, options: {
  106314. width?: number;
  106315. height?: number;
  106316. subdivisions?: number;
  106317. subdivisionsX?: number;
  106318. subdivisionsY?: number;
  106319. updatable?: boolean;
  106320. }, scene: any): Mesh;
  106321. /**
  106322. * Creates a tiled ground mesh
  106323. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106324. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106325. * * 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
  106326. * * 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
  106327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106328. * @param name defines the name of the mesh
  106329. * @param options defines the options used to create the mesh
  106330. * @param scene defines the hosting scene
  106331. * @returns the tiled ground mesh
  106332. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106333. */
  106334. static CreateTiledGround(name: string, options: {
  106335. xmin: number;
  106336. zmin: number;
  106337. xmax: number;
  106338. zmax: number;
  106339. subdivisions?: {
  106340. w: number;
  106341. h: number;
  106342. };
  106343. precision?: {
  106344. w: number;
  106345. h: number;
  106346. };
  106347. updatable?: boolean;
  106348. }, scene: Scene): Mesh;
  106349. /**
  106350. * Creates a ground mesh from a height map
  106351. * * The parameter `url` sets the URL of the height map image resource.
  106352. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106353. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106354. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106355. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106356. * * 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.
  106357. * * 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).
  106358. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106360. * @param name defines the name of the mesh
  106361. * @param url defines the url to the height map
  106362. * @param options defines the options used to create the mesh
  106363. * @param scene defines the hosting scene
  106364. * @returns the ground mesh
  106365. * @see https://doc.babylonjs.com/babylon101/height_map
  106366. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106367. */
  106368. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106369. width?: number;
  106370. height?: number;
  106371. subdivisions?: number;
  106372. minHeight?: number;
  106373. maxHeight?: number;
  106374. colorFilter?: Color3;
  106375. alphaFilter?: number;
  106376. updatable?: boolean;
  106377. onReady?: (mesh: GroundMesh) => void;
  106378. }, scene: Scene): GroundMesh;
  106379. /**
  106380. * Creates a polygon mesh
  106381. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106382. * * 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
  106383. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106386. * * Remember you can only change the shape positions, not their number when updating a polygon
  106387. * @param name defines the name of the mesh
  106388. * @param options defines the options used to create the mesh
  106389. * @param scene defines the hosting scene
  106390. * @param earcutInjection can be used to inject your own earcut reference
  106391. * @returns the polygon mesh
  106392. */
  106393. static CreatePolygon(name: string, options: {
  106394. shape: Vector3[];
  106395. holes?: Vector3[][];
  106396. depth?: number;
  106397. faceUV?: Vector4[];
  106398. faceColors?: Color4[];
  106399. updatable?: boolean;
  106400. sideOrientation?: number;
  106401. frontUVs?: Vector4;
  106402. backUVs?: Vector4;
  106403. }, scene: Scene, earcutInjection?: any): Mesh;
  106404. /**
  106405. * Creates an extruded polygon mesh, with depth in the Y direction.
  106406. * * 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)
  106407. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106408. * @param name defines the name of the mesh
  106409. * @param options defines the options used to create the mesh
  106410. * @param scene defines the hosting scene
  106411. * @param earcutInjection can be used to inject your own earcut reference
  106412. * @returns the polygon mesh
  106413. */
  106414. static ExtrudePolygon(name: string, options: {
  106415. shape: Vector3[];
  106416. holes?: Vector3[][];
  106417. depth?: number;
  106418. faceUV?: Vector4[];
  106419. faceColors?: Color4[];
  106420. updatable?: boolean;
  106421. sideOrientation?: number;
  106422. frontUVs?: Vector4;
  106423. backUVs?: Vector4;
  106424. }, scene: Scene, earcutInjection?: any): Mesh;
  106425. /**
  106426. * Creates a tube mesh.
  106427. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106428. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106429. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106430. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106431. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106432. * * 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)
  106433. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106434. * * 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
  106435. * * 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
  106436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106438. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106440. * @param name defines the name of the mesh
  106441. * @param options defines the options used to create the mesh
  106442. * @param scene defines the hosting scene
  106443. * @returns the tube mesh
  106444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106445. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106446. */
  106447. static CreateTube(name: string, options: {
  106448. path: Vector3[];
  106449. radius?: number;
  106450. tessellation?: number;
  106451. radiusFunction?: {
  106452. (i: number, distance: number): number;
  106453. };
  106454. cap?: number;
  106455. arc?: number;
  106456. updatable?: boolean;
  106457. sideOrientation?: number;
  106458. frontUVs?: Vector4;
  106459. backUVs?: Vector4;
  106460. instance?: Mesh;
  106461. invertUV?: boolean;
  106462. }, scene: Scene): Mesh;
  106463. /**
  106464. * Creates a polyhedron mesh
  106465. * * 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
  106466. * * The parameter `size` (positive float, default 1) sets the polygon size
  106467. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106468. * * 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`
  106469. * * 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
  106470. * * 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)`)
  106471. * * 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
  106472. * * 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
  106473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106476. * @param name defines the name of the mesh
  106477. * @param options defines the options used to create the mesh
  106478. * @param scene defines the hosting scene
  106479. * @returns the polyhedron mesh
  106480. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106481. */
  106482. static CreatePolyhedron(name: string, options: {
  106483. type?: number;
  106484. size?: number;
  106485. sizeX?: number;
  106486. sizeY?: number;
  106487. sizeZ?: number;
  106488. custom?: any;
  106489. faceUV?: Vector4[];
  106490. faceColors?: Color4[];
  106491. flat?: boolean;
  106492. updatable?: boolean;
  106493. sideOrientation?: number;
  106494. frontUVs?: Vector4;
  106495. backUVs?: Vector4;
  106496. }, scene: Scene): Mesh;
  106497. /**
  106498. * Creates a decal mesh.
  106499. * 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
  106500. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106501. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106502. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106503. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106504. * @param name defines the name of the mesh
  106505. * @param sourceMesh defines the mesh where the decal must be applied
  106506. * @param options defines the options used to create the mesh
  106507. * @param scene defines the hosting scene
  106508. * @returns the decal mesh
  106509. * @see https://doc.babylonjs.com/how_to/decals
  106510. */
  106511. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106512. position?: Vector3;
  106513. normal?: Vector3;
  106514. size?: Vector3;
  106515. angle?: number;
  106516. }): Mesh;
  106517. }
  106518. }
  106519. declare module BABYLON {
  106520. /**
  106521. * A simplifier interface for future simplification implementations
  106522. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106523. */
  106524. export interface ISimplifier {
  106525. /**
  106526. * Simplification of a given mesh according to the given settings.
  106527. * Since this requires computation, it is assumed that the function runs async.
  106528. * @param settings The settings of the simplification, including quality and distance
  106529. * @param successCallback A callback that will be called after the mesh was simplified.
  106530. * @param errorCallback in case of an error, this callback will be called. optional.
  106531. */
  106532. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106533. }
  106534. /**
  106535. * Expected simplification settings.
  106536. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106537. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106538. */
  106539. export interface ISimplificationSettings {
  106540. /**
  106541. * Gets or sets the expected quality
  106542. */
  106543. quality: number;
  106544. /**
  106545. * Gets or sets the distance when this optimized version should be used
  106546. */
  106547. distance: number;
  106548. /**
  106549. * Gets an already optimized mesh
  106550. */
  106551. optimizeMesh?: boolean;
  106552. }
  106553. /**
  106554. * Class used to specify simplification options
  106555. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106556. */
  106557. export class SimplificationSettings implements ISimplificationSettings {
  106558. /** expected quality */
  106559. quality: number;
  106560. /** distance when this optimized version should be used */
  106561. distance: number;
  106562. /** already optimized mesh */
  106563. optimizeMesh?: boolean | undefined;
  106564. /**
  106565. * Creates a SimplificationSettings
  106566. * @param quality expected quality
  106567. * @param distance distance when this optimized version should be used
  106568. * @param optimizeMesh already optimized mesh
  106569. */
  106570. constructor(
  106571. /** expected quality */
  106572. quality: number,
  106573. /** distance when this optimized version should be used */
  106574. distance: number,
  106575. /** already optimized mesh */
  106576. optimizeMesh?: boolean | undefined);
  106577. }
  106578. /**
  106579. * Interface used to define a simplification task
  106580. */
  106581. export interface ISimplificationTask {
  106582. /**
  106583. * Array of settings
  106584. */
  106585. settings: Array<ISimplificationSettings>;
  106586. /**
  106587. * Simplification type
  106588. */
  106589. simplificationType: SimplificationType;
  106590. /**
  106591. * Mesh to simplify
  106592. */
  106593. mesh: Mesh;
  106594. /**
  106595. * Callback called on success
  106596. */
  106597. successCallback?: () => void;
  106598. /**
  106599. * Defines if parallel processing can be used
  106600. */
  106601. parallelProcessing: boolean;
  106602. }
  106603. /**
  106604. * Queue used to order the simplification tasks
  106605. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106606. */
  106607. export class SimplificationQueue {
  106608. private _simplificationArray;
  106609. /**
  106610. * Gets a boolean indicating that the process is still running
  106611. */
  106612. running: boolean;
  106613. /**
  106614. * Creates a new queue
  106615. */
  106616. constructor();
  106617. /**
  106618. * Adds a new simplification task
  106619. * @param task defines a task to add
  106620. */
  106621. addTask(task: ISimplificationTask): void;
  106622. /**
  106623. * Execute next task
  106624. */
  106625. executeNext(): void;
  106626. /**
  106627. * Execute a simplification task
  106628. * @param task defines the task to run
  106629. */
  106630. runSimplification(task: ISimplificationTask): void;
  106631. private getSimplifier;
  106632. }
  106633. /**
  106634. * The implemented types of simplification
  106635. * At the moment only Quadratic Error Decimation is implemented
  106636. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106637. */
  106638. export enum SimplificationType {
  106639. /** Quadratic error decimation */
  106640. QUADRATIC = 0
  106641. }
  106642. }
  106643. declare module BABYLON {
  106644. interface Scene {
  106645. /** @hidden (Backing field) */
  106646. _simplificationQueue: SimplificationQueue;
  106647. /**
  106648. * Gets or sets the simplification queue attached to the scene
  106649. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106650. */
  106651. simplificationQueue: SimplificationQueue;
  106652. }
  106653. interface Mesh {
  106654. /**
  106655. * Simplify the mesh according to the given array of settings.
  106656. * Function will return immediately and will simplify async
  106657. * @param settings a collection of simplification settings
  106658. * @param parallelProcessing should all levels calculate parallel or one after the other
  106659. * @param simplificationType the type of simplification to run
  106660. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106661. * @returns the current mesh
  106662. */
  106663. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106664. }
  106665. /**
  106666. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106667. * created in a scene
  106668. */
  106669. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106670. /**
  106671. * The component name helpfull to identify the component in the list of scene components.
  106672. */
  106673. readonly name: string;
  106674. /**
  106675. * The scene the component belongs to.
  106676. */
  106677. scene: Scene;
  106678. /**
  106679. * Creates a new instance of the component for the given scene
  106680. * @param scene Defines the scene to register the component in
  106681. */
  106682. constructor(scene: Scene);
  106683. /**
  106684. * Registers the component in a given scene
  106685. */
  106686. register(): void;
  106687. /**
  106688. * Rebuilds the elements related to this component in case of
  106689. * context lost for instance.
  106690. */
  106691. rebuild(): void;
  106692. /**
  106693. * Disposes the component and the associated ressources
  106694. */
  106695. dispose(): void;
  106696. private _beforeCameraUpdate;
  106697. }
  106698. }
  106699. declare module BABYLON {
  106700. /**
  106701. * Class used to enable access to IndexedDB
  106702. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106703. */
  106704. export class Database implements IOfflineProvider {
  106705. private _callbackManifestChecked;
  106706. private _currentSceneUrl;
  106707. private _db;
  106708. private _enableSceneOffline;
  106709. private _enableTexturesOffline;
  106710. private _manifestVersionFound;
  106711. private _mustUpdateRessources;
  106712. private _hasReachedQuota;
  106713. private _isSupported;
  106714. private _idbFactory;
  106715. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106716. private static IsUASupportingBlobStorage;
  106717. /**
  106718. * Gets a boolean indicating if Database storate is enabled (off by default)
  106719. */
  106720. static IDBStorageEnabled: boolean;
  106721. /**
  106722. * Gets a boolean indicating if scene must be saved in the database
  106723. */
  106724. readonly enableSceneOffline: boolean;
  106725. /**
  106726. * Gets a boolean indicating if textures must be saved in the database
  106727. */
  106728. readonly enableTexturesOffline: boolean;
  106729. /**
  106730. * Creates a new Database
  106731. * @param urlToScene defines the url to load the scene
  106732. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106733. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106734. */
  106735. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106736. private static _ParseURL;
  106737. private static _ReturnFullUrlLocation;
  106738. private _checkManifestFile;
  106739. /**
  106740. * Open the database and make it available
  106741. * @param successCallback defines the callback to call on success
  106742. * @param errorCallback defines the callback to call on error
  106743. */
  106744. open(successCallback: () => void, errorCallback: () => void): void;
  106745. /**
  106746. * Loads an image from the database
  106747. * @param url defines the url to load from
  106748. * @param image defines the target DOM image
  106749. */
  106750. loadImage(url: string, image: HTMLImageElement): void;
  106751. private _loadImageFromDBAsync;
  106752. private _saveImageIntoDBAsync;
  106753. private _checkVersionFromDB;
  106754. private _loadVersionFromDBAsync;
  106755. private _saveVersionIntoDBAsync;
  106756. /**
  106757. * Loads a file from database
  106758. * @param url defines the URL to load from
  106759. * @param sceneLoaded defines a callback to call on success
  106760. * @param progressCallBack defines a callback to call when progress changed
  106761. * @param errorCallback defines a callback to call on error
  106762. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106763. */
  106764. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106765. private _loadFileAsync;
  106766. private _saveFileAsync;
  106767. /**
  106768. * Validates if xhr data is correct
  106769. * @param xhr defines the request to validate
  106770. * @param dataType defines the expected data type
  106771. * @returns true if data is correct
  106772. */
  106773. private static _ValidateXHRData;
  106774. }
  106775. }
  106776. declare module BABYLON {
  106777. /** @hidden */
  106778. export var gpuUpdateParticlesPixelShader: {
  106779. name: string;
  106780. shader: string;
  106781. };
  106782. }
  106783. declare module BABYLON {
  106784. /** @hidden */
  106785. export var gpuUpdateParticlesVertexShader: {
  106786. name: string;
  106787. shader: string;
  106788. };
  106789. }
  106790. declare module BABYLON {
  106791. /** @hidden */
  106792. export var clipPlaneFragmentDeclaration2: {
  106793. name: string;
  106794. shader: string;
  106795. };
  106796. }
  106797. declare module BABYLON {
  106798. /** @hidden */
  106799. export var gpuRenderParticlesPixelShader: {
  106800. name: string;
  106801. shader: string;
  106802. };
  106803. }
  106804. declare module BABYLON {
  106805. /** @hidden */
  106806. export var clipPlaneVertexDeclaration2: {
  106807. name: string;
  106808. shader: string;
  106809. };
  106810. }
  106811. declare module BABYLON {
  106812. /** @hidden */
  106813. export var gpuRenderParticlesVertexShader: {
  106814. name: string;
  106815. shader: string;
  106816. };
  106817. }
  106818. declare module BABYLON {
  106819. /**
  106820. * This represents a GPU particle system in Babylon
  106821. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106822. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106823. */
  106824. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106825. /**
  106826. * The layer mask we are rendering the particles through.
  106827. */
  106828. layerMask: number;
  106829. private _capacity;
  106830. private _activeCount;
  106831. private _currentActiveCount;
  106832. private _accumulatedCount;
  106833. private _renderEffect;
  106834. private _updateEffect;
  106835. private _buffer0;
  106836. private _buffer1;
  106837. private _spriteBuffer;
  106838. private _updateVAO;
  106839. private _renderVAO;
  106840. private _targetIndex;
  106841. private _sourceBuffer;
  106842. private _targetBuffer;
  106843. private _engine;
  106844. private _currentRenderId;
  106845. private _started;
  106846. private _stopped;
  106847. private _timeDelta;
  106848. private _randomTexture;
  106849. private _randomTexture2;
  106850. private _attributesStrideSize;
  106851. private _updateEffectOptions;
  106852. private _randomTextureSize;
  106853. private _actualFrame;
  106854. private readonly _rawTextureWidth;
  106855. /**
  106856. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106857. */
  106858. static readonly IsSupported: boolean;
  106859. /**
  106860. * An event triggered when the system is disposed.
  106861. */
  106862. onDisposeObservable: Observable<GPUParticleSystem>;
  106863. /**
  106864. * Gets the maximum number of particles active at the same time.
  106865. * @returns The max number of active particles.
  106866. */
  106867. getCapacity(): number;
  106868. /**
  106869. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106870. * to override the particles.
  106871. */
  106872. forceDepthWrite: boolean;
  106873. /**
  106874. * Gets or set the number of active particles
  106875. */
  106876. activeParticleCount: number;
  106877. private _preWarmDone;
  106878. /**
  106879. * Is this system ready to be used/rendered
  106880. * @return true if the system is ready
  106881. */
  106882. isReady(): boolean;
  106883. /**
  106884. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106885. * @returns True if it has been started, otherwise false.
  106886. */
  106887. isStarted(): boolean;
  106888. /**
  106889. * Starts the particle system and begins to emit
  106890. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106891. */
  106892. start(delay?: number): void;
  106893. /**
  106894. * Stops the particle system.
  106895. */
  106896. stop(): void;
  106897. /**
  106898. * Remove all active particles
  106899. */
  106900. reset(): void;
  106901. /**
  106902. * Returns the string "GPUParticleSystem"
  106903. * @returns a string containing the class name
  106904. */
  106905. getClassName(): string;
  106906. private _colorGradientsTexture;
  106907. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106908. /**
  106909. * Adds a new color gradient
  106910. * @param gradient defines the gradient to use (between 0 and 1)
  106911. * @param color1 defines the color to affect to the specified gradient
  106912. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106913. * @returns the current particle system
  106914. */
  106915. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106916. /**
  106917. * Remove a specific color gradient
  106918. * @param gradient defines the gradient to remove
  106919. * @returns the current particle system
  106920. */
  106921. removeColorGradient(gradient: number): GPUParticleSystem;
  106922. private _angularSpeedGradientsTexture;
  106923. private _sizeGradientsTexture;
  106924. private _velocityGradientsTexture;
  106925. private _limitVelocityGradientsTexture;
  106926. private _dragGradientsTexture;
  106927. private _addFactorGradient;
  106928. /**
  106929. * Adds a new size gradient
  106930. * @param gradient defines the gradient to use (between 0 and 1)
  106931. * @param factor defines the size factor to affect to the specified gradient
  106932. * @returns the current particle system
  106933. */
  106934. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106935. /**
  106936. * Remove a specific size gradient
  106937. * @param gradient defines the gradient to remove
  106938. * @returns the current particle system
  106939. */
  106940. removeSizeGradient(gradient: number): GPUParticleSystem;
  106941. /**
  106942. * Adds a new angular speed gradient
  106943. * @param gradient defines the gradient to use (between 0 and 1)
  106944. * @param factor defines the angular speed to affect to the specified gradient
  106945. * @returns the current particle system
  106946. */
  106947. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  106948. /**
  106949. * Remove a specific angular speed gradient
  106950. * @param gradient defines the gradient to remove
  106951. * @returns the current particle system
  106952. */
  106953. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  106954. /**
  106955. * Adds a new velocity gradient
  106956. * @param gradient defines the gradient to use (between 0 and 1)
  106957. * @param factor defines the velocity to affect to the specified gradient
  106958. * @returns the current particle system
  106959. */
  106960. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106961. /**
  106962. * Remove a specific velocity gradient
  106963. * @param gradient defines the gradient to remove
  106964. * @returns the current particle system
  106965. */
  106966. removeVelocityGradient(gradient: number): GPUParticleSystem;
  106967. /**
  106968. * Adds a new limit velocity gradient
  106969. * @param gradient defines the gradient to use (between 0 and 1)
  106970. * @param factor defines the limit velocity value to affect to the specified gradient
  106971. * @returns the current particle system
  106972. */
  106973. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106974. /**
  106975. * Remove a specific limit velocity gradient
  106976. * @param gradient defines the gradient to remove
  106977. * @returns the current particle system
  106978. */
  106979. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  106980. /**
  106981. * Adds a new drag gradient
  106982. * @param gradient defines the gradient to use (between 0 and 1)
  106983. * @param factor defines the drag value to affect to the specified gradient
  106984. * @returns the current particle system
  106985. */
  106986. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  106987. /**
  106988. * Remove a specific drag gradient
  106989. * @param gradient defines the gradient to remove
  106990. * @returns the current particle system
  106991. */
  106992. removeDragGradient(gradient: number): GPUParticleSystem;
  106993. /**
  106994. * Not supported by GPUParticleSystem
  106995. * @param gradient defines the gradient to use (between 0 and 1)
  106996. * @param factor defines the emit rate value to affect to the specified gradient
  106997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106998. * @returns the current particle system
  106999. */
  107000. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107001. /**
  107002. * Not supported by GPUParticleSystem
  107003. * @param gradient defines the gradient to remove
  107004. * @returns the current particle system
  107005. */
  107006. removeEmitRateGradient(gradient: number): IParticleSystem;
  107007. /**
  107008. * Not supported by GPUParticleSystem
  107009. * @param gradient defines the gradient to use (between 0 and 1)
  107010. * @param factor defines the start size value to affect to the specified gradient
  107011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107012. * @returns the current particle system
  107013. */
  107014. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107015. /**
  107016. * Not supported by GPUParticleSystem
  107017. * @param gradient defines the gradient to remove
  107018. * @returns the current particle system
  107019. */
  107020. removeStartSizeGradient(gradient: number): IParticleSystem;
  107021. /**
  107022. * Not supported by GPUParticleSystem
  107023. * @param gradient defines the gradient to use (between 0 and 1)
  107024. * @param min defines the color remap minimal range
  107025. * @param max defines the color remap maximal range
  107026. * @returns the current particle system
  107027. */
  107028. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107029. /**
  107030. * Not supported by GPUParticleSystem
  107031. * @param gradient defines the gradient to remove
  107032. * @returns the current particle system
  107033. */
  107034. removeColorRemapGradient(): IParticleSystem;
  107035. /**
  107036. * Not supported by GPUParticleSystem
  107037. * @param gradient defines the gradient to use (between 0 and 1)
  107038. * @param min defines the alpha remap minimal range
  107039. * @param max defines the alpha remap maximal range
  107040. * @returns the current particle system
  107041. */
  107042. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107043. /**
  107044. * Not supported by GPUParticleSystem
  107045. * @param gradient defines the gradient to remove
  107046. * @returns the current particle system
  107047. */
  107048. removeAlphaRemapGradient(): IParticleSystem;
  107049. /**
  107050. * Not supported by GPUParticleSystem
  107051. * @param gradient defines the gradient to use (between 0 and 1)
  107052. * @param color defines the color to affect to the specified gradient
  107053. * @returns the current particle system
  107054. */
  107055. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  107056. /**
  107057. * Not supported by GPUParticleSystem
  107058. * @param gradient defines the gradient to remove
  107059. * @returns the current particle system
  107060. */
  107061. removeRampGradient(): IParticleSystem;
  107062. /**
  107063. * Not supported by GPUParticleSystem
  107064. * @returns the list of ramp gradients
  107065. */
  107066. getRampGradients(): Nullable<Array<Color3Gradient>>;
  107067. /**
  107068. * Not supported by GPUParticleSystem
  107069. * Gets or sets a boolean indicating that ramp gradients must be used
  107070. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107071. */
  107072. useRampGradients: boolean;
  107073. /**
  107074. * Not supported by GPUParticleSystem
  107075. * @param gradient defines the gradient to use (between 0 and 1)
  107076. * @param factor defines the life time factor to affect to the specified gradient
  107077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107078. * @returns the current particle system
  107079. */
  107080. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107081. /**
  107082. * Not supported by GPUParticleSystem
  107083. * @param gradient defines the gradient to remove
  107084. * @returns the current particle system
  107085. */
  107086. removeLifeTimeGradient(gradient: number): IParticleSystem;
  107087. /**
  107088. * Instantiates a GPU particle system.
  107089. * 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.
  107090. * @param name The name of the particle system
  107091. * @param options The options used to create the system
  107092. * @param scene The scene the particle system belongs to
  107093. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107094. */
  107095. constructor(name: string, options: Partial<{
  107096. capacity: number;
  107097. randomTextureSize: number;
  107098. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  107099. protected _reset(): void;
  107100. private _createUpdateVAO;
  107101. private _createRenderVAO;
  107102. private _initialize;
  107103. /** @hidden */
  107104. _recreateUpdateEffect(): void;
  107105. /** @hidden */
  107106. _recreateRenderEffect(): void;
  107107. /**
  107108. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107109. * @param preWarm defines if we are in the pre-warmimg phase
  107110. */
  107111. animate(preWarm?: boolean): void;
  107112. private _createFactorGradientTexture;
  107113. private _createSizeGradientTexture;
  107114. private _createAngularSpeedGradientTexture;
  107115. private _createVelocityGradientTexture;
  107116. private _createLimitVelocityGradientTexture;
  107117. private _createDragGradientTexture;
  107118. private _createColorGradientTexture;
  107119. /**
  107120. * Renders the particle system in its current state
  107121. * @param preWarm defines if the system should only update the particles but not render them
  107122. * @returns the current number of particles
  107123. */
  107124. render(preWarm?: boolean): number;
  107125. /**
  107126. * Rebuilds the particle system
  107127. */
  107128. rebuild(): void;
  107129. private _releaseBuffers;
  107130. private _releaseVAOs;
  107131. /**
  107132. * Disposes the particle system and free the associated resources
  107133. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107134. */
  107135. dispose(disposeTexture?: boolean): void;
  107136. /**
  107137. * Clones the particle system.
  107138. * @param name The name of the cloned object
  107139. * @param newEmitter The new emitter to use
  107140. * @returns the cloned particle system
  107141. */
  107142. clone(name: string, newEmitter: any): GPUParticleSystem;
  107143. /**
  107144. * Serializes the particle system to a JSON object.
  107145. * @returns the JSON object
  107146. */
  107147. serialize(): any;
  107148. /**
  107149. * Parses a JSON object to create a GPU particle system.
  107150. * @param parsedParticleSystem The JSON object to parse
  107151. * @param scene The scene to create the particle system in
  107152. * @param rootUrl The root url to use to load external dependencies like texture
  107153. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107154. * @returns the parsed GPU particle system
  107155. */
  107156. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  107157. }
  107158. }
  107159. declare module BABYLON {
  107160. /**
  107161. * Represents a set of particle systems working together to create a specific effect
  107162. */
  107163. export class ParticleSystemSet implements IDisposable {
  107164. private _emitterCreationOptions;
  107165. private _emitterNode;
  107166. /**
  107167. * Gets the particle system list
  107168. */
  107169. systems: IParticleSystem[];
  107170. /**
  107171. * Gets the emitter node used with this set
  107172. */
  107173. readonly emitterNode: Nullable<TransformNode>;
  107174. /**
  107175. * Creates a new emitter mesh as a sphere
  107176. * @param options defines the options used to create the sphere
  107177. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107178. * @param scene defines the hosting scene
  107179. */
  107180. setEmitterAsSphere(options: {
  107181. diameter: number;
  107182. segments: number;
  107183. color: Color3;
  107184. }, renderingGroupId: number, scene: Scene): void;
  107185. /**
  107186. * Starts all particle systems of the set
  107187. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107188. */
  107189. start(emitter?: AbstractMesh): void;
  107190. /**
  107191. * Release all associated resources
  107192. */
  107193. dispose(): void;
  107194. /**
  107195. * Serialize the set into a JSON compatible object
  107196. * @returns a JSON compatible representation of the set
  107197. */
  107198. serialize(): any;
  107199. /**
  107200. * Parse a new ParticleSystemSet from a serialized source
  107201. * @param data defines a JSON compatible representation of the set
  107202. * @param scene defines the hosting scene
  107203. * @param gpu defines if we want GPU particles or CPU particles
  107204. * @returns a new ParticleSystemSet
  107205. */
  107206. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  107207. }
  107208. }
  107209. declare module BABYLON {
  107210. /**
  107211. * This class is made for on one-liner static method to help creating particle system set.
  107212. */
  107213. export class ParticleHelper {
  107214. /**
  107215. * Gets or sets base Assets URL
  107216. */
  107217. static BaseAssetsUrl: string;
  107218. /**
  107219. * Create a default particle system that you can tweak
  107220. * @param emitter defines the emitter to use
  107221. * @param capacity defines the system capacity (default is 500 particles)
  107222. * @param scene defines the hosting scene
  107223. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  107224. * @returns the new Particle system
  107225. */
  107226. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  107227. /**
  107228. * This is the main static method (one-liner) of this helper to create different particle systems
  107229. * @param type This string represents the type to the particle system to create
  107230. * @param scene The scene where the particle system should live
  107231. * @param gpu If the system will use gpu
  107232. * @returns the ParticleSystemSet created
  107233. */
  107234. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  107235. /**
  107236. * Static function used to export a particle system to a ParticleSystemSet variable.
  107237. * Please note that the emitter shape is not exported
  107238. * @param systems defines the particle systems to export
  107239. * @returns the created particle system set
  107240. */
  107241. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  107242. }
  107243. }
  107244. declare module BABYLON {
  107245. interface Engine {
  107246. /**
  107247. * Create an effect to use with particle systems.
  107248. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  107249. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  107250. * @param uniformsNames defines a list of attribute names
  107251. * @param samplers defines an array of string used to represent textures
  107252. * @param defines defines the string containing the defines to use to compile the shaders
  107253. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107254. * @param onCompiled defines a function to call when the effect creation is successful
  107255. * @param onError defines a function to call when the effect creation has failed
  107256. * @returns the new Effect
  107257. */
  107258. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  107259. }
  107260. interface Mesh {
  107261. /**
  107262. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  107263. * @returns an array of IParticleSystem
  107264. */
  107265. getEmittedParticleSystems(): IParticleSystem[];
  107266. /**
  107267. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  107268. * @returns an array of IParticleSystem
  107269. */
  107270. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  107271. }
  107272. /**
  107273. * @hidden
  107274. */
  107275. export var _IDoNeedToBeInTheBuild: number;
  107276. }
  107277. declare module BABYLON {
  107278. interface Scene {
  107279. /** @hidden (Backing field) */
  107280. _physicsEngine: Nullable<IPhysicsEngine>;
  107281. /**
  107282. * Gets the current physics engine
  107283. * @returns a IPhysicsEngine or null if none attached
  107284. */
  107285. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  107286. /**
  107287. * Enables physics to the current scene
  107288. * @param gravity defines the scene's gravity for the physics engine
  107289. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  107290. * @return a boolean indicating if the physics engine was initialized
  107291. */
  107292. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  107293. /**
  107294. * Disables and disposes the physics engine associated with the scene
  107295. */
  107296. disablePhysicsEngine(): void;
  107297. /**
  107298. * Gets a boolean indicating if there is an active physics engine
  107299. * @returns a boolean indicating if there is an active physics engine
  107300. */
  107301. isPhysicsEnabled(): boolean;
  107302. /**
  107303. * Deletes a physics compound impostor
  107304. * @param compound defines the compound to delete
  107305. */
  107306. deleteCompoundImpostor(compound: any): void;
  107307. /**
  107308. * An event triggered when physic simulation is about to be run
  107309. */
  107310. onBeforePhysicsObservable: Observable<Scene>;
  107311. /**
  107312. * An event triggered when physic simulation has been done
  107313. */
  107314. onAfterPhysicsObservable: Observable<Scene>;
  107315. }
  107316. interface AbstractMesh {
  107317. /** @hidden */
  107318. _physicsImpostor: Nullable<PhysicsImpostor>;
  107319. /**
  107320. * Gets or sets impostor used for physic simulation
  107321. * @see http://doc.babylonjs.com/features/physics_engine
  107322. */
  107323. physicsImpostor: Nullable<PhysicsImpostor>;
  107324. /**
  107325. * Gets the current physics impostor
  107326. * @see http://doc.babylonjs.com/features/physics_engine
  107327. * @returns a physics impostor or null
  107328. */
  107329. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  107330. /** Apply a physic impulse to the mesh
  107331. * @param force defines the force to apply
  107332. * @param contactPoint defines where to apply the force
  107333. * @returns the current mesh
  107334. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107335. */
  107336. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  107337. /**
  107338. * Creates a physic joint between two meshes
  107339. * @param otherMesh defines the other mesh to use
  107340. * @param pivot1 defines the pivot to use on this mesh
  107341. * @param pivot2 defines the pivot to use on the other mesh
  107342. * @param options defines additional options (can be plugin dependent)
  107343. * @returns the current mesh
  107344. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  107345. */
  107346. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  107347. /** @hidden */
  107348. _disposePhysicsObserver: Nullable<Observer<Node>>;
  107349. }
  107350. /**
  107351. * Defines the physics engine scene component responsible to manage a physics engine
  107352. */
  107353. export class PhysicsEngineSceneComponent implements ISceneComponent {
  107354. /**
  107355. * The component name helpful to identify the component in the list of scene components.
  107356. */
  107357. readonly name: string;
  107358. /**
  107359. * The scene the component belongs to.
  107360. */
  107361. scene: Scene;
  107362. /**
  107363. * Creates a new instance of the component for the given scene
  107364. * @param scene Defines the scene to register the component in
  107365. */
  107366. constructor(scene: Scene);
  107367. /**
  107368. * Registers the component in a given scene
  107369. */
  107370. register(): void;
  107371. /**
  107372. * Rebuilds the elements related to this component in case of
  107373. * context lost for instance.
  107374. */
  107375. rebuild(): void;
  107376. /**
  107377. * Disposes the component and the associated ressources
  107378. */
  107379. dispose(): void;
  107380. }
  107381. }
  107382. declare module BABYLON {
  107383. /**
  107384. * A helper for physics simulations
  107385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107386. */
  107387. export class PhysicsHelper {
  107388. private _scene;
  107389. private _physicsEngine;
  107390. /**
  107391. * Initializes the Physics helper
  107392. * @param scene Babylon.js scene
  107393. */
  107394. constructor(scene: Scene);
  107395. /**
  107396. * Applies a radial explosion impulse
  107397. * @param origin the origin of the explosion
  107398. * @param radius the explosion radius
  107399. * @param strength the explosion strength
  107400. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107401. * @returns A physics radial explosion event, or null
  107402. */
  107403. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107404. /**
  107405. * Applies a radial explosion force
  107406. * @param origin the origin of the explosion
  107407. * @param radius the explosion radius
  107408. * @param strength the explosion strength
  107409. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107410. * @returns A physics radial explosion event, or null
  107411. */
  107412. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107413. /**
  107414. * Creates a gravitational field
  107415. * @param origin the origin of the explosion
  107416. * @param radius the explosion radius
  107417. * @param strength the explosion strength
  107418. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107419. * @returns A physics gravitational field event, or null
  107420. */
  107421. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107422. /**
  107423. * Creates a physics updraft event
  107424. * @param origin the origin of the updraft
  107425. * @param radius the radius of the updraft
  107426. * @param strength the strength of the updraft
  107427. * @param height the height of the updraft
  107428. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107429. * @returns A physics updraft event, or null
  107430. */
  107431. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107432. /**
  107433. * Creates a physics vortex event
  107434. * @param origin the of the vortex
  107435. * @param radius the radius of the vortex
  107436. * @param strength the strength of the vortex
  107437. * @param height the height of the vortex
  107438. * @returns a Physics vortex event, or null
  107439. * A physics vortex event or null
  107440. */
  107441. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107442. }
  107443. /**
  107444. * Represents a physics radial explosion event
  107445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107446. */
  107447. export class PhysicsRadialExplosionEvent {
  107448. private _scene;
  107449. private _sphere;
  107450. private _sphereOptions;
  107451. private _rays;
  107452. private _dataFetched;
  107453. /**
  107454. * Initializes a radial explosioin event
  107455. * @param scene BabylonJS scene
  107456. */
  107457. constructor(scene: Scene);
  107458. /**
  107459. * Returns the data related to the radial explosion event (sphere & rays).
  107460. * @returns The radial explosion event data
  107461. */
  107462. getData(): PhysicsRadialExplosionEventData;
  107463. /**
  107464. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107465. * @param impostor A physics imposter
  107466. * @param origin the origin of the explosion
  107467. * @param radius the explosion radius
  107468. * @param strength the explosion strength
  107469. * @param falloff possible options: Constant & Linear
  107470. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107471. */
  107472. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107473. /**
  107474. * Disposes the sphere.
  107475. * @param force Specifies if the sphere should be disposed by force
  107476. */
  107477. dispose(force?: boolean): void;
  107478. /*** Helpers ***/
  107479. private _prepareSphere;
  107480. private _intersectsWithSphere;
  107481. }
  107482. /**
  107483. * Represents a gravitational field event
  107484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107485. */
  107486. export class PhysicsGravitationalFieldEvent {
  107487. private _physicsHelper;
  107488. private _scene;
  107489. private _origin;
  107490. private _radius;
  107491. private _strength;
  107492. private _falloff;
  107493. private _tickCallback;
  107494. private _sphere;
  107495. private _dataFetched;
  107496. /**
  107497. * Initializes the physics gravitational field event
  107498. * @param physicsHelper A physics helper
  107499. * @param scene BabylonJS scene
  107500. * @param origin The origin position of the gravitational field event
  107501. * @param radius The radius of the gravitational field event
  107502. * @param strength The strength of the gravitational field event
  107503. * @param falloff The falloff for the gravitational field event
  107504. */
  107505. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107506. /**
  107507. * Returns the data related to the gravitational field event (sphere).
  107508. * @returns A gravitational field event
  107509. */
  107510. getData(): PhysicsGravitationalFieldEventData;
  107511. /**
  107512. * Enables the gravitational field.
  107513. */
  107514. enable(): void;
  107515. /**
  107516. * Disables the gravitational field.
  107517. */
  107518. disable(): void;
  107519. /**
  107520. * Disposes the sphere.
  107521. * @param force The force to dispose from the gravitational field event
  107522. */
  107523. dispose(force?: boolean): void;
  107524. private _tick;
  107525. }
  107526. /**
  107527. * Represents a physics updraft event
  107528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107529. */
  107530. export class PhysicsUpdraftEvent {
  107531. private _scene;
  107532. private _origin;
  107533. private _radius;
  107534. private _strength;
  107535. private _height;
  107536. private _updraftMode;
  107537. private _physicsEngine;
  107538. private _originTop;
  107539. private _originDirection;
  107540. private _tickCallback;
  107541. private _cylinder;
  107542. private _cylinderPosition;
  107543. private _dataFetched;
  107544. /**
  107545. * Initializes the physics updraft event
  107546. * @param _scene BabylonJS scene
  107547. * @param _origin The origin position of the updraft
  107548. * @param _radius The radius of the updraft
  107549. * @param _strength The strength of the updraft
  107550. * @param _height The height of the updraft
  107551. * @param _updraftMode The mode of the updraft
  107552. */
  107553. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107554. /**
  107555. * Returns the data related to the updraft event (cylinder).
  107556. * @returns A physics updraft event
  107557. */
  107558. getData(): PhysicsUpdraftEventData;
  107559. /**
  107560. * Enables the updraft.
  107561. */
  107562. enable(): void;
  107563. /**
  107564. * Disables the cortex.
  107565. */
  107566. disable(): void;
  107567. /**
  107568. * Disposes the sphere.
  107569. * @param force Specifies if the updraft should be disposed by force
  107570. */
  107571. dispose(force?: boolean): void;
  107572. private getImpostorForceAndContactPoint;
  107573. private _tick;
  107574. /*** Helpers ***/
  107575. private _prepareCylinder;
  107576. private _intersectsWithCylinder;
  107577. }
  107578. /**
  107579. * Represents a physics vortex event
  107580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107581. */
  107582. export class PhysicsVortexEvent {
  107583. private _scene;
  107584. private _origin;
  107585. private _radius;
  107586. private _strength;
  107587. private _height;
  107588. private _physicsEngine;
  107589. private _originTop;
  107590. private _centripetalForceThreshold;
  107591. private _updraftMultiplier;
  107592. private _tickCallback;
  107593. private _cylinder;
  107594. private _cylinderPosition;
  107595. private _dataFetched;
  107596. /**
  107597. * Initializes the physics vortex event
  107598. * @param _scene The BabylonJS scene
  107599. * @param _origin The origin position of the vortex
  107600. * @param _radius The radius of the vortex
  107601. * @param _strength The strength of the vortex
  107602. * @param _height The height of the vortex
  107603. */
  107604. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107605. /**
  107606. * Returns the data related to the vortex event (cylinder).
  107607. * @returns The physics vortex event data
  107608. */
  107609. getData(): PhysicsVortexEventData;
  107610. /**
  107611. * Enables the vortex.
  107612. */
  107613. enable(): void;
  107614. /**
  107615. * Disables the cortex.
  107616. */
  107617. disable(): void;
  107618. /**
  107619. * Disposes the sphere.
  107620. * @param force
  107621. */
  107622. dispose(force?: boolean): void;
  107623. private getImpostorForceAndContactPoint;
  107624. private _tick;
  107625. /*** Helpers ***/
  107626. private _prepareCylinder;
  107627. private _intersectsWithCylinder;
  107628. }
  107629. /**
  107630. * The strenght 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 PhysicsRadialImpulseFalloff {
  107634. /** Defines that impulse is constant in strength across it's whole radius */
  107635. Constant = 0,
  107636. /** DEfines that impulse gets weaker if it's further from the origin */
  107637. Linear = 1
  107638. }
  107639. /**
  107640. * The strength of the force in correspondence to the distance of the affected object
  107641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107642. */
  107643. export enum PhysicsUpdraftMode {
  107644. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107645. Center = 0,
  107646. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107647. Perpendicular = 1
  107648. }
  107649. /**
  107650. * Interface for a physics force and contact point
  107651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107652. */
  107653. export interface PhysicsForceAndContactPoint {
  107654. /**
  107655. * The force applied at the contact point
  107656. */
  107657. force: Vector3;
  107658. /**
  107659. * The contact point
  107660. */
  107661. contactPoint: Vector3;
  107662. }
  107663. /**
  107664. * Interface for radial explosion event data
  107665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107666. */
  107667. export interface PhysicsRadialExplosionEventData {
  107668. /**
  107669. * A sphere used for the radial explosion event
  107670. */
  107671. sphere: Mesh;
  107672. /**
  107673. * An array of rays for the radial explosion event
  107674. */
  107675. rays: Array<Ray>;
  107676. }
  107677. /**
  107678. * Interface for gravitational field event data
  107679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107680. */
  107681. export interface PhysicsGravitationalFieldEventData {
  107682. /**
  107683. * A sphere mesh used for the gravitational field event
  107684. */
  107685. sphere: Mesh;
  107686. }
  107687. /**
  107688. * Interface for updraft event data
  107689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107690. */
  107691. export interface PhysicsUpdraftEventData {
  107692. /**
  107693. * A cylinder used for the updraft event
  107694. */
  107695. cylinder: Mesh;
  107696. }
  107697. /**
  107698. * Interface for vortex event data
  107699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107700. */
  107701. export interface PhysicsVortexEventData {
  107702. /**
  107703. * A cylinder used for the vortex event
  107704. */
  107705. cylinder: Mesh;
  107706. }
  107707. }
  107708. declare module BABYLON {
  107709. /**
  107710. * AmmoJS Physics plugin
  107711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107712. * @see https://github.com/kripken/ammo.js/
  107713. */
  107714. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107715. private _useDeltaForWorldStep;
  107716. /**
  107717. * Reference to the Ammo library
  107718. */
  107719. bjsAMMO: any;
  107720. /**
  107721. * Created ammoJS world which physics bodies are added to
  107722. */
  107723. world: any;
  107724. /**
  107725. * Name of the plugin
  107726. */
  107727. name: string;
  107728. private _timeStep;
  107729. private _fixedTimeStep;
  107730. private _maxSteps;
  107731. private _tmpQuaternion;
  107732. private _tmpAmmoTransform;
  107733. private _tmpAmmoQuaternion;
  107734. private _tmpAmmoConcreteContactResultCallback;
  107735. private _collisionConfiguration;
  107736. private _dispatcher;
  107737. private _overlappingPairCache;
  107738. private _solver;
  107739. private _tmpAmmoVectorA;
  107740. private _tmpAmmoVectorB;
  107741. private _tmpAmmoVectorC;
  107742. private _tmpContactCallbackResult;
  107743. private static readonly DISABLE_COLLISION_FLAG;
  107744. private static readonly KINEMATIC_FLAG;
  107745. private static readonly DISABLE_DEACTIVATION_FLAG;
  107746. /**
  107747. * Initializes the ammoJS plugin
  107748. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107749. * @param ammoInjection can be used to inject your own ammo reference
  107750. */
  107751. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107752. /**
  107753. * Sets the gravity of the physics world (m/(s^2))
  107754. * @param gravity Gravity to set
  107755. */
  107756. setGravity(gravity: Vector3): void;
  107757. /**
  107758. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107759. * @param timeStep timestep to use in seconds
  107760. */
  107761. setTimeStep(timeStep: number): void;
  107762. /**
  107763. * 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)
  107764. * @param fixedTimeStep fixedTimeStep to use in seconds
  107765. */
  107766. setFixedTimeStep(fixedTimeStep: number): void;
  107767. /**
  107768. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107769. * @param maxSteps the maximum number of steps by the physics engine per frame
  107770. */
  107771. setMaxSteps(maxSteps: number): void;
  107772. /**
  107773. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107774. * @returns the current timestep in seconds
  107775. */
  107776. getTimeStep(): number;
  107777. private _isImpostorInContact;
  107778. private _isImpostorPairInContact;
  107779. private _stepSimulation;
  107780. /**
  107781. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107782. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107783. * After the step the babylon meshes are set to the position of the physics imposters
  107784. * @param delta amount of time to step forward
  107785. * @param impostors array of imposters to update before/after the step
  107786. */
  107787. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107788. private _tmpVector;
  107789. private _tmpMatrix;
  107790. /**
  107791. * Applies an implulse on the imposter
  107792. * @param impostor imposter to apply impulse
  107793. * @param force amount of force to be applied to the imposter
  107794. * @param contactPoint the location to apply the impulse on the imposter
  107795. */
  107796. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107797. /**
  107798. * Applies a force on the imposter
  107799. * @param impostor imposter to apply force
  107800. * @param force amount of force to be applied to the imposter
  107801. * @param contactPoint the location to apply the force on the imposter
  107802. */
  107803. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107804. /**
  107805. * Creates a physics body using the plugin
  107806. * @param impostor the imposter to create the physics body on
  107807. */
  107808. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107809. /**
  107810. * Removes the physics body from the imposter and disposes of the body's memory
  107811. * @param impostor imposter to remove the physics body from
  107812. */
  107813. removePhysicsBody(impostor: PhysicsImpostor): void;
  107814. /**
  107815. * Generates a joint
  107816. * @param impostorJoint the imposter joint to create the joint with
  107817. */
  107818. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107819. /**
  107820. * Removes a joint
  107821. * @param impostorJoint the imposter joint to remove the joint from
  107822. */
  107823. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107824. private _addMeshVerts;
  107825. private _createShape;
  107826. /**
  107827. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107828. * @param impostor imposter containing the physics body and babylon object
  107829. */
  107830. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107831. /**
  107832. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107833. * @param impostor imposter containing the physics body and babylon object
  107834. * @param newPosition new position
  107835. * @param newRotation new rotation
  107836. */
  107837. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107838. /**
  107839. * If this plugin is supported
  107840. * @returns true if its supported
  107841. */
  107842. isSupported(): boolean;
  107843. /**
  107844. * Sets the linear velocity of the physics body
  107845. * @param impostor imposter to set the velocity on
  107846. * @param velocity velocity to set
  107847. */
  107848. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107849. /**
  107850. * Sets the angular velocity of the physics body
  107851. * @param impostor imposter to set the velocity on
  107852. * @param velocity velocity to set
  107853. */
  107854. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107855. /**
  107856. * gets the linear velocity
  107857. * @param impostor imposter to get linear velocity from
  107858. * @returns linear velocity
  107859. */
  107860. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107861. /**
  107862. * gets the angular velocity
  107863. * @param impostor imposter to get angular velocity from
  107864. * @returns angular velocity
  107865. */
  107866. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107867. /**
  107868. * Sets the mass of physics body
  107869. * @param impostor imposter to set the mass on
  107870. * @param mass mass to set
  107871. */
  107872. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107873. /**
  107874. * Gets the mass of the physics body
  107875. * @param impostor imposter to get the mass from
  107876. * @returns mass
  107877. */
  107878. getBodyMass(impostor: PhysicsImpostor): number;
  107879. /**
  107880. * Gets friction of the impostor
  107881. * @param impostor impostor to get friction from
  107882. * @returns friction value
  107883. */
  107884. getBodyFriction(impostor: PhysicsImpostor): number;
  107885. /**
  107886. * Sets friction of the impostor
  107887. * @param impostor impostor to set friction on
  107888. * @param friction friction value
  107889. */
  107890. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107891. /**
  107892. * Gets restitution of the impostor
  107893. * @param impostor impostor to get restitution from
  107894. * @returns restitution value
  107895. */
  107896. getBodyRestitution(impostor: PhysicsImpostor): number;
  107897. /**
  107898. * Sets resitution of the impostor
  107899. * @param impostor impostor to set resitution on
  107900. * @param restitution resitution value
  107901. */
  107902. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107903. /**
  107904. * Sleeps the physics body and stops it from being active
  107905. * @param impostor impostor to sleep
  107906. */
  107907. sleepBody(impostor: PhysicsImpostor): void;
  107908. /**
  107909. * Activates the physics body
  107910. * @param impostor impostor to activate
  107911. */
  107912. wakeUpBody(impostor: PhysicsImpostor): void;
  107913. /**
  107914. * Updates the distance parameters of the joint
  107915. * @param joint joint to update
  107916. * @param maxDistance maximum distance of the joint
  107917. * @param minDistance minimum distance of the joint
  107918. */
  107919. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107920. /**
  107921. * Sets a motor on the joint
  107922. * @param joint joint to set motor on
  107923. * @param speed speed of the motor
  107924. * @param maxForce maximum force of the motor
  107925. * @param motorIndex index of the motor
  107926. */
  107927. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107928. /**
  107929. * Sets the motors limit
  107930. * @param joint joint to set limit on
  107931. * @param upperLimit upper limit
  107932. * @param lowerLimit lower limit
  107933. */
  107934. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107935. /**
  107936. * Syncs the position and rotation of a mesh with the impostor
  107937. * @param mesh mesh to sync
  107938. * @param impostor impostor to update the mesh with
  107939. */
  107940. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107941. /**
  107942. * Gets the radius of the impostor
  107943. * @param impostor impostor to get radius from
  107944. * @returns the radius
  107945. */
  107946. getRadius(impostor: PhysicsImpostor): number;
  107947. /**
  107948. * Gets the box size of the impostor
  107949. * @param impostor impostor to get box size from
  107950. * @param result the resulting box size
  107951. */
  107952. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107953. /**
  107954. * Disposes of the impostor
  107955. */
  107956. dispose(): void;
  107957. }
  107958. }
  107959. declare module BABYLON {
  107960. /** @hidden */
  107961. export var blackAndWhitePixelShader: {
  107962. name: string;
  107963. shader: string;
  107964. };
  107965. }
  107966. declare module BABYLON {
  107967. /**
  107968. * Post process used to render in black and white
  107969. */
  107970. export class BlackAndWhitePostProcess extends PostProcess {
  107971. /**
  107972. * Linear about to convert he result to black and white (default: 1)
  107973. */
  107974. degree: number;
  107975. /**
  107976. * Creates a black and white post process
  107977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  107978. * @param name The name of the effect.
  107979. * @param options The required width/height ratio to downsize to before computing the render pass.
  107980. * @param camera The camera to apply the render pass to.
  107981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107982. * @param engine The engine which the post process will be applied. (default: current engine)
  107983. * @param reusable If the post process can be reused on the same frame. (default: false)
  107984. */
  107985. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107986. }
  107987. }
  107988. declare module BABYLON {
  107989. /**
  107990. * This represents a set of one or more post processes in Babylon.
  107991. * A post process can be used to apply a shader to a texture after it is rendered.
  107992. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107993. */
  107994. export class PostProcessRenderEffect {
  107995. private _postProcesses;
  107996. private _getPostProcesses;
  107997. private _singleInstance;
  107998. private _cameras;
  107999. private _indicesForCamera;
  108000. /**
  108001. * Name of the effect
  108002. * @hidden
  108003. */
  108004. _name: string;
  108005. /**
  108006. * Instantiates a post process render effect.
  108007. * A post process can be used to apply a shader to a texture after it is rendered.
  108008. * @param engine The engine the effect is tied to
  108009. * @param name The name of the effect
  108010. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  108011. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  108012. */
  108013. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  108014. /**
  108015. * Checks if all the post processes in the effect are supported.
  108016. */
  108017. readonly isSupported: boolean;
  108018. /**
  108019. * Updates the current state of the effect
  108020. * @hidden
  108021. */
  108022. _update(): void;
  108023. /**
  108024. * Attaches the effect on cameras
  108025. * @param cameras The camera to attach to.
  108026. * @hidden
  108027. */
  108028. _attachCameras(cameras: Camera): void;
  108029. /**
  108030. * Attaches the effect on cameras
  108031. * @param cameras The camera to attach to.
  108032. * @hidden
  108033. */
  108034. _attachCameras(cameras: Camera[]): void;
  108035. /**
  108036. * Detatches the effect on cameras
  108037. * @param cameras The camera to detatch from.
  108038. * @hidden
  108039. */
  108040. _detachCameras(cameras: Camera): void;
  108041. /**
  108042. * Detatches the effect on cameras
  108043. * @param cameras The camera to detatch from.
  108044. * @hidden
  108045. */
  108046. _detachCameras(cameras: Camera[]): void;
  108047. /**
  108048. * Enables the effect on given cameras
  108049. * @param cameras The camera to enable.
  108050. * @hidden
  108051. */
  108052. _enable(cameras: Camera): void;
  108053. /**
  108054. * Enables the effect on given cameras
  108055. * @param cameras The camera to enable.
  108056. * @hidden
  108057. */
  108058. _enable(cameras: Nullable<Camera[]>): void;
  108059. /**
  108060. * Disables the effect on the given cameras
  108061. * @param cameras The camera to disable.
  108062. * @hidden
  108063. */
  108064. _disable(cameras: Camera): void;
  108065. /**
  108066. * Disables the effect on the given cameras
  108067. * @param cameras The camera to disable.
  108068. * @hidden
  108069. */
  108070. _disable(cameras: Nullable<Camera[]>): void;
  108071. /**
  108072. * Gets a list of the post processes contained in the effect.
  108073. * @param camera The camera to get the post processes on.
  108074. * @returns The list of the post processes in the effect.
  108075. */
  108076. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  108077. }
  108078. }
  108079. declare module BABYLON {
  108080. /** @hidden */
  108081. export var extractHighlightsPixelShader: {
  108082. name: string;
  108083. shader: string;
  108084. };
  108085. }
  108086. declare module BABYLON {
  108087. /**
  108088. * 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.
  108089. */
  108090. export class ExtractHighlightsPostProcess extends PostProcess {
  108091. /**
  108092. * The luminance threshold, pixels below this value will be set to black.
  108093. */
  108094. threshold: number;
  108095. /** @hidden */
  108096. _exposure: number;
  108097. /**
  108098. * Post process which has the input texture to be used when performing highlight extraction
  108099. * @hidden
  108100. */
  108101. _inputPostProcess: Nullable<PostProcess>;
  108102. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108103. }
  108104. }
  108105. declare module BABYLON {
  108106. /** @hidden */
  108107. export var bloomMergePixelShader: {
  108108. name: string;
  108109. shader: string;
  108110. };
  108111. }
  108112. declare module BABYLON {
  108113. /**
  108114. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108115. */
  108116. export class BloomMergePostProcess extends PostProcess {
  108117. /** Weight of the bloom to be added to the original input. */
  108118. weight: number;
  108119. /**
  108120. * Creates a new instance of @see BloomMergePostProcess
  108121. * @param name The name of the effect.
  108122. * @param originalFromInput Post process which's input will be used for the merge.
  108123. * @param blurred Blurred highlights post process which's output will be used.
  108124. * @param weight Weight of the bloom to be added to the original input.
  108125. * @param options The required width/height ratio to downsize to before computing the render pass.
  108126. * @param camera The camera to apply the render pass to.
  108127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108128. * @param engine The engine which the post process will be applied. (default: current engine)
  108129. * @param reusable If the post process can be reused on the same frame. (default: false)
  108130. * @param textureType Type of textures used when performing the post process. (default: 0)
  108131. * @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)
  108132. */
  108133. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  108134. /** Weight of the bloom to be added to the original input. */
  108135. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108136. }
  108137. }
  108138. declare module BABYLON {
  108139. /**
  108140. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  108141. */
  108142. export class BloomEffect extends PostProcessRenderEffect {
  108143. private bloomScale;
  108144. /**
  108145. * @hidden Internal
  108146. */
  108147. _effects: Array<PostProcess>;
  108148. /**
  108149. * @hidden Internal
  108150. */
  108151. _downscale: ExtractHighlightsPostProcess;
  108152. private _blurX;
  108153. private _blurY;
  108154. private _merge;
  108155. /**
  108156. * The luminance threshold to find bright areas of the image to bloom.
  108157. */
  108158. threshold: number;
  108159. /**
  108160. * The strength of the bloom.
  108161. */
  108162. weight: number;
  108163. /**
  108164. * Specifies the size of the bloom blur kernel, relative to the final output size
  108165. */
  108166. kernel: number;
  108167. /**
  108168. * Creates a new instance of @see BloomEffect
  108169. * @param scene The scene the effect belongs to.
  108170. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  108171. * @param bloomKernel The size of the kernel to be used when applying the blur.
  108172. * @param bloomWeight The the strength of bloom.
  108173. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108174. * @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)
  108175. */
  108176. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  108177. /**
  108178. * Disposes each of the internal effects for a given camera.
  108179. * @param camera The camera to dispose the effect on.
  108180. */
  108181. disposeEffects(camera: Camera): void;
  108182. /**
  108183. * @hidden Internal
  108184. */
  108185. _updateEffects(): void;
  108186. /**
  108187. * Internal
  108188. * @returns if all the contained post processes are ready.
  108189. * @hidden
  108190. */
  108191. _isReady(): boolean;
  108192. }
  108193. }
  108194. declare module BABYLON {
  108195. /** @hidden */
  108196. export var chromaticAberrationPixelShader: {
  108197. name: string;
  108198. shader: string;
  108199. };
  108200. }
  108201. declare module BABYLON {
  108202. /**
  108203. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  108204. */
  108205. export class ChromaticAberrationPostProcess extends PostProcess {
  108206. /**
  108207. * The amount of seperation of rgb channels (default: 30)
  108208. */
  108209. aberrationAmount: number;
  108210. /**
  108211. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  108212. */
  108213. radialIntensity: number;
  108214. /**
  108215. * 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))
  108216. */
  108217. direction: Vector2;
  108218. /**
  108219. * 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))
  108220. */
  108221. centerPosition: Vector2;
  108222. /**
  108223. * Creates a new instance ChromaticAberrationPostProcess
  108224. * @param name The name of the effect.
  108225. * @param screenWidth The width of the screen to apply the effect on.
  108226. * @param screenHeight The height of the screen to apply the effect on.
  108227. * @param options The required width/height ratio to downsize to before computing the render pass.
  108228. * @param camera The camera to apply the render pass to.
  108229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108230. * @param engine The engine which the post process will be applied. (default: current engine)
  108231. * @param reusable If the post process can be reused on the same frame. (default: false)
  108232. * @param textureType Type of textures used when performing the post process. (default: 0)
  108233. * @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)
  108234. */
  108235. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108236. }
  108237. }
  108238. declare module BABYLON {
  108239. /** @hidden */
  108240. export var circleOfConfusionPixelShader: {
  108241. name: string;
  108242. shader: string;
  108243. };
  108244. }
  108245. declare module BABYLON {
  108246. /**
  108247. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  108248. */
  108249. export class CircleOfConfusionPostProcess extends PostProcess {
  108250. /**
  108251. * 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.
  108252. */
  108253. lensSize: number;
  108254. /**
  108255. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108256. */
  108257. fStop: number;
  108258. /**
  108259. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108260. */
  108261. focusDistance: number;
  108262. /**
  108263. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  108264. */
  108265. focalLength: number;
  108266. private _depthTexture;
  108267. /**
  108268. * Creates a new instance CircleOfConfusionPostProcess
  108269. * @param name The name of the effect.
  108270. * @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.
  108271. * @param options The required width/height ratio to downsize to before computing the render pass.
  108272. * @param camera The camera to apply the render pass to.
  108273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108274. * @param engine The engine which the post process will be applied. (default: current engine)
  108275. * @param reusable If the post process can be reused on the same frame. (default: false)
  108276. * @param textureType Type of textures used when performing the post process. (default: 0)
  108277. * @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)
  108278. */
  108279. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108280. /**
  108281. * 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.
  108282. */
  108283. depthTexture: RenderTargetTexture;
  108284. }
  108285. }
  108286. declare module BABYLON {
  108287. /** @hidden */
  108288. export var colorCorrectionPixelShader: {
  108289. name: string;
  108290. shader: string;
  108291. };
  108292. }
  108293. declare module BABYLON {
  108294. /**
  108295. *
  108296. * This post-process allows the modification of rendered colors by using
  108297. * a 'look-up table' (LUT). This effect is also called Color Grading.
  108298. *
  108299. * The object needs to be provided an url to a texture containing the color
  108300. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  108301. * Use an image editing software to tweak the LUT to match your needs.
  108302. *
  108303. * For an example of a color LUT, see here:
  108304. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  108305. * For explanations on color grading, see here:
  108306. * @see http://udn.epicgames.com/Three/ColorGrading.html
  108307. *
  108308. */
  108309. export class ColorCorrectionPostProcess extends PostProcess {
  108310. private _colorTableTexture;
  108311. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108312. }
  108313. }
  108314. declare module BABYLON {
  108315. /** @hidden */
  108316. export var convolutionPixelShader: {
  108317. name: string;
  108318. shader: string;
  108319. };
  108320. }
  108321. declare module BABYLON {
  108322. /**
  108323. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  108324. * input texture to perform effects such as edge detection or sharpening
  108325. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108326. */
  108327. export class ConvolutionPostProcess extends PostProcess {
  108328. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108329. kernel: number[];
  108330. /**
  108331. * Creates a new instance ConvolutionPostProcess
  108332. * @param name The name of the effect.
  108333. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  108334. * @param options The required width/height ratio to downsize to before computing the render pass.
  108335. * @param camera The camera to apply the render pass to.
  108336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108337. * @param engine The engine which the post process will be applied. (default: current engine)
  108338. * @param reusable If the post process can be reused on the same frame. (default: false)
  108339. * @param textureType Type of textures used when performing the post process. (default: 0)
  108340. */
  108341. constructor(name: string,
  108342. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108343. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108344. /**
  108345. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108346. */
  108347. static EdgeDetect0Kernel: number[];
  108348. /**
  108349. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108350. */
  108351. static EdgeDetect1Kernel: number[];
  108352. /**
  108353. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108354. */
  108355. static EdgeDetect2Kernel: number[];
  108356. /**
  108357. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108358. */
  108359. static SharpenKernel: number[];
  108360. /**
  108361. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108362. */
  108363. static EmbossKernel: number[];
  108364. /**
  108365. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108366. */
  108367. static GaussianKernel: number[];
  108368. }
  108369. }
  108370. declare module BABYLON {
  108371. /**
  108372. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  108373. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  108374. * based on samples that have a large difference in distance than the center pixel.
  108375. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  108376. */
  108377. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  108378. direction: Vector2;
  108379. /**
  108380. * Creates a new instance CircleOfConfusionPostProcess
  108381. * @param name The name of the effect.
  108382. * @param scene The scene the effect belongs to.
  108383. * @param direction The direction the blur should be applied.
  108384. * @param kernel The size of the kernel used to blur.
  108385. * @param options The required width/height ratio to downsize to before computing the render pass.
  108386. * @param camera The camera to apply the render pass to.
  108387. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  108388. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  108389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108390. * @param engine The engine which the post process will be applied. (default: current engine)
  108391. * @param reusable If the post process can be reused on the same frame. (default: false)
  108392. * @param textureType Type of textures used when performing the post process. (default: 0)
  108393. * @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)
  108394. */
  108395. 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);
  108396. }
  108397. }
  108398. declare module BABYLON {
  108399. /** @hidden */
  108400. export var depthOfFieldMergePixelShader: {
  108401. name: string;
  108402. shader: string;
  108403. };
  108404. }
  108405. declare module BABYLON {
  108406. /**
  108407. * Options to be set when merging outputs from the default pipeline.
  108408. */
  108409. export class DepthOfFieldMergePostProcessOptions {
  108410. /**
  108411. * The original image to merge on top of
  108412. */
  108413. originalFromInput: PostProcess;
  108414. /**
  108415. * Parameters to perform the merge of the depth of field effect
  108416. */
  108417. depthOfField?: {
  108418. circleOfConfusion: PostProcess;
  108419. blurSteps: Array<PostProcess>;
  108420. };
  108421. /**
  108422. * Parameters to perform the merge of bloom effect
  108423. */
  108424. bloom?: {
  108425. blurred: PostProcess;
  108426. weight: number;
  108427. };
  108428. }
  108429. /**
  108430. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108431. */
  108432. export class DepthOfFieldMergePostProcess extends PostProcess {
  108433. private blurSteps;
  108434. /**
  108435. * Creates a new instance of DepthOfFieldMergePostProcess
  108436. * @param name The name of the effect.
  108437. * @param originalFromInput Post process which's input will be used for the merge.
  108438. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108439. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108440. * @param options The required width/height ratio to downsize to before computing the render pass.
  108441. * @param camera The camera to apply the render pass to.
  108442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108443. * @param engine The engine which the post process will be applied. (default: current engine)
  108444. * @param reusable If the post process can be reused on the same frame. (default: false)
  108445. * @param textureType Type of textures used when performing the post process. (default: 0)
  108446. * @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)
  108447. */
  108448. 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);
  108449. /**
  108450. * Updates the effect with the current post process compile time values and recompiles the shader.
  108451. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108452. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108453. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108454. * @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
  108455. * @param onCompiled Called when the shader has been compiled.
  108456. * @param onError Called if there is an error when compiling a shader.
  108457. */
  108458. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108459. }
  108460. }
  108461. declare module BABYLON {
  108462. /**
  108463. * Specifies the level of max blur that should be applied when using the depth of field effect
  108464. */
  108465. export enum DepthOfFieldEffectBlurLevel {
  108466. /**
  108467. * Subtle blur
  108468. */
  108469. Low = 0,
  108470. /**
  108471. * Medium blur
  108472. */
  108473. Medium = 1,
  108474. /**
  108475. * Large blur
  108476. */
  108477. High = 2
  108478. }
  108479. /**
  108480. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108481. */
  108482. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108483. private _circleOfConfusion;
  108484. /**
  108485. * @hidden Internal, blurs from high to low
  108486. */
  108487. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108488. private _depthOfFieldBlurY;
  108489. private _dofMerge;
  108490. /**
  108491. * @hidden Internal post processes in depth of field effect
  108492. */
  108493. _effects: Array<PostProcess>;
  108494. /**
  108495. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108496. */
  108497. focalLength: number;
  108498. /**
  108499. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108500. */
  108501. fStop: number;
  108502. /**
  108503. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108504. */
  108505. focusDistance: number;
  108506. /**
  108507. * 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.
  108508. */
  108509. lensSize: number;
  108510. /**
  108511. * Creates a new instance DepthOfFieldEffect
  108512. * @param scene The scene the effect belongs to.
  108513. * @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.
  108514. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108515. * @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)
  108516. */
  108517. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108518. /**
  108519. * 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.
  108520. */
  108521. depthTexture: RenderTargetTexture;
  108522. /**
  108523. * Disposes each of the internal effects for a given camera.
  108524. * @param camera The camera to dispose the effect on.
  108525. */
  108526. disposeEffects(camera: Camera): void;
  108527. /**
  108528. * @hidden Internal
  108529. */
  108530. _updateEffects(): void;
  108531. /**
  108532. * Internal
  108533. * @returns if all the contained post processes are ready.
  108534. * @hidden
  108535. */
  108536. _isReady(): boolean;
  108537. }
  108538. }
  108539. declare module BABYLON {
  108540. /** @hidden */
  108541. export var displayPassPixelShader: {
  108542. name: string;
  108543. shader: string;
  108544. };
  108545. }
  108546. declare module BABYLON {
  108547. /**
  108548. * DisplayPassPostProcess which produces an output the same as it's input
  108549. */
  108550. export class DisplayPassPostProcess extends PostProcess {
  108551. /**
  108552. * Creates the DisplayPassPostProcess
  108553. * @param name The name of the effect.
  108554. * @param options The required width/height ratio to downsize to before computing the render pass.
  108555. * @param camera The camera to apply the render pass to.
  108556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108557. * @param engine The engine which the post process will be applied. (default: current engine)
  108558. * @param reusable If the post process can be reused on the same frame. (default: false)
  108559. */
  108560. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108561. }
  108562. }
  108563. declare module BABYLON {
  108564. /** @hidden */
  108565. export var filterPixelShader: {
  108566. name: string;
  108567. shader: string;
  108568. };
  108569. }
  108570. declare module BABYLON {
  108571. /**
  108572. * Applies a kernel filter to the image
  108573. */
  108574. export class FilterPostProcess extends PostProcess {
  108575. /** The matrix to be applied to the image */
  108576. kernelMatrix: Matrix;
  108577. /**
  108578. *
  108579. * @param name The name of the effect.
  108580. * @param kernelMatrix The matrix to be applied to the image
  108581. * @param options The required width/height ratio to downsize to before computing the render pass.
  108582. * @param camera The camera to apply the render pass to.
  108583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108584. * @param engine The engine which the post process will be applied. (default: current engine)
  108585. * @param reusable If the post process can be reused on the same frame. (default: false)
  108586. */
  108587. constructor(name: string,
  108588. /** The matrix to be applied to the image */
  108589. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108590. }
  108591. }
  108592. declare module BABYLON {
  108593. /** @hidden */
  108594. export var fxaaPixelShader: {
  108595. name: string;
  108596. shader: string;
  108597. };
  108598. }
  108599. declare module BABYLON {
  108600. /** @hidden */
  108601. export var fxaaVertexShader: {
  108602. name: string;
  108603. shader: string;
  108604. };
  108605. }
  108606. declare module BABYLON {
  108607. /**
  108608. * Fxaa post process
  108609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108610. */
  108611. export class FxaaPostProcess extends PostProcess {
  108612. /** @hidden */
  108613. texelWidth: number;
  108614. /** @hidden */
  108615. texelHeight: number;
  108616. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108617. private _getDefines;
  108618. }
  108619. }
  108620. declare module BABYLON {
  108621. /** @hidden */
  108622. export var grainPixelShader: {
  108623. name: string;
  108624. shader: string;
  108625. };
  108626. }
  108627. declare module BABYLON {
  108628. /**
  108629. * The GrainPostProcess adds noise to the image at mid luminance levels
  108630. */
  108631. export class GrainPostProcess extends PostProcess {
  108632. /**
  108633. * The intensity of the grain added (default: 30)
  108634. */
  108635. intensity: number;
  108636. /**
  108637. * If the grain should be randomized on every frame
  108638. */
  108639. animated: boolean;
  108640. /**
  108641. * Creates a new instance of @see GrainPostProcess
  108642. * @param name The name of the effect.
  108643. * @param options The required width/height ratio to downsize to before computing the render pass.
  108644. * @param camera The camera to apply the render pass to.
  108645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108646. * @param engine The engine which the post process will be applied. (default: current engine)
  108647. * @param reusable If the post process can be reused on the same frame. (default: false)
  108648. * @param textureType Type of textures used when performing the post process. (default: 0)
  108649. * @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)
  108650. */
  108651. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108652. }
  108653. }
  108654. declare module BABYLON {
  108655. /** @hidden */
  108656. export var highlightsPixelShader: {
  108657. name: string;
  108658. shader: string;
  108659. };
  108660. }
  108661. declare module BABYLON {
  108662. /**
  108663. * Extracts highlights from the image
  108664. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108665. */
  108666. export class HighlightsPostProcess extends PostProcess {
  108667. /**
  108668. * Extracts highlights from the image
  108669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108670. * @param name The name of the effect.
  108671. * @param options The required width/height ratio to downsize to before computing the render pass.
  108672. * @param camera The camera to apply the render pass to.
  108673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108674. * @param engine The engine which the post process will be applied. (default: current engine)
  108675. * @param reusable If the post process can be reused on the same frame. (default: false)
  108676. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108677. */
  108678. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108679. }
  108680. }
  108681. declare module BABYLON {
  108682. /** @hidden */
  108683. export var mrtFragmentDeclaration: {
  108684. name: string;
  108685. shader: string;
  108686. };
  108687. }
  108688. declare module BABYLON {
  108689. /** @hidden */
  108690. export var geometryPixelShader: {
  108691. name: string;
  108692. shader: string;
  108693. };
  108694. }
  108695. declare module BABYLON {
  108696. /** @hidden */
  108697. export var geometryVertexShader: {
  108698. name: string;
  108699. shader: string;
  108700. };
  108701. }
  108702. declare module BABYLON {
  108703. /**
  108704. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108705. */
  108706. export class GeometryBufferRenderer {
  108707. /**
  108708. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108709. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108710. */
  108711. static readonly POSITION_TEXTURE_TYPE: number;
  108712. /**
  108713. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108714. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108715. */
  108716. static readonly VELOCITY_TEXTURE_TYPE: number;
  108717. /**
  108718. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108719. * in order to compute objects velocities when enableVelocity is set to "true"
  108720. * @hidden
  108721. */
  108722. _previousTransformationMatrices: {
  108723. [index: number]: Matrix;
  108724. };
  108725. private _scene;
  108726. private _multiRenderTarget;
  108727. private _ratio;
  108728. private _enablePosition;
  108729. private _enableVelocity;
  108730. private _positionIndex;
  108731. private _velocityIndex;
  108732. protected _effect: Effect;
  108733. protected _cachedDefines: string;
  108734. /**
  108735. * Set the render list (meshes to be rendered) used in the G buffer.
  108736. */
  108737. renderList: Mesh[];
  108738. /**
  108739. * Gets wether or not G buffer are supported by the running hardware.
  108740. * This requires draw buffer supports
  108741. */
  108742. readonly isSupported: boolean;
  108743. /**
  108744. * Returns the index of the given texture type in the G-Buffer textures array
  108745. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108746. * @returns the index of the given texture type in the G-Buffer textures array
  108747. */
  108748. getTextureIndex(textureType: number): number;
  108749. /**
  108750. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108751. */
  108752. /**
  108753. * Sets whether or not objects positions are enabled for the G buffer.
  108754. */
  108755. enablePosition: boolean;
  108756. /**
  108757. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108758. */
  108759. /**
  108760. * Sets wether or not objects velocities are enabled for the G buffer.
  108761. */
  108762. enableVelocity: boolean;
  108763. /**
  108764. * Gets the scene associated with the buffer.
  108765. */
  108766. readonly scene: Scene;
  108767. /**
  108768. * Gets the ratio used by the buffer during its creation.
  108769. * How big is the buffer related to the main canvas.
  108770. */
  108771. readonly ratio: number;
  108772. /** @hidden */
  108773. static _SceneComponentInitialization: (scene: Scene) => void;
  108774. /**
  108775. * Creates a new G Buffer for the scene
  108776. * @param scene The scene the buffer belongs to
  108777. * @param ratio How big is the buffer related to the main canvas.
  108778. */
  108779. constructor(scene: Scene, ratio?: number);
  108780. /**
  108781. * Checks wether everything is ready to render a submesh to the G buffer.
  108782. * @param subMesh the submesh to check readiness for
  108783. * @param useInstances is the mesh drawn using instance or not
  108784. * @returns true if ready otherwise false
  108785. */
  108786. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108787. /**
  108788. * Gets the current underlying G Buffer.
  108789. * @returns the buffer
  108790. */
  108791. getGBuffer(): MultiRenderTarget;
  108792. /**
  108793. * Gets the number of samples used to render the buffer (anti aliasing).
  108794. */
  108795. /**
  108796. * Sets the number of samples used to render the buffer (anti aliasing).
  108797. */
  108798. samples: number;
  108799. /**
  108800. * Disposes the renderer and frees up associated resources.
  108801. */
  108802. dispose(): void;
  108803. protected _createRenderTargets(): void;
  108804. }
  108805. }
  108806. declare module BABYLON {
  108807. interface Scene {
  108808. /** @hidden (Backing field) */
  108809. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108810. /**
  108811. * Gets or Sets the current geometry buffer associated to the scene.
  108812. */
  108813. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108814. /**
  108815. * Enables a GeometryBufferRender and associates it with the scene
  108816. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108817. * @returns the GeometryBufferRenderer
  108818. */
  108819. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108820. /**
  108821. * Disables the GeometryBufferRender associated with the scene
  108822. */
  108823. disableGeometryBufferRenderer(): void;
  108824. }
  108825. /**
  108826. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108827. * in several rendering techniques.
  108828. */
  108829. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108830. /**
  108831. * The component name helpful to identify the component in the list of scene components.
  108832. */
  108833. readonly name: string;
  108834. /**
  108835. * The scene the component belongs to.
  108836. */
  108837. scene: Scene;
  108838. /**
  108839. * Creates a new instance of the component for the given scene
  108840. * @param scene Defines the scene to register the component in
  108841. */
  108842. constructor(scene: Scene);
  108843. /**
  108844. * Registers the component in a given scene
  108845. */
  108846. register(): void;
  108847. /**
  108848. * Rebuilds the elements related to this component in case of
  108849. * context lost for instance.
  108850. */
  108851. rebuild(): void;
  108852. /**
  108853. * Disposes the component and the associated ressources
  108854. */
  108855. dispose(): void;
  108856. private _gatherRenderTargets;
  108857. }
  108858. }
  108859. declare module BABYLON {
  108860. /** @hidden */
  108861. export var motionBlurPixelShader: {
  108862. name: string;
  108863. shader: string;
  108864. };
  108865. }
  108866. declare module BABYLON {
  108867. /**
  108868. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108869. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108870. * As an example, all you have to do is to create the post-process:
  108871. * var mb = new BABYLON.MotionBlurPostProcess(
  108872. * 'mb', // The name of the effect.
  108873. * scene, // The scene containing the objects to blur according to their velocity.
  108874. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108875. * camera // The camera to apply the render pass to.
  108876. * );
  108877. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108878. */
  108879. export class MotionBlurPostProcess extends PostProcess {
  108880. /**
  108881. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108882. */
  108883. motionStrength: number;
  108884. /**
  108885. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108886. */
  108887. /**
  108888. * Sets the number of iterations to be used for motion blur quality
  108889. */
  108890. motionBlurSamples: number;
  108891. private _motionBlurSamples;
  108892. private _geometryBufferRenderer;
  108893. /**
  108894. * Creates a new instance MotionBlurPostProcess
  108895. * @param name The name of the effect.
  108896. * @param scene The scene containing the objects to blur according to their velocity.
  108897. * @param options The required width/height ratio to downsize to before computing the render pass.
  108898. * @param camera The camera to apply the render pass to.
  108899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108900. * @param engine The engine which the post process will be applied. (default: current engine)
  108901. * @param reusable If the post process can be reused on the same frame. (default: false)
  108902. * @param textureType Type of textures used when performing the post process. (default: 0)
  108903. * @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)
  108904. */
  108905. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108906. /**
  108907. * Disposes the post process.
  108908. * @param camera The camera to dispose the post process on.
  108909. */
  108910. dispose(camera?: Camera): void;
  108911. }
  108912. }
  108913. declare module BABYLON {
  108914. /** @hidden */
  108915. export var refractionPixelShader: {
  108916. name: string;
  108917. shader: string;
  108918. };
  108919. }
  108920. declare module BABYLON {
  108921. /**
  108922. * Post process which applies a refractin texture
  108923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108924. */
  108925. export class RefractionPostProcess extends PostProcess {
  108926. /** the base color of the refraction (used to taint the rendering) */
  108927. color: Color3;
  108928. /** simulated refraction depth */
  108929. depth: number;
  108930. /** the coefficient of the base color (0 to remove base color tainting) */
  108931. colorLevel: number;
  108932. private _refTexture;
  108933. private _ownRefractionTexture;
  108934. /**
  108935. * Gets or sets the refraction texture
  108936. * Please note that you are responsible for disposing the texture if you set it manually
  108937. */
  108938. refractionTexture: Texture;
  108939. /**
  108940. * Initializes the RefractionPostProcess
  108941. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108942. * @param name The name of the effect.
  108943. * @param refractionTextureUrl Url of the refraction texture to use
  108944. * @param color the base color of the refraction (used to taint the rendering)
  108945. * @param depth simulated refraction depth
  108946. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  108947. * @param camera The camera to apply the render pass to.
  108948. * @param options The required width/height ratio to downsize to before computing the render pass.
  108949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108950. * @param engine The engine which the post process will be applied. (default: current engine)
  108951. * @param reusable If the post process can be reused on the same frame. (default: false)
  108952. */
  108953. constructor(name: string, refractionTextureUrl: string,
  108954. /** the base color of the refraction (used to taint the rendering) */
  108955. color: Color3,
  108956. /** simulated refraction depth */
  108957. depth: number,
  108958. /** the coefficient of the base color (0 to remove base color tainting) */
  108959. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108960. /**
  108961. * Disposes of the post process
  108962. * @param camera Camera to dispose post process on
  108963. */
  108964. dispose(camera: Camera): void;
  108965. }
  108966. }
  108967. declare module BABYLON {
  108968. /** @hidden */
  108969. export var sharpenPixelShader: {
  108970. name: string;
  108971. shader: string;
  108972. };
  108973. }
  108974. declare module BABYLON {
  108975. /**
  108976. * The SharpenPostProcess applies a sharpen kernel to every pixel
  108977. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108978. */
  108979. export class SharpenPostProcess extends PostProcess {
  108980. /**
  108981. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  108982. */
  108983. colorAmount: number;
  108984. /**
  108985. * How much sharpness should be applied (default: 0.3)
  108986. */
  108987. edgeAmount: number;
  108988. /**
  108989. * Creates a new instance ConvolutionPostProcess
  108990. * @param name The name of the effect.
  108991. * @param options The required width/height ratio to downsize to before computing the render pass.
  108992. * @param camera The camera to apply the render pass to.
  108993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108994. * @param engine The engine which the post process will be applied. (default: current engine)
  108995. * @param reusable If the post process can be reused on the same frame. (default: false)
  108996. * @param textureType Type of textures used when performing the post process. (default: 0)
  108997. * @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)
  108998. */
  108999. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109000. }
  109001. }
  109002. declare module BABYLON {
  109003. /**
  109004. * PostProcessRenderPipeline
  109005. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109006. */
  109007. export class PostProcessRenderPipeline {
  109008. private engine;
  109009. private _renderEffects;
  109010. private _renderEffectsForIsolatedPass;
  109011. /**
  109012. * @hidden
  109013. */
  109014. protected _cameras: Camera[];
  109015. /** @hidden */
  109016. _name: string;
  109017. /**
  109018. * Gets pipeline name
  109019. */
  109020. readonly name: string;
  109021. /**
  109022. * Initializes a PostProcessRenderPipeline
  109023. * @param engine engine to add the pipeline to
  109024. * @param name name of the pipeline
  109025. */
  109026. constructor(engine: Engine, name: string);
  109027. /**
  109028. * Gets the class name
  109029. * @returns "PostProcessRenderPipeline"
  109030. */
  109031. getClassName(): string;
  109032. /**
  109033. * If all the render effects in the pipeline are supported
  109034. */
  109035. readonly isSupported: boolean;
  109036. /**
  109037. * Adds an effect to the pipeline
  109038. * @param renderEffect the effect to add
  109039. */
  109040. addEffect(renderEffect: PostProcessRenderEffect): void;
  109041. /** @hidden */
  109042. _rebuild(): void;
  109043. /** @hidden */
  109044. _enableEffect(renderEffectName: string, cameras: Camera): void;
  109045. /** @hidden */
  109046. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  109047. /** @hidden */
  109048. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109049. /** @hidden */
  109050. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109051. /** @hidden */
  109052. _attachCameras(cameras: Camera, unique: boolean): void;
  109053. /** @hidden */
  109054. _attachCameras(cameras: Camera[], unique: boolean): void;
  109055. /** @hidden */
  109056. _detachCameras(cameras: Camera): void;
  109057. /** @hidden */
  109058. _detachCameras(cameras: Nullable<Camera[]>): void;
  109059. /** @hidden */
  109060. _update(): void;
  109061. /** @hidden */
  109062. _reset(): void;
  109063. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  109064. /**
  109065. * Disposes of the pipeline
  109066. */
  109067. dispose(): void;
  109068. }
  109069. }
  109070. declare module BABYLON {
  109071. /**
  109072. * PostProcessRenderPipelineManager class
  109073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109074. */
  109075. export class PostProcessRenderPipelineManager {
  109076. private _renderPipelines;
  109077. /**
  109078. * Initializes a PostProcessRenderPipelineManager
  109079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109080. */
  109081. constructor();
  109082. /**
  109083. * Gets the list of supported render pipelines
  109084. */
  109085. readonly supportedPipelines: PostProcessRenderPipeline[];
  109086. /**
  109087. * Adds a pipeline to the manager
  109088. * @param renderPipeline The pipeline to add
  109089. */
  109090. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109091. /**
  109092. * Attaches a camera to the pipeline
  109093. * @param renderPipelineName The name of the pipeline to attach to
  109094. * @param cameras the camera to attach
  109095. * @param unique if the camera can be attached multiple times to the pipeline
  109096. */
  109097. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109098. /**
  109099. * Detaches a camera from the pipeline
  109100. * @param renderPipelineName The name of the pipeline to detach from
  109101. * @param cameras the camera to detach
  109102. */
  109103. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109104. /**
  109105. * Enables an effect by name on a pipeline
  109106. * @param renderPipelineName the name of the pipeline to enable the effect in
  109107. * @param renderEffectName the name of the effect to enable
  109108. * @param cameras the cameras that the effect should be enabled on
  109109. */
  109110. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109111. /**
  109112. * Disables an effect by name on a pipeline
  109113. * @param renderPipelineName the name of the pipeline to disable the effect in
  109114. * @param renderEffectName the name of the effect to disable
  109115. * @param cameras the cameras that the effect should be disabled on
  109116. */
  109117. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109118. /**
  109119. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109120. */
  109121. update(): void;
  109122. /** @hidden */
  109123. _rebuild(): void;
  109124. /**
  109125. * Disposes of the manager and pipelines
  109126. */
  109127. dispose(): void;
  109128. }
  109129. }
  109130. declare module BABYLON {
  109131. interface Scene {
  109132. /** @hidden (Backing field) */
  109133. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109134. /**
  109135. * Gets the postprocess render pipeline manager
  109136. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109137. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109138. */
  109139. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109140. }
  109141. /**
  109142. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109143. */
  109144. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109145. /**
  109146. * The component name helpfull to identify the component in the list of scene components.
  109147. */
  109148. readonly name: string;
  109149. /**
  109150. * The scene the component belongs to.
  109151. */
  109152. scene: Scene;
  109153. /**
  109154. * Creates a new instance of the component for the given scene
  109155. * @param scene Defines the scene to register the component in
  109156. */
  109157. constructor(scene: Scene);
  109158. /**
  109159. * Registers the component in a given scene
  109160. */
  109161. register(): void;
  109162. /**
  109163. * Rebuilds the elements related to this component in case of
  109164. * context lost for instance.
  109165. */
  109166. rebuild(): void;
  109167. /**
  109168. * Disposes the component and the associated ressources
  109169. */
  109170. dispose(): void;
  109171. private _gatherRenderTargets;
  109172. }
  109173. }
  109174. declare module BABYLON {
  109175. /**
  109176. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  109177. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109178. */
  109179. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109180. private _scene;
  109181. private _camerasToBeAttached;
  109182. /**
  109183. * ID of the sharpen post process,
  109184. */
  109185. private readonly SharpenPostProcessId;
  109186. /**
  109187. * @ignore
  109188. * ID of the image processing post process;
  109189. */
  109190. readonly ImageProcessingPostProcessId: string;
  109191. /**
  109192. * @ignore
  109193. * ID of the Fast Approximate Anti-Aliasing post process;
  109194. */
  109195. readonly FxaaPostProcessId: string;
  109196. /**
  109197. * ID of the chromatic aberration post process,
  109198. */
  109199. private readonly ChromaticAberrationPostProcessId;
  109200. /**
  109201. * ID of the grain post process
  109202. */
  109203. private readonly GrainPostProcessId;
  109204. /**
  109205. * Sharpen post process which will apply a sharpen convolution to enhance edges
  109206. */
  109207. sharpen: SharpenPostProcess;
  109208. private _sharpenEffect;
  109209. private bloom;
  109210. /**
  109211. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  109212. */
  109213. depthOfField: DepthOfFieldEffect;
  109214. /**
  109215. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109216. */
  109217. fxaa: FxaaPostProcess;
  109218. /**
  109219. * Image post processing pass used to perform operations such as tone mapping or color grading.
  109220. */
  109221. imageProcessing: ImageProcessingPostProcess;
  109222. /**
  109223. * Chromatic aberration post process which will shift rgb colors in the image
  109224. */
  109225. chromaticAberration: ChromaticAberrationPostProcess;
  109226. private _chromaticAberrationEffect;
  109227. /**
  109228. * Grain post process which add noise to the image
  109229. */
  109230. grain: GrainPostProcess;
  109231. private _grainEffect;
  109232. /**
  109233. * Glow post process which adds a glow to emissive areas of the image
  109234. */
  109235. private _glowLayer;
  109236. /**
  109237. * Animations which can be used to tweak settings over a period of time
  109238. */
  109239. animations: Animation[];
  109240. private _imageProcessingConfigurationObserver;
  109241. private _sharpenEnabled;
  109242. private _bloomEnabled;
  109243. private _depthOfFieldEnabled;
  109244. private _depthOfFieldBlurLevel;
  109245. private _fxaaEnabled;
  109246. private _imageProcessingEnabled;
  109247. private _defaultPipelineTextureType;
  109248. private _bloomScale;
  109249. private _chromaticAberrationEnabled;
  109250. private _grainEnabled;
  109251. private _buildAllowed;
  109252. /**
  109253. * Gets active scene
  109254. */
  109255. readonly scene: Scene;
  109256. /**
  109257. * Enable or disable the sharpen process from the pipeline
  109258. */
  109259. sharpenEnabled: boolean;
  109260. private _resizeObserver;
  109261. private _hardwareScaleLevel;
  109262. private _bloomKernel;
  109263. /**
  109264. * Specifies the size of the bloom blur kernel, relative to the final output size
  109265. */
  109266. bloomKernel: number;
  109267. /**
  109268. * Specifies the weight of the bloom in the final rendering
  109269. */
  109270. private _bloomWeight;
  109271. /**
  109272. * Specifies the luma threshold for the area that will be blurred by the bloom
  109273. */
  109274. private _bloomThreshold;
  109275. private _hdr;
  109276. /**
  109277. * The strength of the bloom.
  109278. */
  109279. bloomWeight: number;
  109280. /**
  109281. * The strength of the bloom.
  109282. */
  109283. bloomThreshold: number;
  109284. /**
  109285. * The scale of the bloom, lower value will provide better performance.
  109286. */
  109287. bloomScale: number;
  109288. /**
  109289. * Enable or disable the bloom from the pipeline
  109290. */
  109291. bloomEnabled: boolean;
  109292. private _rebuildBloom;
  109293. /**
  109294. * If the depth of field is enabled.
  109295. */
  109296. depthOfFieldEnabled: boolean;
  109297. /**
  109298. * Blur level of the depth of field effect. (Higher blur will effect performance)
  109299. */
  109300. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  109301. /**
  109302. * If the anti aliasing is enabled.
  109303. */
  109304. fxaaEnabled: boolean;
  109305. private _samples;
  109306. /**
  109307. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109308. */
  109309. samples: number;
  109310. /**
  109311. * If image processing is enabled.
  109312. */
  109313. imageProcessingEnabled: boolean;
  109314. /**
  109315. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  109316. */
  109317. glowLayerEnabled: boolean;
  109318. /**
  109319. * Enable or disable the chromaticAberration process from the pipeline
  109320. */
  109321. chromaticAberrationEnabled: boolean;
  109322. /**
  109323. * Enable or disable the grain process from the pipeline
  109324. */
  109325. grainEnabled: boolean;
  109326. /**
  109327. * @constructor
  109328. * @param name - The rendering pipeline name (default: "")
  109329. * @param hdr - If high dynamic range textures should be used (default: true)
  109330. * @param scene - The scene linked to this pipeline (default: the last created scene)
  109331. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  109332. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  109333. */
  109334. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  109335. /**
  109336. * Get the class name
  109337. * @returns "DefaultRenderingPipeline"
  109338. */
  109339. getClassName(): string;
  109340. /**
  109341. * Force the compilation of the entire pipeline.
  109342. */
  109343. prepare(): void;
  109344. private _hasCleared;
  109345. private _prevPostProcess;
  109346. private _prevPrevPostProcess;
  109347. private _setAutoClearAndTextureSharing;
  109348. private _depthOfFieldSceneObserver;
  109349. private _buildPipeline;
  109350. private _disposePostProcesses;
  109351. /**
  109352. * Adds a camera to the pipeline
  109353. * @param camera the camera to be added
  109354. */
  109355. addCamera(camera: Camera): void;
  109356. /**
  109357. * Removes a camera from the pipeline
  109358. * @param camera the camera to remove
  109359. */
  109360. removeCamera(camera: Camera): void;
  109361. /**
  109362. * Dispose of the pipeline and stop all post processes
  109363. */
  109364. dispose(): void;
  109365. /**
  109366. * Serialize the rendering pipeline (Used when exporting)
  109367. * @returns the serialized object
  109368. */
  109369. serialize(): any;
  109370. /**
  109371. * Parse the serialized pipeline
  109372. * @param source Source pipeline.
  109373. * @param scene The scene to load the pipeline to.
  109374. * @param rootUrl The URL of the serialized pipeline.
  109375. * @returns An instantiated pipeline from the serialized object.
  109376. */
  109377. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  109378. }
  109379. }
  109380. declare module BABYLON {
  109381. /** @hidden */
  109382. export var lensHighlightsPixelShader: {
  109383. name: string;
  109384. shader: string;
  109385. };
  109386. }
  109387. declare module BABYLON {
  109388. /** @hidden */
  109389. export var depthOfFieldPixelShader: {
  109390. name: string;
  109391. shader: string;
  109392. };
  109393. }
  109394. declare module BABYLON {
  109395. /**
  109396. * BABYLON.JS Chromatic Aberration GLSL Shader
  109397. * Author: Olivier Guyot
  109398. * Separates very slightly R, G and B colors on the edges of the screen
  109399. * Inspired by Francois Tarlier & Martins Upitis
  109400. */
  109401. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  109402. /**
  109403. * @ignore
  109404. * The chromatic aberration PostProcess id in the pipeline
  109405. */
  109406. LensChromaticAberrationEffect: string;
  109407. /**
  109408. * @ignore
  109409. * The highlights enhancing PostProcess id in the pipeline
  109410. */
  109411. HighlightsEnhancingEffect: string;
  109412. /**
  109413. * @ignore
  109414. * The depth-of-field PostProcess id in the pipeline
  109415. */
  109416. LensDepthOfFieldEffect: string;
  109417. private _scene;
  109418. private _depthTexture;
  109419. private _grainTexture;
  109420. private _chromaticAberrationPostProcess;
  109421. private _highlightsPostProcess;
  109422. private _depthOfFieldPostProcess;
  109423. private _edgeBlur;
  109424. private _grainAmount;
  109425. private _chromaticAberration;
  109426. private _distortion;
  109427. private _highlightsGain;
  109428. private _highlightsThreshold;
  109429. private _dofDistance;
  109430. private _dofAperture;
  109431. private _dofDarken;
  109432. private _dofPentagon;
  109433. private _blurNoise;
  109434. /**
  109435. * @constructor
  109436. *
  109437. * Effect parameters are as follow:
  109438. * {
  109439. * chromatic_aberration: number; // from 0 to x (1 for realism)
  109440. * edge_blur: number; // from 0 to x (1 for realism)
  109441. * distortion: number; // from 0 to x (1 for realism)
  109442. * grain_amount: number; // from 0 to 1
  109443. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  109444. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  109445. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  109446. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  109447. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  109448. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  109449. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  109450. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  109451. * }
  109452. * Note: if an effect parameter is unset, effect is disabled
  109453. *
  109454. * @param name The rendering pipeline name
  109455. * @param parameters - An object containing all parameters (see above)
  109456. * @param scene The scene linked to this pipeline
  109457. * @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)
  109458. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109459. */
  109460. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  109461. /**
  109462. * Sets the amount of blur at the edges
  109463. * @param amount blur amount
  109464. */
  109465. setEdgeBlur(amount: number): void;
  109466. /**
  109467. * Sets edge blur to 0
  109468. */
  109469. disableEdgeBlur(): void;
  109470. /**
  109471. * Sets the amout of grain
  109472. * @param amount Amount of grain
  109473. */
  109474. setGrainAmount(amount: number): void;
  109475. /**
  109476. * Set grain amount to 0
  109477. */
  109478. disableGrain(): void;
  109479. /**
  109480. * Sets the chromatic aberration amount
  109481. * @param amount amount of chromatic aberration
  109482. */
  109483. setChromaticAberration(amount: number): void;
  109484. /**
  109485. * Sets chromatic aberration amount to 0
  109486. */
  109487. disableChromaticAberration(): void;
  109488. /**
  109489. * Sets the EdgeDistortion amount
  109490. * @param amount amount of EdgeDistortion
  109491. */
  109492. setEdgeDistortion(amount: number): void;
  109493. /**
  109494. * Sets edge distortion to 0
  109495. */
  109496. disableEdgeDistortion(): void;
  109497. /**
  109498. * Sets the FocusDistance amount
  109499. * @param amount amount of FocusDistance
  109500. */
  109501. setFocusDistance(amount: number): void;
  109502. /**
  109503. * Disables depth of field
  109504. */
  109505. disableDepthOfField(): void;
  109506. /**
  109507. * Sets the Aperture amount
  109508. * @param amount amount of Aperture
  109509. */
  109510. setAperture(amount: number): void;
  109511. /**
  109512. * Sets the DarkenOutOfFocus amount
  109513. * @param amount amount of DarkenOutOfFocus
  109514. */
  109515. setDarkenOutOfFocus(amount: number): void;
  109516. /**
  109517. * Creates a pentagon bokeh effect
  109518. */
  109519. enablePentagonBokeh(): void;
  109520. /**
  109521. * Disables the pentagon bokeh effect
  109522. */
  109523. disablePentagonBokeh(): void;
  109524. /**
  109525. * Enables noise blur
  109526. */
  109527. enableNoiseBlur(): void;
  109528. /**
  109529. * Disables noise blur
  109530. */
  109531. disableNoiseBlur(): void;
  109532. /**
  109533. * Sets the HighlightsGain amount
  109534. * @param amount amount of HighlightsGain
  109535. */
  109536. setHighlightsGain(amount: number): void;
  109537. /**
  109538. * Sets the HighlightsThreshold amount
  109539. * @param amount amount of HighlightsThreshold
  109540. */
  109541. setHighlightsThreshold(amount: number): void;
  109542. /**
  109543. * Disables highlights
  109544. */
  109545. disableHighlights(): void;
  109546. /**
  109547. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  109548. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  109549. */
  109550. dispose(disableDepthRender?: boolean): void;
  109551. private _createChromaticAberrationPostProcess;
  109552. private _createHighlightsPostProcess;
  109553. private _createDepthOfFieldPostProcess;
  109554. private _createGrainTexture;
  109555. }
  109556. }
  109557. declare module BABYLON {
  109558. /** @hidden */
  109559. export var ssao2PixelShader: {
  109560. name: string;
  109561. shader: string;
  109562. };
  109563. }
  109564. declare module BABYLON {
  109565. /** @hidden */
  109566. export var ssaoCombinePixelShader: {
  109567. name: string;
  109568. shader: string;
  109569. };
  109570. }
  109571. declare module BABYLON {
  109572. /**
  109573. * Render pipeline to produce ssao effect
  109574. */
  109575. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  109576. /**
  109577. * @ignore
  109578. * The PassPostProcess id in the pipeline that contains the original scene color
  109579. */
  109580. SSAOOriginalSceneColorEffect: string;
  109581. /**
  109582. * @ignore
  109583. * The SSAO PostProcess id in the pipeline
  109584. */
  109585. SSAORenderEffect: string;
  109586. /**
  109587. * @ignore
  109588. * The horizontal blur PostProcess id in the pipeline
  109589. */
  109590. SSAOBlurHRenderEffect: string;
  109591. /**
  109592. * @ignore
  109593. * The vertical blur PostProcess id in the pipeline
  109594. */
  109595. SSAOBlurVRenderEffect: string;
  109596. /**
  109597. * @ignore
  109598. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109599. */
  109600. SSAOCombineRenderEffect: string;
  109601. /**
  109602. * The output strength of the SSAO post-process. Default value is 1.0.
  109603. */
  109604. totalStrength: number;
  109605. /**
  109606. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  109607. */
  109608. maxZ: number;
  109609. /**
  109610. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  109611. */
  109612. minZAspect: number;
  109613. private _samples;
  109614. /**
  109615. * Number of samples used for the SSAO calculations. Default value is 8
  109616. */
  109617. samples: number;
  109618. private _textureSamples;
  109619. /**
  109620. * Number of samples to use for antialiasing
  109621. */
  109622. textureSamples: number;
  109623. /**
  109624. * Ratio object used for SSAO ratio and blur ratio
  109625. */
  109626. private _ratio;
  109627. /**
  109628. * Dynamically generated sphere sampler.
  109629. */
  109630. private _sampleSphere;
  109631. /**
  109632. * Blur filter offsets
  109633. */
  109634. private _samplerOffsets;
  109635. private _expensiveBlur;
  109636. /**
  109637. * If bilateral blur should be used
  109638. */
  109639. expensiveBlur: boolean;
  109640. /**
  109641. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109642. */
  109643. radius: number;
  109644. /**
  109645. * The base color of the SSAO post-process
  109646. * The final result is "base + ssao" between [0, 1]
  109647. */
  109648. base: number;
  109649. /**
  109650. * Support test.
  109651. */
  109652. static readonly IsSupported: boolean;
  109653. private _scene;
  109654. private _depthTexture;
  109655. private _normalTexture;
  109656. private _randomTexture;
  109657. private _originalColorPostProcess;
  109658. private _ssaoPostProcess;
  109659. private _blurHPostProcess;
  109660. private _blurVPostProcess;
  109661. private _ssaoCombinePostProcess;
  109662. private _firstUpdate;
  109663. /**
  109664. * Gets active scene
  109665. */
  109666. readonly scene: Scene;
  109667. /**
  109668. * @constructor
  109669. * @param name The rendering pipeline name
  109670. * @param scene The scene linked to this pipeline
  109671. * @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 }
  109672. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109673. */
  109674. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109675. /**
  109676. * Get the class name
  109677. * @returns "SSAO2RenderingPipeline"
  109678. */
  109679. getClassName(): string;
  109680. /**
  109681. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109682. */
  109683. dispose(disableGeometryBufferRenderer?: boolean): void;
  109684. private _createBlurPostProcess;
  109685. /** @hidden */
  109686. _rebuild(): void;
  109687. private _bits;
  109688. private _radicalInverse_VdC;
  109689. private _hammersley;
  109690. private _hemisphereSample_uniform;
  109691. private _generateHemisphere;
  109692. private _createSSAOPostProcess;
  109693. private _createSSAOCombinePostProcess;
  109694. private _createRandomTexture;
  109695. /**
  109696. * Serialize the rendering pipeline (Used when exporting)
  109697. * @returns the serialized object
  109698. */
  109699. serialize(): any;
  109700. /**
  109701. * Parse the serialized pipeline
  109702. * @param source Source pipeline.
  109703. * @param scene The scene to load the pipeline to.
  109704. * @param rootUrl The URL of the serialized pipeline.
  109705. * @returns An instantiated pipeline from the serialized object.
  109706. */
  109707. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109708. }
  109709. }
  109710. declare module BABYLON {
  109711. /** @hidden */
  109712. export var ssaoPixelShader: {
  109713. name: string;
  109714. shader: string;
  109715. };
  109716. }
  109717. declare module BABYLON {
  109718. /**
  109719. * Render pipeline to produce ssao effect
  109720. */
  109721. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109722. /**
  109723. * @ignore
  109724. * The PassPostProcess id in the pipeline that contains the original scene color
  109725. */
  109726. SSAOOriginalSceneColorEffect: string;
  109727. /**
  109728. * @ignore
  109729. * The SSAO PostProcess id in the pipeline
  109730. */
  109731. SSAORenderEffect: string;
  109732. /**
  109733. * @ignore
  109734. * The horizontal blur PostProcess id in the pipeline
  109735. */
  109736. SSAOBlurHRenderEffect: string;
  109737. /**
  109738. * @ignore
  109739. * The vertical blur PostProcess id in the pipeline
  109740. */
  109741. SSAOBlurVRenderEffect: string;
  109742. /**
  109743. * @ignore
  109744. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109745. */
  109746. SSAOCombineRenderEffect: string;
  109747. /**
  109748. * The output strength of the SSAO post-process. Default value is 1.0.
  109749. */
  109750. totalStrength: number;
  109751. /**
  109752. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109753. */
  109754. radius: number;
  109755. /**
  109756. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109757. * Must not be equal to fallOff and superior to fallOff.
  109758. * Default value is 0.0075
  109759. */
  109760. area: number;
  109761. /**
  109762. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109763. * Must not be equal to area and inferior to area.
  109764. * Default value is 0.000001
  109765. */
  109766. fallOff: number;
  109767. /**
  109768. * The base color of the SSAO post-process
  109769. * The final result is "base + ssao" between [0, 1]
  109770. */
  109771. base: number;
  109772. private _scene;
  109773. private _depthTexture;
  109774. private _randomTexture;
  109775. private _originalColorPostProcess;
  109776. private _ssaoPostProcess;
  109777. private _blurHPostProcess;
  109778. private _blurVPostProcess;
  109779. private _ssaoCombinePostProcess;
  109780. private _firstUpdate;
  109781. /**
  109782. * Gets active scene
  109783. */
  109784. readonly scene: Scene;
  109785. /**
  109786. * @constructor
  109787. * @param name - The rendering pipeline name
  109788. * @param scene - The scene linked to this pipeline
  109789. * @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 }
  109790. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109791. */
  109792. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109793. /**
  109794. * Get the class name
  109795. * @returns "SSAORenderingPipeline"
  109796. */
  109797. getClassName(): string;
  109798. /**
  109799. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109800. */
  109801. dispose(disableDepthRender?: boolean): void;
  109802. private _createBlurPostProcess;
  109803. /** @hidden */
  109804. _rebuild(): void;
  109805. private _createSSAOPostProcess;
  109806. private _createSSAOCombinePostProcess;
  109807. private _createRandomTexture;
  109808. }
  109809. }
  109810. declare module BABYLON {
  109811. /** @hidden */
  109812. export var standardPixelShader: {
  109813. name: string;
  109814. shader: string;
  109815. };
  109816. }
  109817. declare module BABYLON {
  109818. /**
  109819. * Standard rendering pipeline
  109820. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109821. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109822. */
  109823. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109824. /**
  109825. * Public members
  109826. */
  109827. /**
  109828. * Post-process which contains the original scene color before the pipeline applies all the effects
  109829. */
  109830. originalPostProcess: Nullable<PostProcess>;
  109831. /**
  109832. * Post-process used to down scale an image x4
  109833. */
  109834. downSampleX4PostProcess: Nullable<PostProcess>;
  109835. /**
  109836. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109837. */
  109838. brightPassPostProcess: Nullable<PostProcess>;
  109839. /**
  109840. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109841. */
  109842. blurHPostProcesses: PostProcess[];
  109843. /**
  109844. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109845. */
  109846. blurVPostProcesses: PostProcess[];
  109847. /**
  109848. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109849. */
  109850. textureAdderPostProcess: Nullable<PostProcess>;
  109851. /**
  109852. * Post-process used to create volumetric lighting effect
  109853. */
  109854. volumetricLightPostProcess: Nullable<PostProcess>;
  109855. /**
  109856. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109857. */
  109858. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109859. /**
  109860. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109861. */
  109862. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109863. /**
  109864. * Post-process used to merge the volumetric light effect and the real scene color
  109865. */
  109866. volumetricLightMergePostProces: Nullable<PostProcess>;
  109867. /**
  109868. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109869. */
  109870. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109871. /**
  109872. * Base post-process used to calculate the average luminance of the final image for HDR
  109873. */
  109874. luminancePostProcess: Nullable<PostProcess>;
  109875. /**
  109876. * Post-processes used to create down sample post-processes in order to get
  109877. * the average luminance of the final image for HDR
  109878. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109879. */
  109880. luminanceDownSamplePostProcesses: PostProcess[];
  109881. /**
  109882. * Post-process used to create a HDR effect (light adaptation)
  109883. */
  109884. hdrPostProcess: Nullable<PostProcess>;
  109885. /**
  109886. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109887. */
  109888. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109889. /**
  109890. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109891. */
  109892. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109893. /**
  109894. * Post-process used to merge the final HDR post-process and the real scene color
  109895. */
  109896. hdrFinalPostProcess: Nullable<PostProcess>;
  109897. /**
  109898. * Post-process used to create a lens flare effect
  109899. */
  109900. lensFlarePostProcess: Nullable<PostProcess>;
  109901. /**
  109902. * Post-process that merges the result of the lens flare post-process and the real scene color
  109903. */
  109904. lensFlareComposePostProcess: Nullable<PostProcess>;
  109905. /**
  109906. * Post-process used to create a motion blur effect
  109907. */
  109908. motionBlurPostProcess: Nullable<PostProcess>;
  109909. /**
  109910. * Post-process used to create a depth of field effect
  109911. */
  109912. depthOfFieldPostProcess: Nullable<PostProcess>;
  109913. /**
  109914. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109915. */
  109916. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109917. /**
  109918. * Represents the brightness threshold in order to configure the illuminated surfaces
  109919. */
  109920. brightThreshold: number;
  109921. /**
  109922. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109923. */
  109924. blurWidth: number;
  109925. /**
  109926. * Sets if the blur for highlighted surfaces must be only horizontal
  109927. */
  109928. horizontalBlur: boolean;
  109929. /**
  109930. * Sets the overall exposure used by the pipeline
  109931. */
  109932. exposure: number;
  109933. /**
  109934. * Texture used typically to simulate "dirty" on camera lens
  109935. */
  109936. lensTexture: Nullable<Texture>;
  109937. /**
  109938. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109939. */
  109940. volumetricLightCoefficient: number;
  109941. /**
  109942. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109943. */
  109944. volumetricLightPower: number;
  109945. /**
  109946. * Used the set the blur intensity to smooth the volumetric lights
  109947. */
  109948. volumetricLightBlurScale: number;
  109949. /**
  109950. * Light (spot or directional) used to generate the volumetric lights rays
  109951. * The source light must have a shadow generate so the pipeline can get its
  109952. * depth map
  109953. */
  109954. sourceLight: Nullable<SpotLight | DirectionalLight>;
  109955. /**
  109956. * For eye adaptation, represents the minimum luminance the eye can see
  109957. */
  109958. hdrMinimumLuminance: number;
  109959. /**
  109960. * For eye adaptation, represents the decrease luminance speed
  109961. */
  109962. hdrDecreaseRate: number;
  109963. /**
  109964. * For eye adaptation, represents the increase luminance speed
  109965. */
  109966. hdrIncreaseRate: number;
  109967. /**
  109968. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  109969. */
  109970. lensColorTexture: Nullable<Texture>;
  109971. /**
  109972. * The overall strengh for the lens flare effect
  109973. */
  109974. lensFlareStrength: number;
  109975. /**
  109976. * Dispersion coefficient for lens flare ghosts
  109977. */
  109978. lensFlareGhostDispersal: number;
  109979. /**
  109980. * Main lens flare halo width
  109981. */
  109982. lensFlareHaloWidth: number;
  109983. /**
  109984. * Based on the lens distortion effect, defines how much the lens flare result
  109985. * is distorted
  109986. */
  109987. lensFlareDistortionStrength: number;
  109988. /**
  109989. * Lens star texture must be used to simulate rays on the flares and is available
  109990. * in the documentation
  109991. */
  109992. lensStarTexture: Nullable<Texture>;
  109993. /**
  109994. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  109995. * flare effect by taking account of the dirt texture
  109996. */
  109997. lensFlareDirtTexture: Nullable<Texture>;
  109998. /**
  109999. * Represents the focal length for the depth of field effect
  110000. */
  110001. depthOfFieldDistance: number;
  110002. /**
  110003. * Represents the blur intensity for the blurred part of the depth of field effect
  110004. */
  110005. depthOfFieldBlurWidth: number;
  110006. /**
  110007. * For motion blur, defines how much the image is blurred by the movement
  110008. */
  110009. motionStrength: number;
  110010. /**
  110011. * List of animations for the pipeline (IAnimatable implementation)
  110012. */
  110013. animations: Animation[];
  110014. /**
  110015. * Private members
  110016. */
  110017. private _scene;
  110018. private _currentDepthOfFieldSource;
  110019. private _basePostProcess;
  110020. private _hdrCurrentLuminance;
  110021. private _floatTextureType;
  110022. private _ratio;
  110023. private _bloomEnabled;
  110024. private _depthOfFieldEnabled;
  110025. private _vlsEnabled;
  110026. private _lensFlareEnabled;
  110027. private _hdrEnabled;
  110028. private _motionBlurEnabled;
  110029. private _fxaaEnabled;
  110030. private _motionBlurSamples;
  110031. private _volumetricLightStepsCount;
  110032. private _samples;
  110033. /**
  110034. * @ignore
  110035. * Specifies if the bloom pipeline is enabled
  110036. */
  110037. BloomEnabled: boolean;
  110038. /**
  110039. * @ignore
  110040. * Specifies if the depth of field pipeline is enabed
  110041. */
  110042. DepthOfFieldEnabled: boolean;
  110043. /**
  110044. * @ignore
  110045. * Specifies if the lens flare pipeline is enabed
  110046. */
  110047. LensFlareEnabled: boolean;
  110048. /**
  110049. * @ignore
  110050. * Specifies if the HDR pipeline is enabled
  110051. */
  110052. HDREnabled: boolean;
  110053. /**
  110054. * @ignore
  110055. * Specifies if the volumetric lights scattering effect is enabled
  110056. */
  110057. VLSEnabled: boolean;
  110058. /**
  110059. * @ignore
  110060. * Specifies if the motion blur effect is enabled
  110061. */
  110062. MotionBlurEnabled: boolean;
  110063. /**
  110064. * Specifies if anti-aliasing is enabled
  110065. */
  110066. fxaaEnabled: boolean;
  110067. /**
  110068. * Specifies the number of steps used to calculate the volumetric lights
  110069. * Typically in interval [50, 200]
  110070. */
  110071. volumetricLightStepsCount: number;
  110072. /**
  110073. * Specifies the number of samples used for the motion blur effect
  110074. * Typically in interval [16, 64]
  110075. */
  110076. motionBlurSamples: number;
  110077. /**
  110078. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110079. */
  110080. samples: number;
  110081. /**
  110082. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110083. * @constructor
  110084. * @param name The rendering pipeline name
  110085. * @param scene The scene linked to this pipeline
  110086. * @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)
  110087. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  110088. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110089. */
  110090. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  110091. private _buildPipeline;
  110092. private _createDownSampleX4PostProcess;
  110093. private _createBrightPassPostProcess;
  110094. private _createBlurPostProcesses;
  110095. private _createTextureAdderPostProcess;
  110096. private _createVolumetricLightPostProcess;
  110097. private _createLuminancePostProcesses;
  110098. private _createHdrPostProcess;
  110099. private _createLensFlarePostProcess;
  110100. private _createDepthOfFieldPostProcess;
  110101. private _createMotionBlurPostProcess;
  110102. private _getDepthTexture;
  110103. private _disposePostProcesses;
  110104. /**
  110105. * Dispose of the pipeline and stop all post processes
  110106. */
  110107. dispose(): void;
  110108. /**
  110109. * Serialize the rendering pipeline (Used when exporting)
  110110. * @returns the serialized object
  110111. */
  110112. serialize(): any;
  110113. /**
  110114. * Parse the serialized pipeline
  110115. * @param source Source pipeline.
  110116. * @param scene The scene to load the pipeline to.
  110117. * @param rootUrl The URL of the serialized pipeline.
  110118. * @returns An instantiated pipeline from the serialized object.
  110119. */
  110120. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  110121. /**
  110122. * Luminance steps
  110123. */
  110124. static LuminanceSteps: number;
  110125. }
  110126. }
  110127. declare module BABYLON {
  110128. /** @hidden */
  110129. export var tonemapPixelShader: {
  110130. name: string;
  110131. shader: string;
  110132. };
  110133. }
  110134. declare module BABYLON {
  110135. /** Defines operator used for tonemapping */
  110136. export enum TonemappingOperator {
  110137. /** Hable */
  110138. Hable = 0,
  110139. /** Reinhard */
  110140. Reinhard = 1,
  110141. /** HejiDawson */
  110142. HejiDawson = 2,
  110143. /** Photographic */
  110144. Photographic = 3
  110145. }
  110146. /**
  110147. * Defines a post process to apply tone mapping
  110148. */
  110149. export class TonemapPostProcess extends PostProcess {
  110150. private _operator;
  110151. /** Defines the required exposure adjustement */
  110152. exposureAdjustment: number;
  110153. /**
  110154. * Creates a new TonemapPostProcess
  110155. * @param name defines the name of the postprocess
  110156. * @param _operator defines the operator to use
  110157. * @param exposureAdjustment defines the required exposure adjustement
  110158. * @param camera defines the camera to use (can be null)
  110159. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  110160. * @param engine defines the hosting engine (can be ignore if camera is set)
  110161. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  110162. */
  110163. constructor(name: string, _operator: TonemappingOperator,
  110164. /** Defines the required exposure adjustement */
  110165. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  110166. }
  110167. }
  110168. declare module BABYLON {
  110169. /** @hidden */
  110170. export var depthVertexShader: {
  110171. name: string;
  110172. shader: string;
  110173. };
  110174. }
  110175. declare module BABYLON {
  110176. /** @hidden */
  110177. export var volumetricLightScatteringPixelShader: {
  110178. name: string;
  110179. shader: string;
  110180. };
  110181. }
  110182. declare module BABYLON {
  110183. /** @hidden */
  110184. export var volumetricLightScatteringPassPixelShader: {
  110185. name: string;
  110186. shader: string;
  110187. };
  110188. }
  110189. declare module BABYLON {
  110190. /**
  110191. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  110192. */
  110193. export class VolumetricLightScatteringPostProcess extends PostProcess {
  110194. private _volumetricLightScatteringPass;
  110195. private _volumetricLightScatteringRTT;
  110196. private _viewPort;
  110197. private _screenCoordinates;
  110198. private _cachedDefines;
  110199. /**
  110200. * If not undefined, the mesh position is computed from the attached node position
  110201. */
  110202. attachedNode: {
  110203. position: Vector3;
  110204. };
  110205. /**
  110206. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  110207. */
  110208. customMeshPosition: Vector3;
  110209. /**
  110210. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  110211. */
  110212. useCustomMeshPosition: boolean;
  110213. /**
  110214. * If the post-process should inverse the light scattering direction
  110215. */
  110216. invert: boolean;
  110217. /**
  110218. * The internal mesh used by the post-process
  110219. */
  110220. mesh: Mesh;
  110221. /**
  110222. * @hidden
  110223. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  110224. */
  110225. useDiffuseColor: boolean;
  110226. /**
  110227. * Array containing the excluded meshes not rendered in the internal pass
  110228. */
  110229. excludedMeshes: AbstractMesh[];
  110230. /**
  110231. * Controls the overall intensity of the post-process
  110232. */
  110233. exposure: number;
  110234. /**
  110235. * Dissipates each sample's contribution in range [0, 1]
  110236. */
  110237. decay: number;
  110238. /**
  110239. * Controls the overall intensity of each sample
  110240. */
  110241. weight: number;
  110242. /**
  110243. * Controls the density of each sample
  110244. */
  110245. density: number;
  110246. /**
  110247. * @constructor
  110248. * @param name The post-process name
  110249. * @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)
  110250. * @param camera The camera that the post-process will be attached to
  110251. * @param mesh The mesh used to create the light scattering
  110252. * @param samples The post-process quality, default 100
  110253. * @param samplingModeThe post-process filtering mode
  110254. * @param engine The babylon engine
  110255. * @param reusable If the post-process is reusable
  110256. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  110257. */
  110258. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  110259. /**
  110260. * Returns the string "VolumetricLightScatteringPostProcess"
  110261. * @returns "VolumetricLightScatteringPostProcess"
  110262. */
  110263. getClassName(): string;
  110264. private _isReady;
  110265. /**
  110266. * Sets the new light position for light scattering effect
  110267. * @param position The new custom light position
  110268. */
  110269. setCustomMeshPosition(position: Vector3): void;
  110270. /**
  110271. * Returns the light position for light scattering effect
  110272. * @return Vector3 The custom light position
  110273. */
  110274. getCustomMeshPosition(): Vector3;
  110275. /**
  110276. * Disposes the internal assets and detaches the post-process from the camera
  110277. */
  110278. dispose(camera: Camera): void;
  110279. /**
  110280. * Returns the render target texture used by the post-process
  110281. * @return the render target texture used by the post-process
  110282. */
  110283. getPass(): RenderTargetTexture;
  110284. private _meshExcluded;
  110285. private _createPass;
  110286. private _updateMeshScreenCoordinates;
  110287. /**
  110288. * Creates a default mesh for the Volumeric Light Scattering post-process
  110289. * @param name The mesh name
  110290. * @param scene The scene where to create the mesh
  110291. * @return the default mesh
  110292. */
  110293. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  110294. }
  110295. }
  110296. declare module BABYLON {
  110297. interface Scene {
  110298. /** @hidden (Backing field) */
  110299. _boundingBoxRenderer: BoundingBoxRenderer;
  110300. /** @hidden (Backing field) */
  110301. _forceShowBoundingBoxes: boolean;
  110302. /**
  110303. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  110304. */
  110305. forceShowBoundingBoxes: boolean;
  110306. /**
  110307. * Gets the bounding box renderer associated with the scene
  110308. * @returns a BoundingBoxRenderer
  110309. */
  110310. getBoundingBoxRenderer(): BoundingBoxRenderer;
  110311. }
  110312. interface AbstractMesh {
  110313. /** @hidden (Backing field) */
  110314. _showBoundingBox: boolean;
  110315. /**
  110316. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  110317. */
  110318. showBoundingBox: boolean;
  110319. }
  110320. /**
  110321. * Component responsible of rendering the bounding box of the meshes in a scene.
  110322. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  110323. */
  110324. export class BoundingBoxRenderer implements ISceneComponent {
  110325. /**
  110326. * The component name helpfull to identify the component in the list of scene components.
  110327. */
  110328. readonly name: string;
  110329. /**
  110330. * The scene the component belongs to.
  110331. */
  110332. scene: Scene;
  110333. /**
  110334. * Color of the bounding box lines placed in front of an object
  110335. */
  110336. frontColor: Color3;
  110337. /**
  110338. * Color of the bounding box lines placed behind an object
  110339. */
  110340. backColor: Color3;
  110341. /**
  110342. * Defines if the renderer should show the back lines or not
  110343. */
  110344. showBackLines: boolean;
  110345. /**
  110346. * @hidden
  110347. */
  110348. renderList: SmartArray<BoundingBox>;
  110349. private _colorShader;
  110350. private _vertexBuffers;
  110351. private _indexBuffer;
  110352. /**
  110353. * Instantiates a new bounding box renderer in a scene.
  110354. * @param scene the scene the renderer renders in
  110355. */
  110356. constructor(scene: Scene);
  110357. /**
  110358. * Registers the component in a given scene
  110359. */
  110360. register(): void;
  110361. private _evaluateSubMesh;
  110362. private _activeMesh;
  110363. private _prepareRessources;
  110364. private _createIndexBuffer;
  110365. /**
  110366. * Rebuilds the elements related to this component in case of
  110367. * context lost for instance.
  110368. */
  110369. rebuild(): void;
  110370. /**
  110371. * @hidden
  110372. */
  110373. reset(): void;
  110374. /**
  110375. * Render the bounding boxes of a specific rendering group
  110376. * @param renderingGroupId defines the rendering group to render
  110377. */
  110378. render(renderingGroupId: number): void;
  110379. /**
  110380. * In case of occlusion queries, we can render the occlusion bounding box through this method
  110381. * @param mesh Define the mesh to render the occlusion bounding box for
  110382. */
  110383. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  110384. /**
  110385. * Dispose and release the resources attached to this renderer.
  110386. */
  110387. dispose(): void;
  110388. }
  110389. }
  110390. declare module BABYLON {
  110391. /** @hidden */
  110392. export var depthPixelShader: {
  110393. name: string;
  110394. shader: string;
  110395. };
  110396. }
  110397. declare module BABYLON {
  110398. /**
  110399. * This represents a depth renderer in Babylon.
  110400. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  110401. */
  110402. export class DepthRenderer {
  110403. private _scene;
  110404. private _depthMap;
  110405. private _effect;
  110406. private _cachedDefines;
  110407. private _camera;
  110408. /**
  110409. * Specifiess that the depth renderer will only be used within
  110410. * the camera it is created for.
  110411. * This can help forcing its rendering during the camera processing.
  110412. */
  110413. useOnlyInActiveCamera: boolean;
  110414. /** @hidden */
  110415. static _SceneComponentInitialization: (scene: Scene) => void;
  110416. /**
  110417. * Instantiates a depth renderer
  110418. * @param scene The scene the renderer belongs to
  110419. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  110420. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  110421. */
  110422. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  110423. /**
  110424. * Creates the depth rendering effect and checks if the effect is ready.
  110425. * @param subMesh The submesh to be used to render the depth map of
  110426. * @param useInstances If multiple world instances should be used
  110427. * @returns if the depth renderer is ready to render the depth map
  110428. */
  110429. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110430. /**
  110431. * Gets the texture which the depth map will be written to.
  110432. * @returns The depth map texture
  110433. */
  110434. getDepthMap(): RenderTargetTexture;
  110435. /**
  110436. * Disposes of the depth renderer.
  110437. */
  110438. dispose(): void;
  110439. }
  110440. }
  110441. declare module BABYLON {
  110442. interface Scene {
  110443. /** @hidden (Backing field) */
  110444. _depthRenderer: {
  110445. [id: string]: DepthRenderer;
  110446. };
  110447. /**
  110448. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  110449. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  110450. * @returns the created depth renderer
  110451. */
  110452. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  110453. /**
  110454. * Disables a depth renderer for a given camera
  110455. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  110456. */
  110457. disableDepthRenderer(camera?: Nullable<Camera>): void;
  110458. }
  110459. /**
  110460. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  110461. * in several rendering techniques.
  110462. */
  110463. export class DepthRendererSceneComponent implements ISceneComponent {
  110464. /**
  110465. * The component name helpfull to identify the component in the list of scene components.
  110466. */
  110467. readonly name: string;
  110468. /**
  110469. * The scene the component belongs to.
  110470. */
  110471. scene: Scene;
  110472. /**
  110473. * Creates a new instance of the component for the given scene
  110474. * @param scene Defines the scene to register the component in
  110475. */
  110476. constructor(scene: Scene);
  110477. /**
  110478. * Registers the component in a given scene
  110479. */
  110480. register(): void;
  110481. /**
  110482. * Rebuilds the elements related to this component in case of
  110483. * context lost for instance.
  110484. */
  110485. rebuild(): void;
  110486. /**
  110487. * Disposes the component and the associated ressources
  110488. */
  110489. dispose(): void;
  110490. private _gatherRenderTargets;
  110491. private _gatherActiveCameraRenderTargets;
  110492. }
  110493. }
  110494. declare module BABYLON {
  110495. /** @hidden */
  110496. export var outlinePixelShader: {
  110497. name: string;
  110498. shader: string;
  110499. };
  110500. }
  110501. declare module BABYLON {
  110502. /** @hidden */
  110503. export var outlineVertexShader: {
  110504. name: string;
  110505. shader: string;
  110506. };
  110507. }
  110508. declare module BABYLON {
  110509. interface Scene {
  110510. /** @hidden */
  110511. _outlineRenderer: OutlineRenderer;
  110512. /**
  110513. * Gets the outline renderer associated with the scene
  110514. * @returns a OutlineRenderer
  110515. */
  110516. getOutlineRenderer(): OutlineRenderer;
  110517. }
  110518. interface AbstractMesh {
  110519. /** @hidden (Backing field) */
  110520. _renderOutline: boolean;
  110521. /**
  110522. * Gets or sets a boolean indicating if the outline must be rendered as well
  110523. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110524. */
  110525. renderOutline: boolean;
  110526. /** @hidden (Backing field) */
  110527. _renderOverlay: boolean;
  110528. /**
  110529. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110530. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110531. */
  110532. renderOverlay: boolean;
  110533. }
  110534. /**
  110535. * This class is responsible to draw bothe outline/overlay of meshes.
  110536. * It should not be used directly but through the available method on mesh.
  110537. */
  110538. export class OutlineRenderer implements ISceneComponent {
  110539. /**
  110540. * The name of the component. Each component must have a unique name.
  110541. */
  110542. name: string;
  110543. /**
  110544. * The scene the component belongs to.
  110545. */
  110546. scene: Scene;
  110547. /**
  110548. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110549. */
  110550. zOffset: number;
  110551. private _engine;
  110552. private _effect;
  110553. private _cachedDefines;
  110554. private _savedDepthWrite;
  110555. /**
  110556. * Instantiates a new outline renderer. (There could be only one per scene).
  110557. * @param scene Defines the scene it belongs to
  110558. */
  110559. constructor(scene: Scene);
  110560. /**
  110561. * Register the component to one instance of a scene.
  110562. */
  110563. register(): void;
  110564. /**
  110565. * Rebuilds the elements related to this component in case of
  110566. * context lost for instance.
  110567. */
  110568. rebuild(): void;
  110569. /**
  110570. * Disposes the component and the associated ressources.
  110571. */
  110572. dispose(): void;
  110573. /**
  110574. * Renders the outline in the canvas.
  110575. * @param subMesh Defines the sumesh to render
  110576. * @param batch Defines the batch of meshes in case of instances
  110577. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110578. */
  110579. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110580. /**
  110581. * Returns whether or not the outline renderer is ready for a given submesh.
  110582. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110583. * @param subMesh Defines the submesh to check readyness for
  110584. * @param useInstances Defines wheter wee are trying to render instances or not
  110585. * @returns true if ready otherwise false
  110586. */
  110587. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110588. private _beforeRenderingMesh;
  110589. private _afterRenderingMesh;
  110590. }
  110591. }
  110592. declare module BABYLON {
  110593. /**
  110594. * Defines the list of states available for a task inside a AssetsManager
  110595. */
  110596. export enum AssetTaskState {
  110597. /**
  110598. * Initialization
  110599. */
  110600. INIT = 0,
  110601. /**
  110602. * Running
  110603. */
  110604. RUNNING = 1,
  110605. /**
  110606. * Done
  110607. */
  110608. DONE = 2,
  110609. /**
  110610. * Error
  110611. */
  110612. ERROR = 3
  110613. }
  110614. /**
  110615. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110616. */
  110617. export abstract class AbstractAssetTask {
  110618. /**
  110619. * Task name
  110620. */ name: string;
  110621. /**
  110622. * Callback called when the task is successful
  110623. */
  110624. onSuccess: (task: any) => void;
  110625. /**
  110626. * Callback called when the task is not successful
  110627. */
  110628. onError: (task: any, message?: string, exception?: any) => void;
  110629. /**
  110630. * Creates a new AssetsManager
  110631. * @param name defines the name of the task
  110632. */
  110633. constructor(
  110634. /**
  110635. * Task name
  110636. */ name: string);
  110637. private _isCompleted;
  110638. private _taskState;
  110639. private _errorObject;
  110640. /**
  110641. * Get if the task is completed
  110642. */
  110643. readonly isCompleted: boolean;
  110644. /**
  110645. * Gets the current state of the task
  110646. */
  110647. readonly taskState: AssetTaskState;
  110648. /**
  110649. * Gets the current error object (if task is in error)
  110650. */
  110651. readonly errorObject: {
  110652. message?: string;
  110653. exception?: any;
  110654. };
  110655. /**
  110656. * Internal only
  110657. * @hidden
  110658. */
  110659. _setErrorObject(message?: string, exception?: any): void;
  110660. /**
  110661. * Execute the current task
  110662. * @param scene defines the scene where you want your assets to be loaded
  110663. * @param onSuccess is a callback called when the task is successfully executed
  110664. * @param onError is a callback called if an error occurs
  110665. */
  110666. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110667. /**
  110668. * Execute the current task
  110669. * @param scene defines the scene where you want your assets to be loaded
  110670. * @param onSuccess is a callback called when the task is successfully executed
  110671. * @param onError is a callback called if an error occurs
  110672. */
  110673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110674. /**
  110675. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110676. * This can be used with failed tasks that have the reason for failure fixed.
  110677. */
  110678. reset(): void;
  110679. private onErrorCallback;
  110680. private onDoneCallback;
  110681. }
  110682. /**
  110683. * Define the interface used by progress events raised during assets loading
  110684. */
  110685. export interface IAssetsProgressEvent {
  110686. /**
  110687. * Defines the number of remaining tasks to process
  110688. */
  110689. remainingCount: number;
  110690. /**
  110691. * Defines the total number of tasks
  110692. */
  110693. totalCount: number;
  110694. /**
  110695. * Defines the task that was just processed
  110696. */
  110697. task: AbstractAssetTask;
  110698. }
  110699. /**
  110700. * Class used to share progress information about assets loading
  110701. */
  110702. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110703. /**
  110704. * Defines the number of remaining tasks to process
  110705. */
  110706. remainingCount: number;
  110707. /**
  110708. * Defines the total number of tasks
  110709. */
  110710. totalCount: number;
  110711. /**
  110712. * Defines the task that was just processed
  110713. */
  110714. task: AbstractAssetTask;
  110715. /**
  110716. * Creates a AssetsProgressEvent
  110717. * @param remainingCount defines the number of remaining tasks to process
  110718. * @param totalCount defines the total number of tasks
  110719. * @param task defines the task that was just processed
  110720. */
  110721. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110722. }
  110723. /**
  110724. * Define a task used by AssetsManager to load meshes
  110725. */
  110726. export class MeshAssetTask extends AbstractAssetTask {
  110727. /**
  110728. * Defines the name of the task
  110729. */
  110730. name: string;
  110731. /**
  110732. * Defines the list of mesh's names you want to load
  110733. */
  110734. meshesNames: any;
  110735. /**
  110736. * Defines the root url to use as a base to load your meshes and associated resources
  110737. */
  110738. rootUrl: string;
  110739. /**
  110740. * Defines the filename of the scene to load from
  110741. */
  110742. sceneFilename: string;
  110743. /**
  110744. * Gets the list of loaded meshes
  110745. */
  110746. loadedMeshes: Array<AbstractMesh>;
  110747. /**
  110748. * Gets the list of loaded particle systems
  110749. */
  110750. loadedParticleSystems: Array<IParticleSystem>;
  110751. /**
  110752. * Gets the list of loaded skeletons
  110753. */
  110754. loadedSkeletons: Array<Skeleton>;
  110755. /**
  110756. * Gets the list of loaded animation groups
  110757. */
  110758. loadedAnimationGroups: Array<AnimationGroup>;
  110759. /**
  110760. * Callback called when the task is successful
  110761. */
  110762. onSuccess: (task: MeshAssetTask) => void;
  110763. /**
  110764. * Callback called when the task is successful
  110765. */
  110766. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110767. /**
  110768. * Creates a new MeshAssetTask
  110769. * @param name defines the name of the task
  110770. * @param meshesNames defines the list of mesh's names you want to load
  110771. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110772. * @param sceneFilename defines the filename of the scene to load from
  110773. */
  110774. constructor(
  110775. /**
  110776. * Defines the name of the task
  110777. */
  110778. name: string,
  110779. /**
  110780. * Defines the list of mesh's names you want to load
  110781. */
  110782. meshesNames: any,
  110783. /**
  110784. * Defines the root url to use as a base to load your meshes and associated resources
  110785. */
  110786. rootUrl: string,
  110787. /**
  110788. * Defines the filename of the scene to load from
  110789. */
  110790. sceneFilename: string);
  110791. /**
  110792. * Execute the current task
  110793. * @param scene defines the scene where you want your assets to be loaded
  110794. * @param onSuccess is a callback called when the task is successfully executed
  110795. * @param onError is a callback called if an error occurs
  110796. */
  110797. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110798. }
  110799. /**
  110800. * Define a task used by AssetsManager to load text content
  110801. */
  110802. export class TextFileAssetTask extends AbstractAssetTask {
  110803. /**
  110804. * Defines the name of the task
  110805. */
  110806. name: string;
  110807. /**
  110808. * Defines the location of the file to load
  110809. */
  110810. url: string;
  110811. /**
  110812. * Gets the loaded text string
  110813. */
  110814. text: string;
  110815. /**
  110816. * Callback called when the task is successful
  110817. */
  110818. onSuccess: (task: TextFileAssetTask) => void;
  110819. /**
  110820. * Callback called when the task is successful
  110821. */
  110822. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110823. /**
  110824. * Creates a new TextFileAssetTask object
  110825. * @param name defines the name of the task
  110826. * @param url defines the location of the file to load
  110827. */
  110828. constructor(
  110829. /**
  110830. * Defines the name of the task
  110831. */
  110832. name: string,
  110833. /**
  110834. * Defines the location of the file to load
  110835. */
  110836. url: string);
  110837. /**
  110838. * Execute the current task
  110839. * @param scene defines the scene where you want your assets to be loaded
  110840. * @param onSuccess is a callback called when the task is successfully executed
  110841. * @param onError is a callback called if an error occurs
  110842. */
  110843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110844. }
  110845. /**
  110846. * Define a task used by AssetsManager to load binary data
  110847. */
  110848. export class BinaryFileAssetTask extends AbstractAssetTask {
  110849. /**
  110850. * Defines the name of the task
  110851. */
  110852. name: string;
  110853. /**
  110854. * Defines the location of the file to load
  110855. */
  110856. url: string;
  110857. /**
  110858. * Gets the lodaded data (as an array buffer)
  110859. */
  110860. data: ArrayBuffer;
  110861. /**
  110862. * Callback called when the task is successful
  110863. */
  110864. onSuccess: (task: BinaryFileAssetTask) => void;
  110865. /**
  110866. * Callback called when the task is successful
  110867. */
  110868. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110869. /**
  110870. * Creates a new BinaryFileAssetTask object
  110871. * @param name defines the name of the new task
  110872. * @param url defines the location of the file to load
  110873. */
  110874. constructor(
  110875. /**
  110876. * Defines the name of the task
  110877. */
  110878. name: string,
  110879. /**
  110880. * Defines the location of the file to load
  110881. */
  110882. url: string);
  110883. /**
  110884. * Execute the current task
  110885. * @param scene defines the scene where you want your assets to be loaded
  110886. * @param onSuccess is a callback called when the task is successfully executed
  110887. * @param onError is a callback called if an error occurs
  110888. */
  110889. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110890. }
  110891. /**
  110892. * Define a task used by AssetsManager to load images
  110893. */
  110894. export class ImageAssetTask extends AbstractAssetTask {
  110895. /**
  110896. * Defines the name of the task
  110897. */
  110898. name: string;
  110899. /**
  110900. * Defines the location of the image to load
  110901. */
  110902. url: string;
  110903. /**
  110904. * Gets the loaded images
  110905. */
  110906. image: HTMLImageElement;
  110907. /**
  110908. * Callback called when the task is successful
  110909. */
  110910. onSuccess: (task: ImageAssetTask) => void;
  110911. /**
  110912. * Callback called when the task is successful
  110913. */
  110914. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110915. /**
  110916. * Creates a new ImageAssetTask
  110917. * @param name defines the name of the task
  110918. * @param url defines the location of the image to load
  110919. */
  110920. constructor(
  110921. /**
  110922. * Defines the name of the task
  110923. */
  110924. name: string,
  110925. /**
  110926. * Defines the location of the image to load
  110927. */
  110928. url: string);
  110929. /**
  110930. * Execute the current task
  110931. * @param scene defines the scene where you want your assets to be loaded
  110932. * @param onSuccess is a callback called when the task is successfully executed
  110933. * @param onError is a callback called if an error occurs
  110934. */
  110935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110936. }
  110937. /**
  110938. * Defines the interface used by texture loading tasks
  110939. */
  110940. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110941. /**
  110942. * Gets the loaded texture
  110943. */
  110944. texture: TEX;
  110945. }
  110946. /**
  110947. * Define a task used by AssetsManager to load 2D textures
  110948. */
  110949. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  110950. /**
  110951. * Defines the name of the task
  110952. */
  110953. name: string;
  110954. /**
  110955. * Defines the location of the file to load
  110956. */
  110957. url: string;
  110958. /**
  110959. * Defines if mipmap should not be generated (default is false)
  110960. */
  110961. noMipmap?: boolean | undefined;
  110962. /**
  110963. * Defines if texture must be inverted on Y axis (default is false)
  110964. */
  110965. invertY?: boolean | undefined;
  110966. /**
  110967. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110968. */
  110969. samplingMode: number;
  110970. /**
  110971. * Gets the loaded texture
  110972. */
  110973. texture: Texture;
  110974. /**
  110975. * Callback called when the task is successful
  110976. */
  110977. onSuccess: (task: TextureAssetTask) => void;
  110978. /**
  110979. * Callback called when the task is successful
  110980. */
  110981. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  110982. /**
  110983. * Creates a new TextureAssetTask object
  110984. * @param name defines the name of the task
  110985. * @param url defines the location of the file to load
  110986. * @param noMipmap defines if mipmap should not be generated (default is false)
  110987. * @param invertY defines if texture must be inverted on Y axis (default is false)
  110988. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110989. */
  110990. constructor(
  110991. /**
  110992. * Defines the name of the task
  110993. */
  110994. name: string,
  110995. /**
  110996. * Defines the location of the file to load
  110997. */
  110998. url: string,
  110999. /**
  111000. * Defines if mipmap should not be generated (default is false)
  111001. */
  111002. noMipmap?: boolean | undefined,
  111003. /**
  111004. * Defines if texture must be inverted on Y axis (default is false)
  111005. */
  111006. invertY?: boolean | undefined,
  111007. /**
  111008. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111009. */
  111010. samplingMode?: number);
  111011. /**
  111012. * Execute the current task
  111013. * @param scene defines the scene where you want your assets to be loaded
  111014. * @param onSuccess is a callback called when the task is successfully executed
  111015. * @param onError is a callback called if an error occurs
  111016. */
  111017. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111018. }
  111019. /**
  111020. * Define a task used by AssetsManager to load cube textures
  111021. */
  111022. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  111023. /**
  111024. * Defines the name of the task
  111025. */
  111026. name: string;
  111027. /**
  111028. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111029. */
  111030. url: string;
  111031. /**
  111032. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111033. */
  111034. extensions?: string[] | undefined;
  111035. /**
  111036. * Defines if mipmaps should not be generated (default is false)
  111037. */
  111038. noMipmap?: boolean | undefined;
  111039. /**
  111040. * Defines the explicit list of files (undefined by default)
  111041. */
  111042. files?: string[] | undefined;
  111043. /**
  111044. * Gets the loaded texture
  111045. */
  111046. texture: CubeTexture;
  111047. /**
  111048. * Callback called when the task is successful
  111049. */
  111050. onSuccess: (task: CubeTextureAssetTask) => void;
  111051. /**
  111052. * Callback called when the task is successful
  111053. */
  111054. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  111055. /**
  111056. * Creates a new CubeTextureAssetTask
  111057. * @param name defines the name of the task
  111058. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111059. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111060. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111061. * @param files defines the explicit list of files (undefined by default)
  111062. */
  111063. constructor(
  111064. /**
  111065. * Defines the name of the task
  111066. */
  111067. name: string,
  111068. /**
  111069. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111070. */
  111071. url: string,
  111072. /**
  111073. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111074. */
  111075. extensions?: string[] | undefined,
  111076. /**
  111077. * Defines if mipmaps should not be generated (default is false)
  111078. */
  111079. noMipmap?: boolean | undefined,
  111080. /**
  111081. * Defines the explicit list of files (undefined by default)
  111082. */
  111083. files?: string[] | undefined);
  111084. /**
  111085. * Execute the current task
  111086. * @param scene defines the scene where you want your assets to be loaded
  111087. * @param onSuccess is a callback called when the task is successfully executed
  111088. * @param onError is a callback called if an error occurs
  111089. */
  111090. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111091. }
  111092. /**
  111093. * Define a task used by AssetsManager to load HDR cube textures
  111094. */
  111095. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  111096. /**
  111097. * Defines the name of the task
  111098. */
  111099. name: string;
  111100. /**
  111101. * Defines the location of the file to load
  111102. */
  111103. url: string;
  111104. /**
  111105. * Defines the desired size (the more it increases the longer the generation will be)
  111106. */
  111107. size: number;
  111108. /**
  111109. * Defines if mipmaps should not be generated (default is false)
  111110. */
  111111. noMipmap: boolean;
  111112. /**
  111113. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111114. */
  111115. generateHarmonics: boolean;
  111116. /**
  111117. * 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)
  111118. */
  111119. gammaSpace: boolean;
  111120. /**
  111121. * Internal Use Only
  111122. */
  111123. reserved: boolean;
  111124. /**
  111125. * Gets the loaded texture
  111126. */
  111127. texture: HDRCubeTexture;
  111128. /**
  111129. * Callback called when the task is successful
  111130. */
  111131. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  111132. /**
  111133. * Callback called when the task is successful
  111134. */
  111135. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  111136. /**
  111137. * Creates a new HDRCubeTextureAssetTask object
  111138. * @param name defines the name of the task
  111139. * @param url defines the location of the file to load
  111140. * @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.
  111141. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111142. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111143. * @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)
  111144. * @param reserved Internal use only
  111145. */
  111146. constructor(
  111147. /**
  111148. * Defines the name of the task
  111149. */
  111150. name: string,
  111151. /**
  111152. * Defines the location of the file to load
  111153. */
  111154. url: string,
  111155. /**
  111156. * Defines the desired size (the more it increases the longer the generation will be)
  111157. */
  111158. size: number,
  111159. /**
  111160. * Defines if mipmaps should not be generated (default is false)
  111161. */
  111162. noMipmap?: boolean,
  111163. /**
  111164. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111165. */
  111166. generateHarmonics?: boolean,
  111167. /**
  111168. * 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)
  111169. */
  111170. gammaSpace?: boolean,
  111171. /**
  111172. * Internal Use Only
  111173. */
  111174. reserved?: boolean);
  111175. /**
  111176. * Execute the current task
  111177. * @param scene defines the scene where you want your assets to be loaded
  111178. * @param onSuccess is a callback called when the task is successfully executed
  111179. * @param onError is a callback called if an error occurs
  111180. */
  111181. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111182. }
  111183. /**
  111184. * This class can be used to easily import assets into a scene
  111185. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  111186. */
  111187. export class AssetsManager {
  111188. private _scene;
  111189. private _isLoading;
  111190. protected _tasks: AbstractAssetTask[];
  111191. protected _waitingTasksCount: number;
  111192. protected _totalTasksCount: number;
  111193. /**
  111194. * Callback called when all tasks are processed
  111195. */
  111196. onFinish: (tasks: AbstractAssetTask[]) => void;
  111197. /**
  111198. * Callback called when a task is successful
  111199. */
  111200. onTaskSuccess: (task: AbstractAssetTask) => void;
  111201. /**
  111202. * Callback called when a task had an error
  111203. */
  111204. onTaskError: (task: AbstractAssetTask) => void;
  111205. /**
  111206. * Callback called when a task is done (whatever the result is)
  111207. */
  111208. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  111209. /**
  111210. * Observable called when all tasks are processed
  111211. */
  111212. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  111213. /**
  111214. * Observable called when a task had an error
  111215. */
  111216. onTaskErrorObservable: Observable<AbstractAssetTask>;
  111217. /**
  111218. * Observable called when a task is successful
  111219. */
  111220. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  111221. /**
  111222. * Observable called when a task is done (whatever the result is)
  111223. */
  111224. onProgressObservable: Observable<IAssetsProgressEvent>;
  111225. /**
  111226. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  111227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  111228. */
  111229. useDefaultLoadingScreen: boolean;
  111230. /**
  111231. * Creates a new AssetsManager
  111232. * @param scene defines the scene to work on
  111233. */
  111234. constructor(scene: Scene);
  111235. /**
  111236. * Add a MeshAssetTask to the list of active tasks
  111237. * @param taskName defines the name of the new task
  111238. * @param meshesNames defines the name of meshes to load
  111239. * @param rootUrl defines the root url to use to locate files
  111240. * @param sceneFilename defines the filename of the scene file
  111241. * @returns a new MeshAssetTask object
  111242. */
  111243. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  111244. /**
  111245. * Add a TextFileAssetTask to the list of active tasks
  111246. * @param taskName defines the name of the new task
  111247. * @param url defines the url of the file to load
  111248. * @returns a new TextFileAssetTask object
  111249. */
  111250. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  111251. /**
  111252. * Add a BinaryFileAssetTask to the list of active tasks
  111253. * @param taskName defines the name of the new task
  111254. * @param url defines the url of the file to load
  111255. * @returns a new BinaryFileAssetTask object
  111256. */
  111257. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  111258. /**
  111259. * Add a ImageAssetTask to the list of active tasks
  111260. * @param taskName defines the name of the new task
  111261. * @param url defines the url of the file to load
  111262. * @returns a new ImageAssetTask object
  111263. */
  111264. addImageTask(taskName: string, url: string): ImageAssetTask;
  111265. /**
  111266. * Add a TextureAssetTask 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 noMipmap defines if the texture must not receive mipmaps (false by default)
  111270. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  111271. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  111272. * @returns a new TextureAssetTask object
  111273. */
  111274. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  111275. /**
  111276. * Add a CubeTextureAssetTask to the list of active tasks
  111277. * @param taskName defines the name of the new task
  111278. * @param url defines the url of the file to load
  111279. * @param extensions defines the extension to use to load the cube map (can be null)
  111280. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111281. * @param files defines the list of files to load (can be null)
  111282. * @returns a new CubeTextureAssetTask object
  111283. */
  111284. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  111285. /**
  111286. *
  111287. * Add a HDRCubeTextureAssetTask to the list of active tasks
  111288. * @param taskName defines the name of the new task
  111289. * @param url defines the url of the file to load
  111290. * @param size defines the size you want for the cubemap (can be null)
  111291. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111292. * @param generateHarmonics defines if you want to automatically generate (true by default)
  111293. * @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)
  111294. * @param reserved Internal use only
  111295. * @returns a new HDRCubeTextureAssetTask object
  111296. */
  111297. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  111298. /**
  111299. * Remove a task from the assets manager.
  111300. * @param task the task to remove
  111301. */
  111302. removeTask(task: AbstractAssetTask): void;
  111303. private _decreaseWaitingTasksCount;
  111304. private _runTask;
  111305. /**
  111306. * Reset the AssetsManager and remove all tasks
  111307. * @return the current instance of the AssetsManager
  111308. */
  111309. reset(): AssetsManager;
  111310. /**
  111311. * Start the loading process
  111312. * @return the current instance of the AssetsManager
  111313. */
  111314. load(): AssetsManager;
  111315. }
  111316. }
  111317. declare module BABYLON {
  111318. /**
  111319. * Wrapper class for promise with external resolve and reject.
  111320. */
  111321. export class Deferred<T> {
  111322. /**
  111323. * The promise associated with this deferred object.
  111324. */
  111325. readonly promise: Promise<T>;
  111326. private _resolve;
  111327. private _reject;
  111328. /**
  111329. * The resolve method of the promise associated with this deferred object.
  111330. */
  111331. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  111332. /**
  111333. * The reject method of the promise associated with this deferred object.
  111334. */
  111335. readonly reject: (reason?: any) => void;
  111336. /**
  111337. * Constructor for this deferred object.
  111338. */
  111339. constructor();
  111340. }
  111341. }
  111342. declare module BABYLON {
  111343. /**
  111344. * Class used to help managing file picking and drag'n'drop
  111345. */
  111346. export class FilesInput {
  111347. /**
  111348. * List of files ready to be loaded
  111349. */
  111350. static readonly FilesToLoad: {
  111351. [key: string]: File;
  111352. };
  111353. /**
  111354. * Callback called when a file is processed
  111355. */
  111356. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  111357. private _engine;
  111358. private _currentScene;
  111359. private _sceneLoadedCallback;
  111360. private _progressCallback;
  111361. private _additionalRenderLoopLogicCallback;
  111362. private _textureLoadingCallback;
  111363. private _startingProcessingFilesCallback;
  111364. private _onReloadCallback;
  111365. private _errorCallback;
  111366. private _elementToMonitor;
  111367. private _sceneFileToLoad;
  111368. private _filesToLoad;
  111369. /**
  111370. * Creates a new FilesInput
  111371. * @param engine defines the rendering engine
  111372. * @param scene defines the hosting scene
  111373. * @param sceneLoadedCallback callback called when scene is loaded
  111374. * @param progressCallback callback called to track progress
  111375. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  111376. * @param textureLoadingCallback callback called when a texture is loading
  111377. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  111378. * @param onReloadCallback callback called when a reload is requested
  111379. * @param errorCallback callback call if an error occurs
  111380. */
  111381. 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);
  111382. private _dragEnterHandler;
  111383. private _dragOverHandler;
  111384. private _dropHandler;
  111385. /**
  111386. * Calls this function to listen to drag'n'drop events on a specific DOM element
  111387. * @param elementToMonitor defines the DOM element to track
  111388. */
  111389. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  111390. /**
  111391. * Release all associated resources
  111392. */
  111393. dispose(): void;
  111394. private renderFunction;
  111395. private drag;
  111396. private drop;
  111397. private _traverseFolder;
  111398. private _processFiles;
  111399. /**
  111400. * Load files from a drop event
  111401. * @param event defines the drop event to use as source
  111402. */
  111403. loadFiles(event: any): void;
  111404. private _processReload;
  111405. /**
  111406. * Reload the current scene from the loaded files
  111407. */
  111408. reload(): void;
  111409. }
  111410. }
  111411. declare module BABYLON {
  111412. /**
  111413. * Defines the root class used to create scene optimization to use with SceneOptimizer
  111414. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111415. */
  111416. export class SceneOptimization {
  111417. /**
  111418. * Defines the priority of this optimization (0 by default which means first in the list)
  111419. */
  111420. priority: number;
  111421. /**
  111422. * Gets a string describing the action executed by the current optimization
  111423. * @returns description string
  111424. */
  111425. getDescription(): string;
  111426. /**
  111427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111428. * @param scene defines the current scene where to apply this optimization
  111429. * @param optimizer defines the current optimizer
  111430. * @returns true if everything that can be done was applied
  111431. */
  111432. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111433. /**
  111434. * Creates the SceneOptimization object
  111435. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111436. * @param desc defines the description associated with the optimization
  111437. */
  111438. constructor(
  111439. /**
  111440. * Defines the priority of this optimization (0 by default which means first in the list)
  111441. */
  111442. priority?: number);
  111443. }
  111444. /**
  111445. * Defines an optimization used to reduce the size of render target textures
  111446. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111447. */
  111448. export class TextureOptimization extends SceneOptimization {
  111449. /**
  111450. * Defines the priority of this optimization (0 by default which means first in the list)
  111451. */
  111452. priority: number;
  111453. /**
  111454. * 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
  111455. */
  111456. maximumSize: number;
  111457. /**
  111458. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111459. */
  111460. step: number;
  111461. /**
  111462. * Gets a string describing the action executed by the current optimization
  111463. * @returns description string
  111464. */
  111465. getDescription(): string;
  111466. /**
  111467. * Creates the TextureOptimization object
  111468. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111469. * @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
  111470. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111471. */
  111472. constructor(
  111473. /**
  111474. * Defines the priority of this optimization (0 by default which means first in the list)
  111475. */
  111476. priority?: number,
  111477. /**
  111478. * 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
  111479. */
  111480. maximumSize?: number,
  111481. /**
  111482. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111483. */
  111484. step?: number);
  111485. /**
  111486. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111487. * @param scene defines the current scene where to apply this optimization
  111488. * @param optimizer defines the current optimizer
  111489. * @returns true if everything that can be done was applied
  111490. */
  111491. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111492. }
  111493. /**
  111494. * Defines an optimization used to increase or decrease the rendering resolution
  111495. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111496. */
  111497. export class HardwareScalingOptimization extends SceneOptimization {
  111498. /**
  111499. * Defines the priority of this optimization (0 by default which means first in the list)
  111500. */
  111501. priority: number;
  111502. /**
  111503. * Defines the maximum scale to use (2 by default)
  111504. */
  111505. maximumScale: number;
  111506. /**
  111507. * Defines the step to use between two passes (0.5 by default)
  111508. */
  111509. step: number;
  111510. private _currentScale;
  111511. private _directionOffset;
  111512. /**
  111513. * Gets a string describing the action executed by the current optimization
  111514. * @return description string
  111515. */
  111516. getDescription(): string;
  111517. /**
  111518. * Creates the HardwareScalingOptimization object
  111519. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111520. * @param maximumScale defines the maximum scale to use (2 by default)
  111521. * @param step defines the step to use between two passes (0.5 by default)
  111522. */
  111523. constructor(
  111524. /**
  111525. * Defines the priority of this optimization (0 by default which means first in the list)
  111526. */
  111527. priority?: number,
  111528. /**
  111529. * Defines the maximum scale to use (2 by default)
  111530. */
  111531. maximumScale?: number,
  111532. /**
  111533. * Defines the step to use between two passes (0.5 by default)
  111534. */
  111535. step?: number);
  111536. /**
  111537. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111538. * @param scene defines the current scene where to apply this optimization
  111539. * @param optimizer defines the current optimizer
  111540. * @returns true if everything that can be done was applied
  111541. */
  111542. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111543. }
  111544. /**
  111545. * Defines an optimization used to remove shadows
  111546. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111547. */
  111548. export class ShadowsOptimization extends SceneOptimization {
  111549. /**
  111550. * Gets a string describing the action executed by the current optimization
  111551. * @return description string
  111552. */
  111553. getDescription(): string;
  111554. /**
  111555. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111556. * @param scene defines the current scene where to apply this optimization
  111557. * @param optimizer defines the current optimizer
  111558. * @returns true if everything that can be done was applied
  111559. */
  111560. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111561. }
  111562. /**
  111563. * Defines an optimization used to turn post-processes off
  111564. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111565. */
  111566. export class PostProcessesOptimization extends SceneOptimization {
  111567. /**
  111568. * Gets a string describing the action executed by the current optimization
  111569. * @return description string
  111570. */
  111571. getDescription(): string;
  111572. /**
  111573. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111574. * @param scene defines the current scene where to apply this optimization
  111575. * @param optimizer defines the current optimizer
  111576. * @returns true if everything that can be done was applied
  111577. */
  111578. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111579. }
  111580. /**
  111581. * Defines an optimization used to turn lens flares off
  111582. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111583. */
  111584. export class LensFlaresOptimization extends SceneOptimization {
  111585. /**
  111586. * Gets a string describing the action executed by the current optimization
  111587. * @return description string
  111588. */
  111589. getDescription(): string;
  111590. /**
  111591. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111592. * @param scene defines the current scene where to apply this optimization
  111593. * @param optimizer defines the current optimizer
  111594. * @returns true if everything that can be done was applied
  111595. */
  111596. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111597. }
  111598. /**
  111599. * Defines an optimization based on user defined callback.
  111600. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111601. */
  111602. export class CustomOptimization extends SceneOptimization {
  111603. /**
  111604. * Callback called to apply the custom optimization.
  111605. */
  111606. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111607. /**
  111608. * Callback called to get custom description
  111609. */
  111610. onGetDescription: () => string;
  111611. /**
  111612. * Gets a string describing the action executed by the current optimization
  111613. * @returns description string
  111614. */
  111615. getDescription(): string;
  111616. /**
  111617. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111618. * @param scene defines the current scene where to apply this optimization
  111619. * @param optimizer defines the current optimizer
  111620. * @returns true if everything that can be done was applied
  111621. */
  111622. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111623. }
  111624. /**
  111625. * Defines an optimization used to turn particles off
  111626. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111627. */
  111628. export class ParticlesOptimization extends SceneOptimization {
  111629. /**
  111630. * Gets a string describing the action executed by the current optimization
  111631. * @return description string
  111632. */
  111633. getDescription(): string;
  111634. /**
  111635. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111636. * @param scene defines the current scene where to apply this optimization
  111637. * @param optimizer defines the current optimizer
  111638. * @returns true if everything that can be done was applied
  111639. */
  111640. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111641. }
  111642. /**
  111643. * Defines an optimization used to turn render targets off
  111644. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111645. */
  111646. export class RenderTargetsOptimization extends SceneOptimization {
  111647. /**
  111648. * Gets a string describing the action executed by the current optimization
  111649. * @return description string
  111650. */
  111651. getDescription(): string;
  111652. /**
  111653. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111654. * @param scene defines the current scene where to apply this optimization
  111655. * @param optimizer defines the current optimizer
  111656. * @returns true if everything that can be done was applied
  111657. */
  111658. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111659. }
  111660. /**
  111661. * Defines an optimization used to merge meshes with compatible materials
  111662. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111663. */
  111664. export class MergeMeshesOptimization extends SceneOptimization {
  111665. private static _UpdateSelectionTree;
  111666. /**
  111667. * Gets or sets a boolean which defines if optimization octree has to be updated
  111668. */
  111669. /**
  111670. * Gets or sets a boolean which defines if optimization octree has to be updated
  111671. */
  111672. static UpdateSelectionTree: boolean;
  111673. /**
  111674. * Gets a string describing the action executed by the current optimization
  111675. * @return description string
  111676. */
  111677. getDescription(): string;
  111678. private _canBeMerged;
  111679. /**
  111680. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111681. * @param scene defines the current scene where to apply this optimization
  111682. * @param optimizer defines the current optimizer
  111683. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111684. * @returns true if everything that can be done was applied
  111685. */
  111686. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111687. }
  111688. /**
  111689. * Defines a list of options used by SceneOptimizer
  111690. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111691. */
  111692. export class SceneOptimizerOptions {
  111693. /**
  111694. * Defines the target frame rate to reach (60 by default)
  111695. */
  111696. targetFrameRate: number;
  111697. /**
  111698. * Defines the interval between two checkes (2000ms by default)
  111699. */
  111700. trackerDuration: number;
  111701. /**
  111702. * Gets the list of optimizations to apply
  111703. */
  111704. optimizations: SceneOptimization[];
  111705. /**
  111706. * Creates a new list of options used by SceneOptimizer
  111707. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111708. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111709. */
  111710. constructor(
  111711. /**
  111712. * Defines the target frame rate to reach (60 by default)
  111713. */
  111714. targetFrameRate?: number,
  111715. /**
  111716. * Defines the interval between two checkes (2000ms by default)
  111717. */
  111718. trackerDuration?: number);
  111719. /**
  111720. * Add a new optimization
  111721. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111722. * @returns the current SceneOptimizerOptions
  111723. */
  111724. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111725. /**
  111726. * Add a new custom optimization
  111727. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111728. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111729. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111730. * @returns the current SceneOptimizerOptions
  111731. */
  111732. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111733. /**
  111734. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111735. * @param targetFrameRate defines the target frame rate (60 by default)
  111736. * @returns a SceneOptimizerOptions object
  111737. */
  111738. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111739. /**
  111740. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111741. * @param targetFrameRate defines the target frame rate (60 by default)
  111742. * @returns a SceneOptimizerOptions object
  111743. */
  111744. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111745. /**
  111746. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111747. * @param targetFrameRate defines the target frame rate (60 by default)
  111748. * @returns a SceneOptimizerOptions object
  111749. */
  111750. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111751. }
  111752. /**
  111753. * Class used to run optimizations in order to reach a target frame rate
  111754. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111755. */
  111756. export class SceneOptimizer implements IDisposable {
  111757. private _isRunning;
  111758. private _options;
  111759. private _scene;
  111760. private _currentPriorityLevel;
  111761. private _targetFrameRate;
  111762. private _trackerDuration;
  111763. private _currentFrameRate;
  111764. private _sceneDisposeObserver;
  111765. private _improvementMode;
  111766. /**
  111767. * Defines an observable called when the optimizer reaches the target frame rate
  111768. */
  111769. onSuccessObservable: Observable<SceneOptimizer>;
  111770. /**
  111771. * Defines an observable called when the optimizer enables an optimization
  111772. */
  111773. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111774. /**
  111775. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111776. */
  111777. onFailureObservable: Observable<SceneOptimizer>;
  111778. /**
  111779. * Gets a boolean indicating if the optimizer is in improvement mode
  111780. */
  111781. readonly isInImprovementMode: boolean;
  111782. /**
  111783. * Gets the current priority level (0 at start)
  111784. */
  111785. readonly currentPriorityLevel: number;
  111786. /**
  111787. * Gets the current frame rate checked by the SceneOptimizer
  111788. */
  111789. readonly currentFrameRate: number;
  111790. /**
  111791. * Gets or sets the current target frame rate (60 by default)
  111792. */
  111793. /**
  111794. * Gets or sets the current target frame rate (60 by default)
  111795. */
  111796. targetFrameRate: number;
  111797. /**
  111798. * Gets or sets the current interval between two checks (every 2000ms by default)
  111799. */
  111800. /**
  111801. * Gets or sets the current interval between two checks (every 2000ms by default)
  111802. */
  111803. trackerDuration: number;
  111804. /**
  111805. * Gets the list of active optimizations
  111806. */
  111807. readonly optimizations: SceneOptimization[];
  111808. /**
  111809. * Creates a new SceneOptimizer
  111810. * @param scene defines the scene to work on
  111811. * @param options defines the options to use with the SceneOptimizer
  111812. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111813. * @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)
  111814. */
  111815. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111816. /**
  111817. * Stops the current optimizer
  111818. */
  111819. stop(): void;
  111820. /**
  111821. * Reset the optimizer to initial step (current priority level = 0)
  111822. */
  111823. reset(): void;
  111824. /**
  111825. * Start the optimizer. By default it will try to reach a specific framerate
  111826. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111827. */
  111828. start(): void;
  111829. private _checkCurrentState;
  111830. /**
  111831. * Release all resources
  111832. */
  111833. dispose(): void;
  111834. /**
  111835. * Helper function to create a SceneOptimizer with one single line of code
  111836. * @param scene defines the scene to work on
  111837. * @param options defines the options to use with the SceneOptimizer
  111838. * @param onSuccess defines a callback to call on success
  111839. * @param onFailure defines a callback to call on failure
  111840. * @returns the new SceneOptimizer object
  111841. */
  111842. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111843. }
  111844. }
  111845. declare module BABYLON {
  111846. /**
  111847. * Class used to serialize a scene into a string
  111848. */
  111849. export class SceneSerializer {
  111850. /**
  111851. * Clear cache used by a previous serialization
  111852. */
  111853. static ClearCache(): void;
  111854. /**
  111855. * Serialize a scene into a JSON compatible object
  111856. * @param scene defines the scene to serialize
  111857. * @returns a JSON compatible object
  111858. */
  111859. static Serialize(scene: Scene): any;
  111860. /**
  111861. * Serialize a mesh into a JSON compatible object
  111862. * @param toSerialize defines the mesh to serialize
  111863. * @param withParents defines if parents must be serialized as well
  111864. * @param withChildren defines if children must be serialized as well
  111865. * @returns a JSON compatible object
  111866. */
  111867. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111868. }
  111869. }
  111870. declare module BABYLON {
  111871. /**
  111872. * This represents the different options avilable for the video capture.
  111873. */
  111874. export interface VideoRecorderOptions {
  111875. /** Defines the mime type of the video */
  111876. mimeType: string;
  111877. /** Defines the video the video should be recorded at */
  111878. fps: number;
  111879. /** Defines the chunk size for the recording data */
  111880. recordChunckSize: number;
  111881. /** The audio tracks to attach to the record */
  111882. audioTracks?: MediaStreamTrack[];
  111883. }
  111884. /**
  111885. * This can helps recording videos from BabylonJS.
  111886. * This is based on the available WebRTC functionalities of the browser.
  111887. *
  111888. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111889. */
  111890. export class VideoRecorder {
  111891. private static readonly _defaultOptions;
  111892. /**
  111893. * Returns wehther or not the VideoRecorder is available in your browser.
  111894. * @param engine Defines the Babylon Engine to check the support for
  111895. * @returns true if supported otherwise false
  111896. */
  111897. static IsSupported(engine: Engine): boolean;
  111898. private readonly _options;
  111899. private _canvas;
  111900. private _mediaRecorder;
  111901. private _recordedChunks;
  111902. private _fileName;
  111903. private _resolve;
  111904. private _reject;
  111905. /**
  111906. * True wether a recording is already in progress.
  111907. */
  111908. readonly isRecording: boolean;
  111909. /**
  111910. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111911. * a video file.
  111912. * @param engine Defines the BabylonJS Engine you wish to record
  111913. * @param options Defines options that can be used to customized the capture
  111914. */
  111915. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111916. /**
  111917. * Stops the current recording before the default capture timeout passed in the startRecording
  111918. * functions.
  111919. */
  111920. stopRecording(): void;
  111921. /**
  111922. * Starts recording the canvas for a max duration specified in parameters.
  111923. * @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.
  111924. * @param maxDuration Defines the maximum recording time in seconds.
  111925. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111926. * @return a promise callback at the end of the recording with the video data in Blob.
  111927. */
  111928. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111929. /**
  111930. * Releases internal resources used during the recording.
  111931. */
  111932. dispose(): void;
  111933. private _handleDataAvailable;
  111934. private _handleError;
  111935. private _handleStop;
  111936. }
  111937. }
  111938. declare module BABYLON {
  111939. /**
  111940. * Helper class to push actions to a pool of workers.
  111941. */
  111942. export class WorkerPool implements IDisposable {
  111943. private _workerInfos;
  111944. private _pendingActions;
  111945. /**
  111946. * Constructor
  111947. * @param workers Array of workers to use for actions
  111948. */
  111949. constructor(workers: Array<Worker>);
  111950. /**
  111951. * Terminates all workers and clears any pending actions.
  111952. */
  111953. dispose(): void;
  111954. /**
  111955. * Pushes an action to the worker pool. If all the workers are active, the action will be
  111956. * pended until a worker has completed its action.
  111957. * @param action The action to perform. Call onComplete when the action is complete.
  111958. */
  111959. push(action: (worker: Worker, onComplete: () => void) => void): void;
  111960. private _execute;
  111961. }
  111962. }
  111963. declare module BABYLON {
  111964. /**
  111965. * Class containing a set of static utilities functions for screenshots
  111966. */
  111967. export class ScreenshotTools {
  111968. /**
  111969. * Captures a screenshot of the current rendering
  111970. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111971. * @param engine defines the rendering engine
  111972. * @param camera defines the source camera
  111973. * @param size This parameter can be set to a single number or to an object with the
  111974. * following (optional) properties: precision, width, height. If a single number is passed,
  111975. * it will be used for both width and height. If an object is passed, the screenshot size
  111976. * will be derived from the parameters. The precision property is a multiplier allowing
  111977. * rendering at a higher or lower resolution
  111978. * @param successCallback defines the callback receives a single parameter which contains the
  111979. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111980. * src parameter of an <img> to display it
  111981. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  111982. * Check your browser for supported MIME types
  111983. */
  111984. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  111985. /**
  111986. * Generates an image screenshot from the specified camera.
  111987. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111988. * @param engine The engine to use for rendering
  111989. * @param camera The camera to use for rendering
  111990. * @param size This parameter can be set to a single number or to an object with the
  111991. * following (optional) properties: precision, width, height. If a single number is passed,
  111992. * it will be used for both width and height. If an object is passed, the screenshot size
  111993. * will be derived from the parameters. The precision property is a multiplier allowing
  111994. * rendering at a higher or lower resolution
  111995. * @param successCallback The callback receives a single parameter which contains the
  111996. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111997. * src parameter of an <img> to display it
  111998. * @param mimeType The MIME type of the screenshot image (default: image/png).
  111999. * Check your browser for supported MIME types
  112000. * @param samples Texture samples (default: 1)
  112001. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  112002. * @param fileName A name for for the downloaded file.
  112003. */
  112004. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  112005. }
  112006. }
  112007. declare module BABYLON {
  112008. /**
  112009. * A cursor which tracks a point on a path
  112010. */
  112011. export class PathCursor {
  112012. private path;
  112013. /**
  112014. * Stores path cursor callbacks for when an onchange event is triggered
  112015. */
  112016. private _onchange;
  112017. /**
  112018. * The value of the path cursor
  112019. */
  112020. value: number;
  112021. /**
  112022. * The animation array of the path cursor
  112023. */
  112024. animations: Animation[];
  112025. /**
  112026. * Initializes the path cursor
  112027. * @param path The path to track
  112028. */
  112029. constructor(path: Path2);
  112030. /**
  112031. * Gets the cursor point on the path
  112032. * @returns A point on the path cursor at the cursor location
  112033. */
  112034. getPoint(): Vector3;
  112035. /**
  112036. * Moves the cursor ahead by the step amount
  112037. * @param step The amount to move the cursor forward
  112038. * @returns This path cursor
  112039. */
  112040. moveAhead(step?: number): PathCursor;
  112041. /**
  112042. * Moves the cursor behind by the step amount
  112043. * @param step The amount to move the cursor back
  112044. * @returns This path cursor
  112045. */
  112046. moveBack(step?: number): PathCursor;
  112047. /**
  112048. * Moves the cursor by the step amount
  112049. * If the step amount is greater than one, an exception is thrown
  112050. * @param step The amount to move the cursor
  112051. * @returns This path cursor
  112052. */
  112053. move(step: number): PathCursor;
  112054. /**
  112055. * Ensures that the value is limited between zero and one
  112056. * @returns This path cursor
  112057. */
  112058. private ensureLimits;
  112059. /**
  112060. * Runs onchange callbacks on change (used by the animation engine)
  112061. * @returns This path cursor
  112062. */
  112063. private raiseOnChange;
  112064. /**
  112065. * Executes a function on change
  112066. * @param f A path cursor onchange callback
  112067. * @returns This path cursor
  112068. */
  112069. onchange(f: (cursor: PathCursor) => void): PathCursor;
  112070. }
  112071. }
  112072. declare module BABYLON {
  112073. /** @hidden */
  112074. export var blurPixelShader: {
  112075. name: string;
  112076. shader: string;
  112077. };
  112078. }
  112079. declare module BABYLON {
  112080. /** @hidden */
  112081. export var bones300Declaration: {
  112082. name: string;
  112083. shader: string;
  112084. };
  112085. }
  112086. declare module BABYLON {
  112087. /** @hidden */
  112088. export var instances300Declaration: {
  112089. name: string;
  112090. shader: string;
  112091. };
  112092. }
  112093. declare module BABYLON {
  112094. /** @hidden */
  112095. export var pointCloudVertexDeclaration: {
  112096. name: string;
  112097. shader: string;
  112098. };
  112099. }
  112100. // Mixins
  112101. interface Window {
  112102. mozIndexedDB: IDBFactory;
  112103. webkitIndexedDB: IDBFactory;
  112104. msIndexedDB: IDBFactory;
  112105. webkitURL: typeof URL;
  112106. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  112107. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  112108. WebGLRenderingContext: WebGLRenderingContext;
  112109. MSGesture: MSGesture;
  112110. CANNON: any;
  112111. AudioContext: AudioContext;
  112112. webkitAudioContext: AudioContext;
  112113. PointerEvent: any;
  112114. Math: Math;
  112115. Uint8Array: Uint8ArrayConstructor;
  112116. Float32Array: Float32ArrayConstructor;
  112117. mozURL: typeof URL;
  112118. msURL: typeof URL;
  112119. VRFrameData: any; // WebVR, from specs 1.1
  112120. DracoDecoderModule: any;
  112121. setImmediate(handler: (...args: any[]) => void): number;
  112122. }
  112123. interface HTMLCanvasElement {
  112124. requestPointerLock(): void;
  112125. msRequestPointerLock?(): void;
  112126. mozRequestPointerLock?(): void;
  112127. webkitRequestPointerLock?(): void;
  112128. /** Track wether a record is in progress */
  112129. isRecording: boolean;
  112130. /** Capture Stream method defined by some browsers */
  112131. captureStream(fps?: number): MediaStream;
  112132. }
  112133. interface CanvasRenderingContext2D {
  112134. msImageSmoothingEnabled: boolean;
  112135. }
  112136. interface MouseEvent {
  112137. mozMovementX: number;
  112138. mozMovementY: number;
  112139. webkitMovementX: number;
  112140. webkitMovementY: number;
  112141. msMovementX: number;
  112142. msMovementY: number;
  112143. }
  112144. interface Navigator {
  112145. mozGetVRDevices: (any: any) => any;
  112146. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112147. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112148. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112149. webkitGetGamepads(): Gamepad[];
  112150. msGetGamepads(): Gamepad[];
  112151. webkitGamepads(): Gamepad[];
  112152. }
  112153. interface HTMLVideoElement {
  112154. mozSrcObject: any;
  112155. }
  112156. interface Math {
  112157. fround(x: number): number;
  112158. imul(a: number, b: number): number;
  112159. }
  112160. interface WebGLProgram {
  112161. context?: WebGLRenderingContext;
  112162. vertexShader?: WebGLShader;
  112163. fragmentShader?: WebGLShader;
  112164. isParallelCompiled: boolean;
  112165. onCompiled?: () => void;
  112166. }
  112167. interface WebGLRenderingContext {
  112168. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  112169. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  112170. vertexAttribDivisor(index: number, divisor: number): void;
  112171. createVertexArray(): any;
  112172. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  112173. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  112174. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  112175. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  112176. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  112177. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  112178. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  112179. // Queries
  112180. createQuery(): WebGLQuery;
  112181. deleteQuery(query: WebGLQuery): void;
  112182. beginQuery(target: number, query: WebGLQuery): void;
  112183. endQuery(target: number): void;
  112184. getQueryParameter(query: WebGLQuery, pname: number): any;
  112185. getQuery(target: number, pname: number): any;
  112186. MAX_SAMPLES: number;
  112187. RGBA8: number;
  112188. READ_FRAMEBUFFER: number;
  112189. DRAW_FRAMEBUFFER: number;
  112190. UNIFORM_BUFFER: number;
  112191. HALF_FLOAT_OES: number;
  112192. RGBA16F: number;
  112193. RGBA32F: number;
  112194. R32F: number;
  112195. RG32F: number;
  112196. RGB32F: number;
  112197. R16F: number;
  112198. RG16F: number;
  112199. RGB16F: number;
  112200. RED: number;
  112201. RG: number;
  112202. R8: number;
  112203. RG8: number;
  112204. UNSIGNED_INT_24_8: number;
  112205. DEPTH24_STENCIL8: number;
  112206. /* Multiple Render Targets */
  112207. drawBuffers(buffers: number[]): void;
  112208. readBuffer(src: number): void;
  112209. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  112210. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  112211. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  112212. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  112213. // Occlusion Query
  112214. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  112215. ANY_SAMPLES_PASSED: number;
  112216. QUERY_RESULT_AVAILABLE: number;
  112217. QUERY_RESULT: number;
  112218. }
  112219. interface WebGLBuffer {
  112220. references: number;
  112221. capacity: number;
  112222. is32Bits: boolean;
  112223. }
  112224. interface WebGLProgram {
  112225. transformFeedback?: WebGLTransformFeedback | null;
  112226. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  112227. }
  112228. interface EXT_disjoint_timer_query {
  112229. QUERY_COUNTER_BITS_EXT: number;
  112230. TIME_ELAPSED_EXT: number;
  112231. TIMESTAMP_EXT: number;
  112232. GPU_DISJOINT_EXT: number;
  112233. QUERY_RESULT_EXT: number;
  112234. QUERY_RESULT_AVAILABLE_EXT: number;
  112235. queryCounterEXT(query: WebGLQuery, target: number): void;
  112236. createQueryEXT(): WebGLQuery;
  112237. beginQueryEXT(target: number, query: WebGLQuery): void;
  112238. endQueryEXT(target: number): void;
  112239. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  112240. deleteQueryEXT(query: WebGLQuery): void;
  112241. }
  112242. interface WebGLUniformLocation {
  112243. _currentState: any;
  112244. }
  112245. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  112246. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  112247. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  112248. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112249. interface WebGLRenderingContext {
  112250. readonly RASTERIZER_DISCARD: number;
  112251. readonly DEPTH_COMPONENT24: number;
  112252. readonly TEXTURE_3D: number;
  112253. readonly TEXTURE_2D_ARRAY: number;
  112254. readonly TEXTURE_COMPARE_FUNC: number;
  112255. readonly TEXTURE_COMPARE_MODE: number;
  112256. readonly COMPARE_REF_TO_TEXTURE: number;
  112257. readonly TEXTURE_WRAP_R: number;
  112258. readonly HALF_FLOAT: number;
  112259. readonly RGB8: number;
  112260. readonly RED_INTEGER: number;
  112261. readonly RG_INTEGER: number;
  112262. readonly RGB_INTEGER: number;
  112263. readonly RGBA_INTEGER: number;
  112264. readonly R8_SNORM: number;
  112265. readonly RG8_SNORM: number;
  112266. readonly RGB8_SNORM: number;
  112267. readonly RGBA8_SNORM: number;
  112268. readonly R8I: number;
  112269. readonly RG8I: number;
  112270. readonly RGB8I: number;
  112271. readonly RGBA8I: number;
  112272. readonly R8UI: number;
  112273. readonly RG8UI: number;
  112274. readonly RGB8UI: number;
  112275. readonly RGBA8UI: number;
  112276. readonly R16I: number;
  112277. readonly RG16I: number;
  112278. readonly RGB16I: number;
  112279. readonly RGBA16I: number;
  112280. readonly R16UI: number;
  112281. readonly RG16UI: number;
  112282. readonly RGB16UI: number;
  112283. readonly RGBA16UI: number;
  112284. readonly R32I: number;
  112285. readonly RG32I: number;
  112286. readonly RGB32I: number;
  112287. readonly RGBA32I: number;
  112288. readonly R32UI: number;
  112289. readonly RG32UI: number;
  112290. readonly RGB32UI: number;
  112291. readonly RGBA32UI: number;
  112292. readonly RGB10_A2UI: number;
  112293. readonly R11F_G11F_B10F: number;
  112294. readonly RGB9_E5: number;
  112295. readonly RGB10_A2: number;
  112296. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  112297. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  112298. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  112299. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  112300. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  112301. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  112302. 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;
  112303. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  112304. readonly TRANSFORM_FEEDBACK: number;
  112305. readonly INTERLEAVED_ATTRIBS: number;
  112306. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  112307. createTransformFeedback(): WebGLTransformFeedback;
  112308. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  112309. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  112310. beginTransformFeedback(primitiveMode: number): void;
  112311. endTransformFeedback(): void;
  112312. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  112313. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112314. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112315. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112316. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  112317. }
  112318. interface ImageBitmap {
  112319. readonly width: number;
  112320. readonly height: number;
  112321. close(): void;
  112322. }
  112323. interface WebGLQuery extends WebGLObject {
  112324. }
  112325. declare var WebGLQuery: {
  112326. prototype: WebGLQuery;
  112327. new(): WebGLQuery;
  112328. };
  112329. interface WebGLSampler extends WebGLObject {
  112330. }
  112331. declare var WebGLSampler: {
  112332. prototype: WebGLSampler;
  112333. new(): WebGLSampler;
  112334. };
  112335. interface WebGLSync extends WebGLObject {
  112336. }
  112337. declare var WebGLSync: {
  112338. prototype: WebGLSync;
  112339. new(): WebGLSync;
  112340. };
  112341. interface WebGLTransformFeedback extends WebGLObject {
  112342. }
  112343. declare var WebGLTransformFeedback: {
  112344. prototype: WebGLTransformFeedback;
  112345. new(): WebGLTransformFeedback;
  112346. };
  112347. interface WebGLVertexArrayObject extends WebGLObject {
  112348. }
  112349. declare var WebGLVertexArrayObject: {
  112350. prototype: WebGLVertexArrayObject;
  112351. new(): WebGLVertexArrayObject;
  112352. };
  112353. // Type definitions for WebVR API
  112354. // Project: https://w3c.github.io/webvr/
  112355. // Definitions by: six a <https://github.com/lostfictions>
  112356. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112357. interface VRDisplay extends EventTarget {
  112358. /**
  112359. * Dictionary of capabilities describing the VRDisplay.
  112360. */
  112361. readonly capabilities: VRDisplayCapabilities;
  112362. /**
  112363. * z-depth defining the far plane of the eye view frustum
  112364. * enables mapping of values in the render target depth
  112365. * attachment to scene coordinates. Initially set to 10000.0.
  112366. */
  112367. depthFar: number;
  112368. /**
  112369. * z-depth defining the near plane of the eye view frustum
  112370. * enables mapping of values in the render target depth
  112371. * attachment to scene coordinates. Initially set to 0.01.
  112372. */
  112373. depthNear: number;
  112374. /**
  112375. * An identifier for this distinct VRDisplay. Used as an
  112376. * association point in the Gamepad API.
  112377. */
  112378. readonly displayId: number;
  112379. /**
  112380. * A display name, a user-readable name identifying it.
  112381. */
  112382. readonly displayName: string;
  112383. readonly isConnected: boolean;
  112384. readonly isPresenting: boolean;
  112385. /**
  112386. * If this VRDisplay supports room-scale experiences, the optional
  112387. * stage attribute contains details on the room-scale parameters.
  112388. */
  112389. readonly stageParameters: VRStageParameters | null;
  112390. /**
  112391. * Passing the value returned by `requestAnimationFrame` to
  112392. * `cancelAnimationFrame` will unregister the callback.
  112393. * @param handle Define the hanle of the request to cancel
  112394. */
  112395. cancelAnimationFrame(handle: number): void;
  112396. /**
  112397. * Stops presenting to the VRDisplay.
  112398. * @returns a promise to know when it stopped
  112399. */
  112400. exitPresent(): Promise<void>;
  112401. /**
  112402. * Return the current VREyeParameters for the given eye.
  112403. * @param whichEye Define the eye we want the parameter for
  112404. * @returns the eye parameters
  112405. */
  112406. getEyeParameters(whichEye: string): VREyeParameters;
  112407. /**
  112408. * Populates the passed VRFrameData with the information required to render
  112409. * the current frame.
  112410. * @param frameData Define the data structure to populate
  112411. * @returns true if ok otherwise false
  112412. */
  112413. getFrameData(frameData: VRFrameData): boolean;
  112414. /**
  112415. * Get the layers currently being presented.
  112416. * @returns the list of VR layers
  112417. */
  112418. getLayers(): VRLayer[];
  112419. /**
  112420. * Return a VRPose containing the future predicted pose of the VRDisplay
  112421. * when the current frame will be presented. The value returned will not
  112422. * change until JavaScript has returned control to the browser.
  112423. *
  112424. * The VRPose will contain the position, orientation, velocity,
  112425. * and acceleration of each of these properties.
  112426. * @returns the pose object
  112427. */
  112428. getPose(): VRPose;
  112429. /**
  112430. * Return the current instantaneous pose of the VRDisplay, with no
  112431. * prediction applied.
  112432. * @returns the current instantaneous pose
  112433. */
  112434. getImmediatePose(): VRPose;
  112435. /**
  112436. * The callback passed to `requestAnimationFrame` will be called
  112437. * any time a new frame should be rendered. When the VRDisplay is
  112438. * presenting the callback will be called at the native refresh
  112439. * rate of the HMD. When not presenting this function acts
  112440. * identically to how window.requestAnimationFrame acts. Content should
  112441. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112442. * asynchronously from other displays and at differing refresh rates.
  112443. * @param callback Define the eaction to run next frame
  112444. * @returns the request handle it
  112445. */
  112446. requestAnimationFrame(callback: FrameRequestCallback): number;
  112447. /**
  112448. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112449. * Repeat calls while already presenting will update the VRLayers being displayed.
  112450. * @param layers Define the list of layer to present
  112451. * @returns a promise to know when the request has been fulfilled
  112452. */
  112453. requestPresent(layers: VRLayer[]): Promise<void>;
  112454. /**
  112455. * Reset the pose for this display, treating its current position and
  112456. * orientation as the "origin/zero" values. VRPose.position,
  112457. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112458. * updated when calling resetPose(). This should be called in only
  112459. * sitting-space experiences.
  112460. */
  112461. resetPose(): void;
  112462. /**
  112463. * The VRLayer provided to the VRDisplay will be captured and presented
  112464. * in the HMD. Calling this function has the same effect on the source
  112465. * canvas as any other operation that uses its source image, and canvases
  112466. * created without preserveDrawingBuffer set to true will be cleared.
  112467. * @param pose Define the pose to submit
  112468. */
  112469. submitFrame(pose?: VRPose): void;
  112470. }
  112471. declare var VRDisplay: {
  112472. prototype: VRDisplay;
  112473. new(): VRDisplay;
  112474. };
  112475. interface VRLayer {
  112476. leftBounds?: number[] | Float32Array | null;
  112477. rightBounds?: number[] | Float32Array | null;
  112478. source?: HTMLCanvasElement | null;
  112479. }
  112480. interface VRDisplayCapabilities {
  112481. readonly canPresent: boolean;
  112482. readonly hasExternalDisplay: boolean;
  112483. readonly hasOrientation: boolean;
  112484. readonly hasPosition: boolean;
  112485. readonly maxLayers: number;
  112486. }
  112487. interface VREyeParameters {
  112488. /** @deprecated */
  112489. readonly fieldOfView: VRFieldOfView;
  112490. readonly offset: Float32Array;
  112491. readonly renderHeight: number;
  112492. readonly renderWidth: number;
  112493. }
  112494. interface VRFieldOfView {
  112495. readonly downDegrees: number;
  112496. readonly leftDegrees: number;
  112497. readonly rightDegrees: number;
  112498. readonly upDegrees: number;
  112499. }
  112500. interface VRFrameData {
  112501. readonly leftProjectionMatrix: Float32Array;
  112502. readonly leftViewMatrix: Float32Array;
  112503. readonly pose: VRPose;
  112504. readonly rightProjectionMatrix: Float32Array;
  112505. readonly rightViewMatrix: Float32Array;
  112506. readonly timestamp: number;
  112507. }
  112508. interface VRPose {
  112509. readonly angularAcceleration: Float32Array | null;
  112510. readonly angularVelocity: Float32Array | null;
  112511. readonly linearAcceleration: Float32Array | null;
  112512. readonly linearVelocity: Float32Array | null;
  112513. readonly orientation: Float32Array | null;
  112514. readonly position: Float32Array | null;
  112515. readonly timestamp: number;
  112516. }
  112517. interface VRStageParameters {
  112518. sittingToStandingTransform?: Float32Array;
  112519. sizeX?: number;
  112520. sizeY?: number;
  112521. }
  112522. interface Navigator {
  112523. getVRDisplays(): Promise<VRDisplay[]>;
  112524. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112525. }
  112526. interface Window {
  112527. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112528. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112529. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112530. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112531. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112532. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112533. }
  112534. interface Gamepad {
  112535. readonly displayId: number;
  112536. }
  112537. interface XRDevice {
  112538. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112539. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112540. }
  112541. interface XRSession {
  112542. getInputSources(): Array<any>;
  112543. baseLayer: XRWebGLLayer;
  112544. requestFrameOfReference(type: string): Promise<void>;
  112545. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112546. end(): Promise<void>;
  112547. requestAnimationFrame: Function;
  112548. addEventListener: Function;
  112549. }
  112550. interface XRSessionCreationOptions {
  112551. outputContext?: WebGLRenderingContext | null;
  112552. immersive?: boolean;
  112553. environmentIntegration?: boolean;
  112554. }
  112555. interface XRLayer {
  112556. getViewport: Function;
  112557. framebufferWidth: number;
  112558. framebufferHeight: number;
  112559. }
  112560. interface XRView {
  112561. projectionMatrix: Float32Array;
  112562. }
  112563. interface XRFrame {
  112564. getDevicePose: Function;
  112565. getInputPose: Function;
  112566. views: Array<XRView>;
  112567. baseLayer: XRLayer;
  112568. }
  112569. interface XRFrameOfReference {
  112570. }
  112571. interface XRWebGLLayer extends XRLayer {
  112572. framebuffer: WebGLFramebuffer;
  112573. }
  112574. declare var XRWebGLLayer: {
  112575. prototype: XRWebGLLayer;
  112576. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112577. };